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