@@ -228,41 +228,41 @@ func TestCloudConfigInput(t *testing.T) {
228228 t .Run ("SnapstoreProxy" , func (t * testing.T ) {
229229 for _ , tc := range []struct {
230230 name string
231- makeCloudConfig func () (* cloudinit.CloudConfig , error )
231+ makeCloudConfig func (scheme string ) (* cloudinit.CloudConfig , error )
232232 }{
233233 {
234234 name : "ControlPlaneInit" ,
235- makeCloudConfig : func () (* cloudinit.CloudConfig , error ) {
235+ makeCloudConfig : func (scheme string ) (* cloudinit.CloudConfig , error ) {
236236 return cloudinit .NewInitControlPlane (& cloudinit.ControlPlaneInitInput {
237237 KubernetesVersion : "v1.25.0" ,
238238 Token : strings .Repeat ("a" , 32 ),
239239 TokenTTL : 100 ,
240- SnapstoreProxyScheme : "https" ,
240+ SnapstoreProxyScheme : scheme ,
241241 SnapstoreProxyDomain : "snapstore.domain.com" ,
242242 SnapstoreProxyId : "ID123456789" ,
243243 })
244244 },
245245 },
246246 {
247247 name : "ControlPlaneJoin" ,
248- makeCloudConfig : func () (* cloudinit.CloudConfig , error ) {
248+ makeCloudConfig : func (scheme string ) (* cloudinit.CloudConfig , error ) {
249249 return cloudinit .NewJoinControlPlane (& cloudinit.ControlPlaneJoinInput {
250250 KubernetesVersion : "v1.25.0" ,
251251 Token : strings .Repeat ("a" , 32 ),
252252 TokenTTL : 100 ,
253- SnapstoreProxyScheme : "https" ,
253+ SnapstoreProxyScheme : scheme ,
254254 SnapstoreProxyDomain : "snapstore.domain.com" ,
255255 SnapstoreProxyId : "ID123456789" ,
256256 })
257257 },
258258 },
259259 {
260260 name : "Worker" ,
261- makeCloudConfig : func () (* cloudinit.CloudConfig , error ) {
261+ makeCloudConfig : func (scheme string ) (* cloudinit.CloudConfig , error ) {
262262 return cloudinit .NewJoinWorker (& cloudinit.WorkerInput {
263263 KubernetesVersion : "v1.25.0" ,
264264 Token : strings .Repeat ("a" , 32 ),
265- SnapstoreProxyScheme : "https" ,
265+ SnapstoreProxyScheme : scheme ,
266266 SnapstoreProxyDomain : "snapstore.domain.com" ,
267267 SnapstoreProxyId : "ID123456789" ,
268268 })
@@ -271,10 +271,22 @@ func TestCloudConfigInput(t *testing.T) {
271271 } {
272272 t .Run (tc .name , func (t * testing.T ) {
273273 g := NewWithT (t )
274- c , err := tc .makeCloudConfig ()
275- g .Expect (err ).NotTo (HaveOccurred ())
276274
277- g .Expect (c .RunCommands ).To (ContainElement (`/capi-scripts/00-configure-snapstore-proxy.sh "https" "snapstore.domain.com" "ID123456789"` ))
275+ for _ , withScheme := range []string {"" , "http" , "https" } {
276+ t .Run (fmt .Sprintf ("withScheme=%q" , withScheme ), func (t * testing.T ) {
277+ c , err := tc .makeCloudConfig (withScheme )
278+ g .Expect (err ).NotTo (HaveOccurred ())
279+
280+ // if scheme is unspecified, default to http
281+ var expectedScheme string
282+ if withScheme == "" {
283+ expectedScheme = "http"
284+ } else {
285+ expectedScheme = withScheme
286+ }
287+ g .Expect (c .RunCommands ).To (ContainElement (fmt .Sprintf (`/capi-scripts/00-configure-snapstore-proxy.sh %q "snapstore.domain.com" "ID123456789"` , expectedScheme )))
288+ })
289+ }
278290 })
279291 }
280292 })
0 commit comments