File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,8 @@ limitations under the License.
1717package v1beta1
1818
1919import (
20+ "k8s.io/apimachinery/pkg/util/validation/field"
2021 "k8s.io/utils/ptr"
21-
2222 "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/optional"
2323)
2424
@@ -75,6 +75,24 @@ func (f *ImageFilter) IsZero() bool {
7575 return f .Name == nil && len (f .Tags ) == 0
7676}
7777
78+ // Validate performs validation on [ImageParam], returning a list of field errors using the provided base path.
79+ // It is intended to be used in the validation webhooks of resources containing [Image].
80+ func (i * ImageParam ) Validate (base field.Path ) field.ErrorList {
81+ var errors field.ErrorList
82+ // Not possible to validate the image if it is missing
83+ if i == nil {
84+ errors = append (errors , field .Required (& base , "image is required" ))
85+ return errors
86+ }
87+ if i .Filter .Name == nil || i .Filter .Tags == nil {
88+ errors = append (errors , field .Required (base .Child ("Image filter" ), "either name or tags of image are missing" ))
89+ }
90+ if i .ImageRef .Name == "" {
91+ errors = append (errors , field .Required (base .Child ("ORC mage Regerecne" ), "Orc image is missing" ))
92+ }
93+ return errors
94+ }
95+
7896type ExternalRouterIPParam struct {
7997 // The FixedIP in the corresponding subnet
8098 FixedIP string `json:"fixedIP,omitempty"`
You can’t perform that action at this time.
0 commit comments