1
0
mirror of https://github.com/lxc/incus.git synced 2026-02-05 18:45:46 +01:00
Files
incus/internal/server/device/device_utils_instance.go
JUN JIE NAN d2741f464e incusd: Simplify code by using modern constructs
Using more modern features of Go, such as:
- conditional assignment -> built-in min or max in go1.21,
- sort.Slice -> slices.Sort in go1.21,
- loop assign map -> maps.Copy in go1.21,
- []byte(fmt.Sprintf...) -> fmt.Appendf(nil,...) in go1.19,
- strings.HasPrefix / strings.TrimPrefix -> strings.CutPrefix in go1.20

Signed-off-by: JUN JIE NAN <nanjunjie@gmail.com>
2025-05-17 12:17:39 -04:00

19 lines
581 B
Go

package device
import (
"slices"
"github.com/lxc/incus/v6/internal/server/instance/instancetype"
)
// instanceSupported is a helper function to check instance type is supported for validation.
// Always returns true if supplied instance type is Any, to support profile validation.
func instanceSupported(instType instancetype.Type, supportedTypes ...instancetype.Type) bool {
// If instance type is Any, then profile validation is occurring and we need to support this.
if instType == instancetype.Any {
return true
}
return slices.Contains(supportedTypes, instType)
}