@@ -57,12 +57,12 @@ const (
57
57
// helps to iterate through provider reconciliation phases.
58
58
type PhaseReconciler [P generic.Provider , G generic.Group [P ]] struct {
59
59
ctrlClient client.Client
60
- repo repository.Repository
61
- contract string
62
- options repository.ComponentsOptions
63
- providerConfig configclient.Provider
64
- configClient configclient.Client
65
- components repository.Components
60
+ Repo repository.Repository
61
+ Contract string
62
+ Options repository.ComponentsOptions
63
+ ProviderConfig configclient.Provider
64
+ ConfigClient configclient.Client
65
+ Components repository.Components
66
66
}
67
67
68
68
type Phase [P generic.Provider ] struct {
@@ -180,14 +180,14 @@ func (p *PhaseReconciler[P, G]) InitializePhaseReconciler(ctx context.Context, p
180
180
}
181
181
182
182
// Load provider's secret and config url.
183
- p .configClient , err = configclient .New (ctx , "" , configclient .InjectReader (reader ))
183
+ p .ConfigClient , err = configclient .New (ctx , "" , configclient .InjectReader (reader ))
184
184
if err != nil {
185
185
return reconcile.Result {}, wrapPhaseError (err , "failed to load the secret reader" , operatorv1 .ProviderInstalledCondition )
186
186
}
187
187
188
188
// Get returns the configuration for the provider with a given name/type.
189
189
// This is done using clusterctl internal API types.
190
- p .providerConfig , err = p .configClient .Providers ().Get (phase .GetProvider ().GetName (), phase .ClusterctlProviderType ())
190
+ p .ProviderConfig , err = p .ConfigClient .Providers ().Get (phase .GetProvider ().GetName (), phase .ClusterctlProviderType ())
191
191
if err != nil {
192
192
return reconcile.Result {}, wrapPhaseError (err , operatorv1 .UnknownProviderReason , operatorv1 .ProviderInstalledCondition )
193
193
}
@@ -219,14 +219,14 @@ func (p *PhaseReconciler[P, G]) Load(ctx context.Context, phase G) (reconcile.Re
219
219
return reconcile.Result {}, wrapPhaseError (err , "failed to load additional manifests" , operatorv1 .ProviderInstalledCondition )
220
220
}
221
221
222
- p .repo , err = configmapRepository (ctx , phase .GetClient (), labelSelector , phase .GetProvider ().GetNamespace (), additionalManifests )
222
+ p .Repo , err = configmapRepository (ctx , phase .GetClient (), labelSelector , phase .GetProvider ().GetNamespace (), additionalManifests )
223
223
if err != nil {
224
224
return reconcile.Result {}, wrapPhaseError (err , "failed to load the repository" , operatorv1 .ProviderInstalledCondition )
225
225
}
226
226
227
227
if spec .Version == "" {
228
228
// User didn't set the version, so we need to find the latest one from the matching config maps.
229
- repoVersions , err := p .repo .GetVersions (ctx )
229
+ repoVersions , err := p .Repo .GetVersions (ctx )
230
230
if err != nil {
231
231
return reconcile.Result {}, wrapPhaseError (err , fmt .Sprintf ("failed to get a list of available versions for provider %q" , phase .GetProvider ().GetName ()), operatorv1 .ProviderInstalledCondition )
232
232
}
@@ -241,7 +241,7 @@ func (p *PhaseReconciler[P, G]) Load(ctx context.Context, phase G) (reconcile.Re
241
241
}
242
242
243
243
// Store some provider specific inputs for passing it to clusterctl library
244
- p .options = repository.ComponentsOptions {
244
+ p .Options = repository.ComponentsOptions {
245
245
TargetNamespace : phase .GetProvider ().GetNamespace (),
246
246
SkipTemplateProcess : false ,
247
247
Version : spec .Version ,
@@ -422,7 +422,7 @@ func getComponentsData(cm corev1.ConfigMap) (string, error) {
422
422
func (p * PhaseReconciler [P , G ]) validateRepoCAPIVersion (ctx context.Context , phase G ) error {
423
423
name := phase .GetProvider ().GetName ()
424
424
425
- file , err := p .repo .GetFile (ctx , p .options .Version , metadataFile )
425
+ file , err := p .Repo .GetFile (ctx , p .Options .Version , metadataFile )
426
426
if err != nil {
427
427
return fmt .Errorf ("failed to read %q from the repository for provider %q: %w" , metadataFile , name , err )
428
428
}
@@ -436,21 +436,21 @@ func (p *PhaseReconciler[P, G]) validateRepoCAPIVersion(ctx context.Context, pha
436
436
}
437
437
438
438
// Gets the contract for the target release.
439
- targetVersion , err := versionutil .ParseSemantic (p .options .Version )
439
+ targetVersion , err := versionutil .ParseSemantic (p .Options .Version )
440
440
if err != nil {
441
441
return fmt .Errorf ("failed to parse current version for the %s provider: %w" , name , err )
442
442
}
443
443
444
444
releaseSeries := latestMetadata .GetReleaseSeriesForVersion (targetVersion )
445
445
if releaseSeries == nil {
446
- return fmt .Errorf ("invalid provider metadata: version %s for the provider %s does not match any release series" , p .options .Version , name )
446
+ return fmt .Errorf ("invalid provider metadata: version %s for the provider %s does not match any release series" , p .Options .Version , name )
447
447
}
448
448
449
449
if releaseSeries .Contract != "v1alpha4" && releaseSeries .Contract != "v1beta1" {
450
450
return fmt .Errorf (capiVersionIncompatibilityMessage , clusterv1 .GroupVersion .Version , releaseSeries .Contract , name )
451
451
}
452
452
453
- p .contract = releaseSeries .Contract
453
+ p .Contract = releaseSeries .Contract
454
454
455
455
return nil
456
456
}
@@ -461,35 +461,35 @@ func (p *PhaseReconciler[P, G]) Fetch(ctx context.Context, phase G) (reconcile.R
461
461
log .Info ("Fetching provider" )
462
462
463
463
// Fetch the provider components yaml file from the provided repository GitHub/GitLab/ConfigMap.
464
- componentsFile , err := p .repo .GetFile (ctx , p .options .Version , p .repo .ComponentsPath ())
464
+ componentsFile , err := p .Repo .GetFile (ctx , p .Options .Version , p .Repo .ComponentsPath ())
465
465
if err != nil {
466
- err = fmt .Errorf ("failed to read %q from provider's repository %q: %w" , p .repo .ComponentsPath (), p .providerConfig .ManifestLabel (), err )
466
+ err = fmt .Errorf ("failed to read %q from provider's repository %q: %w" , p .Repo .ComponentsPath (), p .ProviderConfig .ManifestLabel (), err )
467
467
468
468
return reconcile.Result {}, wrapPhaseError (err , operatorv1 .ComponentsFetchErrorReason , operatorv1 .ProviderInstalledCondition )
469
469
}
470
470
471
471
// Generate a set of new objects using the clusterctl library. NewComponents() will do the yaml processing,
472
472
// like ensure all the provider components are in proper namespace, replace variables, etc. See the clusterctl
473
473
// documentation for more details.
474
- p .components , err = repository .NewComponents (repository.ComponentsInput {
475
- Provider : p .providerConfig ,
476
- ConfigClient : p .configClient ,
474
+ p .Components , err = repository .NewComponents (repository.ComponentsInput {
475
+ Provider : p .ProviderConfig ,
476
+ ConfigClient : p .ConfigClient ,
477
477
Processor : yamlprocessor .NewSimpleProcessor (),
478
478
RawYaml : componentsFile ,
479
- Options : p .options ,
479
+ Options : p .Options ,
480
480
})
481
481
if err != nil {
482
482
return reconcile.Result {}, wrapPhaseError (err , operatorv1 .ComponentsFetchErrorReason , operatorv1 .ProviderInstalledCondition )
483
483
}
484
484
485
485
// ProviderSpec provides fields for customizing the provider deployment options.
486
486
// We can use clusterctl library to apply this customizations.
487
- if err := repository .AlterComponents (p .components , customizeObjectsFn (phase .GetProvider ())); err != nil {
487
+ if err := repository .AlterComponents (p .Components , customizeObjectsFn (phase .GetProvider ())); err != nil {
488
488
return reconcile.Result {}, wrapPhaseError (err , operatorv1 .ComponentsFetchErrorReason , operatorv1 .ProviderInstalledCondition )
489
489
}
490
490
491
491
// Apply patches to the provider components if specified.
492
- if err := repository .AlterComponents (p .components , applyPatches (ctx , phase .GetProvider ())); err != nil {
492
+ if err := repository .AlterComponents (p .Components , applyPatches (ctx , phase .GetProvider ())); err != nil {
493
493
return reconcile.Result {}, wrapPhaseError (err , operatorv1 .ComponentsFetchErrorReason , operatorv1 .ProviderInstalledCondition )
494
494
}
495
495
@@ -541,7 +541,7 @@ func (p *PhaseReconciler[P, G]) Install(ctx context.Context, phase G) (reconcile
541
541
542
542
log .Info ("Installing provider" )
543
543
544
- if err := clusterClient .ProviderComponents ().Create (ctx , p .components .Objs ()); err != nil {
544
+ if err := clusterClient .ProviderComponents ().Create (ctx , p .Components .Objs ()); err != nil {
545
545
reason := "Install failed"
546
546
if wait .Interrupted (err ) {
547
547
reason = "Timed out waiting for deployment to become ready"
@@ -558,8 +558,8 @@ func (p *PhaseReconciler[P, G]) Install(ctx context.Context, phase G) (reconcile
558
558
559
559
func (p * PhaseReconciler [P , G ]) ReportStatus (_ context.Context , phase G ) (reconcile.Result , error ) {
560
560
status := phase .GetProvider ().GetStatus ()
561
- status .Contract = & p .contract
562
- installedVersion := p .components .Version ()
561
+ status .Contract = & p .Contract
562
+ installedVersion := p .Components .Version ()
563
563
status .InstalledVersion = & installedVersion
564
564
phase .GetProvider ().SetStatus (status )
565
565
@@ -589,9 +589,9 @@ func (p *PhaseReconciler[P, G]) Delete(ctx context.Context, phase G) (reconcile.
589
589
}
590
590
591
591
func (p * PhaseReconciler [P , G ]) repositoryProxy (ctx context.Context , provider configclient.Provider , configClient configclient.Client , options ... repository.Option ) (repository.Client , error ) {
592
- injectRepo := p .repo
592
+ injectRepo := p .Repo
593
593
594
- if ! provider .SameAs (p .providerConfig ) {
594
+ if ! provider .SameAs (p .ProviderConfig ) {
595
595
genericProvider , err := GetGenericProvider (ctx , p .ctrlClient , provider )
596
596
if err != nil {
597
597
return nil , wrapPhaseError (err , "unable to find generic provider for configclient " + string (provider .Type ())+ ": " + provider .Name (), operatorv1 .ProviderUpgradedCondition )
@@ -619,7 +619,7 @@ func (p *PhaseReconciler[P, G]) repositoryProxy(ctx context.Context, provider co
619
619
return nil , err
620
620
}
621
621
622
- return proxy.RepositoryProxy {Client : cl , RepositoryComponents : p .components }, nil
622
+ return proxy.RepositoryProxy {Client : cl , RepositoryComponents : p .Components }, nil
623
623
}
624
624
625
625
// GetGenericProvider returns the first of generic providers matching the type and the name from the configclient.Provider.
@@ -645,7 +645,7 @@ func GetGenericProvider(ctx context.Context, cl client.Client, provider configcl
645
645
646
646
// newClusterClient returns a clusterctl client for interacting with management cluster.
647
647
func newClusterClient [P generic.Provider , G generic.Group [P ]](p * PhaseReconciler [P , G ], phase G ) cluster.Client {
648
- return cluster .New (cluster.Kubeconfig {}, p .configClient , cluster .InjectProxy (& proxy.ControllerProxy {
648
+ return cluster .New (cluster.Kubeconfig {}, p .ConfigClient , cluster .InjectProxy (& proxy.ControllerProxy {
649
649
CtrlClient : proxy.ClientProxy {
650
650
Client : phase .GetClient (),
651
651
ListProviders : listProviders ,
0 commit comments