Skip to content

Commit 296aeaa

Browse files
committed
support installing providers with custom names in air-gapped envs
Currently we do not support installation of providers with custom names for air-gapped environments. It happens because we inject new names in the list of known providers only for those with URL specified, ignoring config maps. This PR fixes it, so we support both URL and ConfigMap installations with custom names.
1 parent 5ccd1ab commit 296aeaa

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

internal/controller/manifests_downloader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ const (
5050
func (p *phaseReconciler) downloadManifests(ctx context.Context) (reconcile.Result, error) {
5151
log := ctrl.LoggerFrom(ctx)
5252

53-
log.Info("Downloading provider manifests")
54-
5553
// Return immediately if a custom config map is used instead of a url.
5654
if p.provider.GetSpec().FetchConfig != nil && p.provider.GetSpec().FetchConfig.Selector != nil {
5755
log.V(5).Info("Custom config map is used, skip downloading provider manifests")
@@ -75,6 +73,8 @@ func (p *phaseReconciler) downloadManifests(ctx context.Context) (reconcile.Resu
7573
return reconcile.Result{}, nil
7674
}
7775

76+
log.Info("Downloading provider manifests")
77+
7878
repo, err := repositoryFactory(p.providerConfig, p.configClient.Variables())
7979
if err != nil {
8080
err = fmt.Errorf("failed to create repo from provider url for provider %q: %w", p.provider.GetName(), err)

internal/controller/phases.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,23 @@ func (p *phaseReconciler) secretReader(ctx context.Context) (configclient.Reader
218218
}
219219

220220
// If provided store fetch config url in memory reader.
221-
if p.provider.GetSpec().FetchConfig != nil && p.provider.GetSpec().FetchConfig.URL != "" {
222-
log.Info("Custom fetch configuration url was provided")
223-
return mr.AddProvider(p.provider.GetName(), util.ClusterctlProviderType(p.provider), p.provider.GetSpec().FetchConfig.URL)
221+
if p.provider.GetSpec().FetchConfig != nil {
222+
if p.provider.GetSpec().FetchConfig.URL != "" {
223+
log.Info("Custom fetch configuration url was provided")
224+
return mr.AddProvider(p.provider.GetName(), util.ClusterctlProviderType(p.provider), p.provider.GetSpec().FetchConfig.URL)
225+
}
226+
227+
if p.provider.GetSpec().FetchConfig.Selector != nil {
228+
log.Info("Custom fetch configuration config map was provided")
229+
230+
// To register a new provider from the config map, we need to specify a URL with a valid
231+
// format. However, since we're using data from a local config map, URLs are not needed.
232+
// As a workaround, we add a fake but well-formatted URL.
233+
234+
fakeURL := "https://example.com/my-provider"
235+
236+
return mr.AddProvider(p.provider.GetName(), util.ClusterctlProviderType(p.provider), fakeURL)
237+
}
224238
}
225239

226240
return mr, nil

test/e2e/compressed_manifests_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
)
3333

3434
const (
35-
ociInfrastructureProviderName = "oci"
35+
ociInfrastructureProviderName = "my-oci"
3636
ociInfrastructureProviderVersion = "v0.12.0"
3737
ociInfrastructureProviderDeploymentName = "capoci-controller-manager"
3838
compressedAnnotation = "provider.cluster.x-k8s.io/compressed"

0 commit comments

Comments
 (0)