@@ -228,38 +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 : scheme ,
240241 SnapstoreProxyDomain : "snapstore.domain.com" ,
241242 SnapstoreProxyId : "ID123456789" ,
242243 })
243244 },
244245 },
245246 {
246247 name : "ControlPlaneJoin" ,
247- makeCloudConfig : func () (* cloudinit.CloudConfig , error ) {
248+ makeCloudConfig : func (scheme string ) (* cloudinit.CloudConfig , error ) {
248249 return cloudinit .NewJoinControlPlane (& cloudinit.ControlPlaneJoinInput {
249250 KubernetesVersion : "v1.25.0" ,
250251 Token : strings .Repeat ("a" , 32 ),
251252 TokenTTL : 100 ,
253+ SnapstoreProxyScheme : scheme ,
252254 SnapstoreProxyDomain : "snapstore.domain.com" ,
253255 SnapstoreProxyId : "ID123456789" ,
254256 })
255257 },
256258 },
257259 {
258260 name : "Worker" ,
259- makeCloudConfig : func () (* cloudinit.CloudConfig , error ) {
261+ makeCloudConfig : func (scheme string ) (* cloudinit.CloudConfig , error ) {
260262 return cloudinit .NewJoinWorker (& cloudinit.WorkerInput {
261263 KubernetesVersion : "v1.25.0" ,
262264 Token : strings .Repeat ("a" , 32 ),
265+ SnapstoreProxyScheme : scheme ,
263266 SnapstoreProxyDomain : "snapstore.domain.com" ,
264267 SnapstoreProxyId : "ID123456789" ,
265268 })
@@ -268,10 +271,22 @@ func TestCloudConfigInput(t *testing.T) {
268271 } {
269272 t .Run (tc .name , func (t * testing.T ) {
270273 g := NewWithT (t )
271- c , err := tc .makeCloudConfig ()
272- g .Expect (err ).NotTo (HaveOccurred ())
273274
274- g .Expect (c .RunCommands ).To (ContainElement (`/capi-scripts/00-configure-snapstore-proxy.sh "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+ }
275290 })
276291 }
277292 })
0 commit comments