@@ -26,7 +26,7 @@ import (
2626 v1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1"
2727)
2828
29- func validateImages (ctx context.Context , spec * v1.ClusterPolicySpec ) error {
29+ func validateImages (ctx context.Context , spec * v1.ClusterPolicySpec , client * regclient. RegClient ) error {
3030 // Driver
3131 path , err := v1 .ImagePath (& spec .Driver )
3232 if err != nil {
@@ -35,7 +35,7 @@ func validateImages(ctx context.Context, spec *v1.ClusterPolicySpec) error {
3535 // For driver, we must append the os-tag
3636 path += "-ubuntu22.04"
3737
38- err = validateImage (ctx , path )
38+ err = validateImage (ctx , client , path )
3939 if err != nil {
4040 return fmt .Errorf ("failed to validate image %s: %v" , path , err )
4141 }
@@ -46,7 +46,7 @@ func validateImages(ctx context.Context, spec *v1.ClusterPolicySpec) error {
4646 return fmt .Errorf ("failed to construct the image path: %v" , err )
4747 }
4848
49- err = validateImage (ctx , path )
49+ err = validateImage (ctx , client , path )
5050 if err != nil {
5151 return fmt .Errorf ("failed to validate image %s: %v" , path , err )
5252 }
@@ -57,7 +57,7 @@ func validateImages(ctx context.Context, spec *v1.ClusterPolicySpec) error {
5757 return fmt .Errorf ("failed to construct the image path: %v" , err )
5858 }
5959
60- err = validateImage (ctx , path )
60+ err = validateImage (ctx , client , path )
6161 if err != nil {
6262 return fmt .Errorf ("failed to validate image %s: %v" , path , err )
6363 }
@@ -68,7 +68,7 @@ func validateImages(ctx context.Context, spec *v1.ClusterPolicySpec) error {
6868 return fmt .Errorf ("failed to construct the image path: %v" , err )
6969 }
7070
71- err = validateImage (ctx , path )
71+ err = validateImage (ctx , client , path )
7272 if err != nil {
7373 return fmt .Errorf ("failed to validate image %s: %v" , path , err )
7474 }
@@ -79,7 +79,7 @@ func validateImages(ctx context.Context, spec *v1.ClusterPolicySpec) error {
7979 return fmt .Errorf ("failed to construct the image path: %v" , err )
8080 }
8181
82- err = validateImage (ctx , path )
82+ err = validateImage (ctx , client , path )
8383 if err != nil {
8484 return fmt .Errorf ("failed to validate image %s: %v" , path , err )
8585 }
@@ -90,7 +90,7 @@ func validateImages(ctx context.Context, spec *v1.ClusterPolicySpec) error {
9090 return fmt .Errorf ("failed to construct the image path: %v" , err )
9191 }
9292
93- err = validateImage (ctx , path )
93+ err = validateImage (ctx , client , path )
9494 if err != nil {
9595 return fmt .Errorf ("failed to validate image %s: %v" , path , err )
9696 }
@@ -101,7 +101,7 @@ func validateImages(ctx context.Context, spec *v1.ClusterPolicySpec) error {
101101 return fmt .Errorf ("failed to construct the image path: %v" , err )
102102 }
103103
104- err = validateImage (ctx , path )
104+ err = validateImage (ctx , client , path )
105105 if err != nil {
106106 return fmt .Errorf ("failed to validate image %s: %v" , path , err )
107107 }
@@ -114,7 +114,7 @@ func validateImages(ctx context.Context, spec *v1.ClusterPolicySpec) error {
114114 // For GDS driver, we must append the os-tag
115115 path += "-ubuntu22.04"
116116
117- err = validateImage (ctx , path )
117+ err = validateImage (ctx , client , path )
118118 if err != nil {
119119 return fmt .Errorf ("failed to validate image %s: %v" , path , err )
120120 }
@@ -125,7 +125,7 @@ func validateImages(ctx context.Context, spec *v1.ClusterPolicySpec) error {
125125 return fmt .Errorf ("failed to construct the image path: %v" , err )
126126 }
127127
128- err = validateImage (ctx , path )
128+ err = validateImage (ctx , client , path )
129129 if err != nil {
130130 return fmt .Errorf ("failed to validate image %s: %v" , path , err )
131131 }
@@ -136,7 +136,7 @@ func validateImages(ctx context.Context, spec *v1.ClusterPolicySpec) error {
136136 return fmt .Errorf ("failed to construct the image path: %v" , err )
137137 }
138138
139- err = validateImage (ctx , path )
139+ err = validateImage (ctx , client , path )
140140 if err != nil {
141141 return fmt .Errorf ("failed to validate image %s: %v" , path , err )
142142 }
@@ -147,16 +147,15 @@ func validateImages(ctx context.Context, spec *v1.ClusterPolicySpec) error {
147147 return fmt .Errorf ("failed to construct the image path: %v" , err )
148148 }
149149
150- err = validateImage (ctx , path )
150+ err = validateImage (ctx , client , path )
151151 if err != nil {
152152 return fmt .Errorf ("failed to validate image %s: %v" , path , err )
153153 }
154154
155155 return nil
156156}
157157
158- func validateImage (ctx context.Context , path string ) error {
159- var client = regclient .New ()
158+ func validateImage (ctx context.Context , client * regclient.RegClient , path string ) error {
160159 ref , err := ref .New (path )
161160 if err != nil {
162161 return fmt .Errorf ("failed to construct an image reference: %v" , err )
0 commit comments