@@ -68,10 +68,10 @@ func (c *ClusterAPI) Dependencies() []asset.Asset {
6868 }
6969}
7070
71- // Generate generates Cluster API machine manifests.
71+ // GenerateWithContext generates Cluster API machine manifests.
7272//
7373//nolint:gocyclo
74- func (c * ClusterAPI ) Generate ( dependencies asset.Parents ) error {
74+ func (c * ClusterAPI ) GenerateWithContext ( ctx context. Context , dependencies asset.Parents ) error {
7575 installConfig := & installconfig.InstallConfig {}
7676 clusterID := & installconfig.ClusterID {}
7777 rhcosImage := new (rhcos.Image )
@@ -87,7 +87,6 @@ func (c *ClusterAPI) Generate(dependencies asset.Parents) error {
8787 var err error
8888 ic := installConfig .Config
8989 pool := * ic .ControlPlane
90- ctx := context .TODO ()
9190
9291 switch ic .Platform .Name () {
9392 case awstypes .Name :
@@ -234,7 +233,7 @@ func (c *ClusterAPI) Generate(dependencies asset.Parents) error {
234233 mpool .Zones = []string {"" }
235234 }
236235 if len (mpool .Zones ) == 0 {
237- azs , err := client .GetAvailabilityZones (context . TODO () , ic .Platform .Azure .Region , mpool .InstanceType )
236+ azs , err := client .GetAvailabilityZones (ctx , ic .Platform .Azure .Region , mpool .InstanceType )
238237 if err != nil {
239238 return fmt .Errorf ("failed to fetch availability zones: %w" , err )
240239 }
@@ -245,10 +244,10 @@ func (c *ClusterAPI) Generate(dependencies asset.Parents) error {
245244 mpool .Zones = []string {"" }
246245 }
247246 }
248- // client.GetControlPlaneSubnet(context.TODO() , ic.Platform.Azure.ResourceGroupName, ic.Platform.Azure.VirtualNetwork, )
247+ // client.GetControlPlaneSubnet(ctx , ic.Platform.Azure.ResourceGroupName, ic.Platform.Azure.VirtualNetwork, )
249248
250249 if mpool .OSImage .Publisher != "" {
251- img , ierr := client .GetMarketplaceImage (context . TODO () , ic .Platform .Azure .Region , mpool .OSImage .Publisher , mpool .OSImage .Offer , mpool .OSImage .SKU , mpool .OSImage .Version )
250+ img , ierr := client .GetMarketplaceImage (ctx , ic .Platform .Azure .Region , mpool .OSImage .Publisher , mpool .OSImage .Offer , mpool .OSImage .SKU , mpool .OSImage .Version )
252251 if ierr != nil {
253252 return fmt .Errorf ("failed to fetch marketplace image: %w" , ierr )
254253 }
@@ -262,7 +261,7 @@ func (c *ClusterAPI) Generate(dependencies asset.Parents) error {
262261 pool .Platform .Azure = & mpool
263262 subnet := ic .Azure .ControlPlaneSubnet
264263
265- capabilities , err := client .GetVMCapabilities (context . TODO () , mpool .InstanceType , installConfig .Config .Platform .Azure .Region )
264+ capabilities , err := client .GetVMCapabilities (ctx , mpool .InstanceType , installConfig .Config .Platform .Azure .Region )
266265 if err != nil {
267266 return err
268267 }
@@ -337,7 +336,7 @@ func (c *ClusterAPI) Generate(dependencies asset.Parents) error {
337336 // that the installer's install-config has been provided with bogus values.
338337
339338 // Timeout context for Lookup
340- ctx , cancel := context .WithTimeout (context . TODO () , 30 * time .Second )
339+ ctx , cancel := context .WithTimeout (ctx , 30 * time .Second )
341340 defer cancel ()
342341
343342 _ , err := resolver .LookupHost (ctx , v .Server )
@@ -349,7 +348,7 @@ func (c *ClusterAPI) Generate(dependencies asset.Parents) error {
349348 // Timeout context for Networks
350349 // vCenter APIs can be unreliable in performance, extended this context
351350 // timeout to 60 seconds.
352- ctx , cancel = context .WithTimeout (context . TODO () , 60 * time .Second )
351+ ctx , cancel = context .WithTimeout (ctx , 60 * time .Second )
353352 defer cancel ()
354353
355354 err = installConfig .VSphere .Networks (ctx , v , platform .FailureDomains )
@@ -521,3 +520,9 @@ func (c *ClusterAPI) Load(f asset.FileFetcher) (bool, error) {
521520 asset .SortManifestFiles (c .FileList )
522521 return len (c .FileList ) > 0 , nil
523522}
523+
524+ // Generate is implemented so this asset maintains compatibility with the Asset
525+ // interface. It should never be called.
526+ func (* ClusterAPI ) Generate (_ asset.Parents ) (err error ) {
527+ panic ("ClusterAPI.Generate was called instead of ClusterAPI.GenerateWithContext" )
528+ }
0 commit comments