You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
errs=append(errs, field.Invalid(field.NewPath("spec.placement.host.dedicatedHost.id"), placement.Host.DedicatedHost.ID, "id must start with 'h-' followed by 8 or 17 lowercase hexadecimal characters (0-9 and a-f)"))
// We need to make sure DedicatedHost is set with an ID
957
957
ifplacement.Host.DedicatedHost==nil {
958
958
errs=append(errs, field.Required(field.NewPath("spec.placement.host.dedicatedHost"), "dedicatedHost is required when hostAffinity is DedicatedHost, and optional otherwise"))
959
959
} else {
960
-
// If not set, return required error. If it does not match pattern, return pattern failure message.
961
-
ifplacement.Host.DedicatedHost.ID=="" {
962
-
errs=append(errs, field.Required(field.NewPath("spec.placement.host.dedicatedHost.id"), "id is required and must start with 'h-' followed by 8 or 17 lowercase hexadecimal characters (0-9 and a-f)"))
errs=append(errs, field.Invalid(field.NewPath("spec.placement.host.dedicatedHost.id"), placement.Host.DedicatedHost.ID, "id must start with 'h-' followed by 8 or 17 lowercase hexadecimal characters (0-9 and a-f)"))
errs=append(errs, field.Invalid(field.NewPath("spec.placement.host.affinity"), placement.Host.Affinity, "hostAffinity must be either AnyAvailable or DedicatedHost"))
// User Provided requires the ID being set of the host to use
1000
+
ifhost.ID=="" {
1001
+
errs=append(errs, field.Required(field.NewPath("spec.placement.host.dedicatedHost.id"), "id is required when allocationStrategy is UserProvided and must start with 'h-' followed by 8 or 17 lowercase hexadecimal characters (0-9 and a-f)"))
errs=append(errs, field.Invalid(field.NewPath("spec.placement.host.dedicatedHost.id"), host.ID, "id must start with 'h-' followed by 8 or 17 lowercase hexadecimal characters (0-9 and a-f)"))
1004
+
}
1005
+
1006
+
// DynamicHostAllocation is not allowed if user provided
1007
+
ifhost.DynamicHostAllocation!=nil {
1008
+
errs=append(errs, field.Invalid(field.NewPath("spec.placement.host.dedicatedHost.dynamicHostAllocation"), host.ID, "dynamicHostAllocation is only allowed when allocationStrategy is Dynamic"))
1009
+
}
1010
+
casemachinev1beta1.AllocationStrategyDynamic:
1011
+
// ID must not be set
1012
+
ifhost.ID!="" {
1013
+
errs=append(errs, field.Forbidden(field.NewPath("spec.placement.host.dedicatedHost.id"), "id is only allowed when allocationStrategy is Provided"))
1014
+
}
1015
+
1016
+
// Validate DynamicHostAllocation if present
1017
+
ifhost.DynamicHostAllocation!=nil {
1018
+
// MinProperties=1: At least one property must be set
1019
+
// Currently only Tags exists, so if Tags is nil, the struct is empty
1020
+
ifhost.DynamicHostAllocation.Tags==nil {
1021
+
errs=append(errs, field.Required(field.NewPath("spec.placement.host.dedicatedHost.dynamicHostAllocation.tags"), "at least one property must be specified in dynamicHostAllocation"))
1022
+
} else {
1023
+
tags:=*host.DynamicHostAllocation.Tags
1024
+
1025
+
// MinItems=1: At least 1 tag must be specified
1026
+
iflen(tags) <1 {
1027
+
errs=append(errs, field.Invalid(field.NewPath("spec.placement.host.dedicatedHost.dynamicHostAllocation.tags"), len(tags), "at least 1 tag must be specified"))
1028
+
}
1029
+
1030
+
// MaxItems=50: Maximum 50 tags can be specified
1031
+
iflen(tags) >50 {
1032
+
errs=append(errs, field.Invalid(field.NewPath("spec.placement.host.dedicatedHost.dynamicHostAllocation.tags"), len(tags), "maximum 50 tags can be specified"))
0 commit comments