@@ -61,7 +61,7 @@ type InitInput struct {
61
61
}
62
62
63
63
// Init calls clusterctl init with the list of providers defined in the local repository.
64
- func Init (_ context.Context , input InitInput ) {
64
+ func Init (ctx context.Context , input InitInput ) {
65
65
args := calculateClusterCtlInitArgs (input )
66
66
log .Logf ("clusterctl %s" , strings .Join (args , " " ))
67
67
@@ -81,10 +81,10 @@ func Init(_ context.Context, input InitInput) {
81
81
WaitProviders : true ,
82
82
}
83
83
84
- clusterctlClient , log := getClusterctlClientWithLogger (input .ClusterctlConfigPath , "clusterctl-init.log" , input .LogFolder )
84
+ clusterctlClient , log := getClusterctlClientWithLogger (ctx , input .ClusterctlConfigPath , "clusterctl-init.log" , input .LogFolder )
85
85
defer log .Close ()
86
86
87
- _ , err := clusterctlClient .Init (initOpt )
87
+ _ , err := clusterctlClient .Init (ctx , initOpt )
88
88
Expect (err ).ToNot (HaveOccurred (), "failed to run clusterctl init" )
89
89
}
90
90
@@ -209,10 +209,10 @@ func Upgrade(ctx context.Context, input UpgradeInput) {
209
209
WaitProviders : true ,
210
210
}
211
211
212
- clusterctlClient , log := getClusterctlClientWithLogger (input .ClusterctlConfigPath , "clusterctl-upgrade.log" , input .LogFolder )
212
+ clusterctlClient , log := getClusterctlClientWithLogger (ctx , input .ClusterctlConfigPath , "clusterctl-upgrade.log" , input .LogFolder )
213
213
defer log .Close ()
214
214
215
- err := clusterctlClient .ApplyUpgrade (upgradeOpt )
215
+ err := clusterctlClient .ApplyUpgrade (ctx , upgradeOpt )
216
216
Expect (err ).ToNot (HaveOccurred (), "failed to run clusterctl upgrade" )
217
217
}
218
218
@@ -224,7 +224,7 @@ type DeleteInput struct {
224
224
}
225
225
226
226
// Delete calls clusterctl delete --all.
227
- func Delete (_ context.Context , input DeleteInput ) {
227
+ func Delete (ctx context.Context , input DeleteInput ) {
228
228
log .Logf ("clusterctl delete --all" )
229
229
230
230
deleteOpts := clusterctlclient.DeleteOptions {
@@ -235,10 +235,10 @@ func Delete(_ context.Context, input DeleteInput) {
235
235
DeleteAll : true ,
236
236
}
237
237
238
- clusterctlClient , log := getClusterctlClientWithLogger (input .ClusterctlConfigPath , "clusterctl-delete.log" , input .LogFolder )
238
+ clusterctlClient , log := getClusterctlClientWithLogger (ctx , input .ClusterctlConfigPath , "clusterctl-delete.log" , input .LogFolder )
239
239
defer log .Close ()
240
240
241
- err := clusterctlClient .Delete (deleteOpts )
241
+ err := clusterctlClient .Delete (ctx , deleteOpts )
242
242
Expect (err ).ToNot (HaveOccurred (), "failed to run clusterctl upgrade" )
243
243
}
244
244
@@ -294,10 +294,10 @@ func ConfigCluster(ctx context.Context, input ConfigClusterInput) []byte {
294
294
input .ClusterctlConfigPath = outputPath
295
295
}
296
296
297
- clusterctlClient , log := getClusterctlClientWithLogger (input .ClusterctlConfigPath , fmt .Sprintf ("%s-cluster-template.yaml" , input .ClusterName ), input .LogFolder )
297
+ clusterctlClient , log := getClusterctlClientWithLogger (ctx , input .ClusterctlConfigPath , fmt .Sprintf ("%s-cluster-template.yaml" , input .ClusterName ), input .LogFolder )
298
298
defer log .Close ()
299
299
300
- template , err := clusterctlClient .GetClusterTemplate (templateOptions )
300
+ template , err := clusterctlClient .GetClusterTemplate (ctx , templateOptions )
301
301
Expect (err ).ToNot (HaveOccurred (), "Failed to run clusterctl config cluster" )
302
302
303
303
yaml , err := template .Yaml ()
@@ -403,25 +403,25 @@ func Move(ctx context.Context, input MoveInput) {
403
403
input .Namespace ,
404
404
)
405
405
406
- clusterctlClient , log := getClusterctlClientWithLogger (input .ClusterctlConfigPath , "clusterctl-move.log" , logDir )
406
+ clusterctlClient , log := getClusterctlClientWithLogger (ctx , input .ClusterctlConfigPath , "clusterctl-move.log" , logDir )
407
407
defer log .Close ()
408
408
options := clusterctlclient.MoveOptions {
409
409
FromKubeconfig : clusterctlclient.Kubeconfig {Path : input .FromKubeconfigPath , Context : "" },
410
410
ToKubeconfig : clusterctlclient.Kubeconfig {Path : input .ToKubeconfigPath , Context : "" },
411
411
Namespace : input .Namespace ,
412
412
}
413
413
414
- Expect (clusterctlClient .Move (options )).To (Succeed (), "Failed to run clusterctl move" )
414
+ Expect (clusterctlClient .Move (ctx , options )).To (Succeed (), "Failed to run clusterctl move" )
415
415
}
416
416
417
- func getClusterctlClientWithLogger (configPath , logName , logFolder string ) (clusterctlclient.Client , * logger.LogFile ) {
417
+ func getClusterctlClientWithLogger (ctx context. Context , configPath , logName , logFolder string ) (clusterctlclient.Client , * logger.LogFile ) {
418
418
log := logger .OpenLogFile (logger.OpenLogFileInput {
419
419
LogFolder : logFolder ,
420
420
Name : logName ,
421
421
})
422
422
clusterctllog .SetLogger (log .Logger ())
423
423
424
- c , err := clusterctlclient .New (configPath )
424
+ c , err := clusterctlclient .New (ctx , configPath )
425
425
Expect (err ).ToNot (HaveOccurred (), "Failed to create the clusterctl client library" )
426
426
return c , log
427
427
}
0 commit comments