Skip to content

🌱 Add alias to GenericProviderReconciler type #725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
run:
timeout: 5m
go: "1.23"
skip-files:
- "zz_generated.*\\.go$"
allow-parallel-runners: true

linters:
Expand Down Expand Up @@ -145,6 +143,8 @@ issues:
# supported will be caught by the default case in the switches.
- "missing cases in switch of type v1.PlatformType: (\\.*)"
exclude-use-default: false
exclude-files:
- "zz_generated.*\\.go$"
exclude-rules:
- linters:
- staticcheck
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ GOTESTSUM_VER := v1.11.0
GOTESTSUM_BIN := gotestsum
GOTESTSUM := $(TOOLS_BIN_DIR)/$(GOTESTSUM_BIN)-$(GOTESTSUM_VER)

GINKGO_VER := v2.20.1
GINKGO_VER := v2.22.2
GINKGO_BIN := ginkgo
GINKGO := $(TOOLS_BIN_DIR)/$(GINKGO_BIN)-$(GINKGO_VER)

Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha2/conditions_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ const (
// IncorrectVersionFormatReason documents that the provider version is in the incorrect format.
IncorrectVersionFormatReason = "IncorrectVersionFormat"

// IncorrectCoreProviderNameReason documents that the provider name is incorrect.
// IncorrectCoreProviderNameReason documents that the Core provider name is incorrect.
IncorrectCoreProviderNameReason = "IncorrectCoreProviderNameReason"

// EmptyVersionReason documents that the provider version is in the incorrect format.
EmptyVersionReason = "EmptyVersionReason"

// FetchConfigValidationError documents that the FetchConfig is configured incorrectly.
// FetchConfigValidationErrorReason documents that the FetchConfig is configured incorrectly.
FetchConfigValidationErrorReason = "FetchConfigValidationError"

// UnknownProviderReason documents that the provider name is not the name of a known provider.
Expand Down
5 changes: 4 additions & 1 deletion api/v1alpha2/provider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ import (
)

const (
ProviderFinalizer = "provider.cluster.x-k8s.io"
ProviderFinalizer = "provider.cluster.x-k8s.io"

ConfigMapVersionLabelName = "provider.cluster.x-k8s.io/version"
ConfigMapTypeLabel = "provider.cluster.x-k8s.io/type"
ConfigMapNameLabel = "provider.cluster.x-k8s.io/name"

CompressedAnnotation = "provider.cluster.x-k8s.io/compressed"

Expand Down
4 changes: 2 additions & 2 deletions cmd/plugin/cmd/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"sigs.k8s.io/cluster-api-operator/util"
)

func TestCheckCAPIOpearatorAvailability(t *testing.T) {
func TestCheckCAPIOperatorAvailability(t *testing.T) {
tests := []struct {
name string
want bool
Expand Down Expand Up @@ -425,7 +425,7 @@ func getGenericProvider(ctx context.Context, client ctrlclient.Client, providerK
}

return provider, nil
case "RuntimExtensionProvider":
case "RuntimeExtensionProvider":
provider := &operatorv1.RuntimeExtensionProvider{}
if err := client.Get(ctx, types.NamespacedName{Name: providerName, Namespace: providerNamespace}, provider); err != nil {
return nil, err
Expand Down
21 changes: 21 additions & 0 deletions controller/alias.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2025 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package controller

import providercontroller "sigs.k8s.io/cluster-api-operator/internal/controller"

type GenericProviderReconciler = providercontroller.GenericProviderReconciler
11 changes: 4 additions & 7 deletions internal/controller/manifests_downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ import (
)

const (
configMapVersionLabel = "provider.cluster.x-k8s.io/version"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the benefit of moving these to API package? AFAICT, they are used in internal package only

Copy link
Member Author

@dmvolod dmvolod Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is good question, but according to test data below, it seems to possible to have any ConfigMap name with following labels to be configured in air-gap mode, to avoid assigning name equals to provider version.

This would be an option for configuration. Seems to need to add this option to documentation.
What do you think about it?

provider.cluster.x-k8s.io/name: cluster-api
provider.cluster.x-k8s.io/type: core
provider.cluster.x-k8s.io/version: v1.7.7

configMapTypeLabel = "provider.cluster.x-k8s.io/type"
configMapNameLabel = "provider.cluster.x-k8s.io/name"
configMapSourceLabel = "provider.cluster.x-k8s.io/source"
configMapSourceAnnotation = "provider.cluster.x-k8s.io/source"
operatorManagedLabel = "managed-by.operator.cluster.x-k8s.io"
Expand Down Expand Up @@ -292,10 +289,10 @@ func providerLabelSelector(provider operatorv1.GenericProvider) *metav1.LabelSel
// ProviderLabels returns default set of labels that identify a config map with downloaded manifests.
func ProviderLabels(provider operatorv1.GenericProvider) map[string]string {
labels := map[string]string{
configMapVersionLabel: provider.GetSpec().Version,
configMapTypeLabel: provider.GetType(),
configMapNameLabel: provider.GetName(),
operatorManagedLabel: "true",
operatorv1.ConfigMapVersionLabelName: provider.GetSpec().Version,
operatorv1.ConfigMapTypeLabel: provider.GetType(),
operatorv1.ConfigMapNameLabel: provider.GetName(),
operatorManagedLabel: "true",
}

if provider.GetSpec().FetchConfig != nil && provider.GetSpec().FetchConfig.OCI != "" {
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/phases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,10 @@ releaseSeries:
Name: testCurrentVersion,
Namespace: "default",
Labels: map[string]string{
configMapVersionLabel: testCurrentVersion,
configMapTypeLabel: core.GetType(),
configMapNameLabel: core.GetName(),
operatorManagedLabel: "true",
operatorv1.ConfigMapVersionLabelName: testCurrentVersion,
operatorv1.ConfigMapTypeLabel: core.GetType(),
operatorv1.ConfigMapNameLabel: core.GetName(),
operatorManagedLabel: "true",
},
},
Data: map[string]string{"metadata": metadata, "components": ""},
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/air_gapped_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ var _ = Describe("Install Core Provider in an air-gapped environment", func() {
HaveStatusCondition(&coreProvider.Status.Conditions, operatorv1.ProviderInstalledCondition),
), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for status.IntalledVersion to be set")
By("Waiting for status.InstalledVersion to be set")
WaitFor(ctx, For(coreProvider).In(bootstrapCluster).ToSatisfy(func() bool {
return ptr.Equal(coreProvider.Status.InstalledVersion, ptr.To(coreProvider.Spec.Version))
}), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
Expand All @@ -129,7 +129,7 @@ var _ = Describe("Install Core Provider in an air-gapped environment", func() {
HaveStatusCondition(&coreProvider.Status.Conditions, operatorv1.ProviderInstalledCondition),
), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for status.IntalledVersion to be set")
By("Waiting for status.InstalledVersion to be set")
WaitFor(ctx, For(coreProvider).In(bootstrapCluster).ToSatisfy(func() bool {
return ptr.Equal(coreProvider.Status.InstalledVersion, ptr.To(coreProvider.Spec.Version))
}), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/compressed_manifests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ var _ = Describe("Create and delete a provider with manifests that don't fit the
HaveStatusCondition(&coreProvider.Status.Conditions, operatorv1.ProviderInstalledCondition),
), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for status.IntalledVersion to be set")
By("Waiting for status.InstalledVersion to be set")
WaitFor(ctx, For(coreProvider).In(bootstrapCluster).ToSatisfy(func() bool {
return ptr.Equal(coreProvider.Status.InstalledVersion, ptr.To(coreProvider.Spec.Version))
}), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
Expand All @@ -94,7 +94,7 @@ var _ = Describe("Create and delete a provider with manifests that don't fit the
HaveStatusCondition(&infraProvider.Status.Conditions, operatorv1.ProviderInstalledCondition),
), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for status.IntalledVersion to be set")
By("Waiting for status.InstalledVersion to be set")
WaitFor(ctx, For(infraProvider).In(bootstrapCluster).ToSatisfy(func() bool {
return ptr.Equal(infraProvider.Status.InstalledVersion, ptr.To(infraProvider.Spec.Version))
}), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
Expand Down Expand Up @@ -168,7 +168,7 @@ var _ = Describe("Create and delete a provider with manifests that don't fit the
HaveStatusCondition(&infraProvider.Status.Conditions, operatorv1.ProviderInstalledCondition)),
e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for status.IntalledVersion to be set")
By("Waiting for status.InstalledVersion to be set")
WaitFor(ctx, For(infraProvider).In(bootstrapCluster).ToSatisfy(func() bool {
return ptr.Equal(infraProvider.Status.InstalledVersion, ptr.To(infraProvider.Spec.Version))
}), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
Expand Down
20 changes: 10 additions & 10 deletions test/e2e/minimal_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ metadata:
HaveStatusCondition(&coreProvider.Status.Conditions, operatorv1.ProviderInstalledCondition)),
e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for status.IntalledVersion to be set")
By("Waiting for status.InstalledVersion to be set")
WaitFor(ctx, For(coreProvider).In(bootstrapCluster).ToSatisfy(func() bool {
return ptr.Equal(coreProvider.Status.InstalledVersion, &coreProvider.Spec.Version)
}), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
Expand Down Expand Up @@ -154,7 +154,7 @@ metadata:
HaveStatusCondition(&bootstrapProvider.Status.Conditions, operatorv1.ProviderInstalledCondition)),
e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for status.IntalledVersion to be set")
By("Waiting for status.InstalledVersion to be set")
WaitFor(ctx, For(bootstrapProvider).In(bootstrapCluster).ToSatisfy(func() bool {
return ptr.Equal(bootstrapProvider.Status.InstalledVersion, &bootstrapProvider.Spec.Version)
}), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
Expand Down Expand Up @@ -189,7 +189,7 @@ metadata:
HaveStatusCondition(&cpProvider.Status.Conditions, operatorv1.ProviderInstalledCondition)),
e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for status.IntalledVersion to be set")
By("Waiting for status.InstalledVersion to be set")
WaitFor(ctx, For(cpProvider).In(bootstrapCluster).ToSatisfy(func() bool {
return ptr.Equal(cpProvider.Status.InstalledVersion, &cpProvider.Spec.Version)
}), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
Expand Down Expand Up @@ -224,7 +224,7 @@ metadata:
HaveStatusCondition(&infraProvider.Status.Conditions, operatorv1.ProviderInstalledCondition)),
e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for status.IntalledVersion to be set")
By("Waiting for status.InstalledVersion to be set")
WaitFor(ctx, For(infraProvider).In(bootstrapCluster).ToSatisfy(func() bool {
return ptr.Equal(infraProvider.Status.InstalledVersion, &infraProvider.Spec.Version)
}), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
Expand Down Expand Up @@ -266,7 +266,7 @@ metadata:
HaveStatusCondition(&addonProvider.Status.Conditions, operatorv1.ProviderInstalledCondition)),
e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for status.IntalledVersion to be set")
By("Waiting for status.InstalledVersion to be set")
WaitFor(ctx, For(addonProvider).In(bootstrapCluster).ToSatisfy(func() bool {
return ptr.Equal(addonProvider.Status.InstalledVersion, &addonProvider.Spec.Version)
}), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
Expand Down Expand Up @@ -310,7 +310,7 @@ metadata:
HaveStatusCondition(&ipamProvider.Status.Conditions, operatorv1.ProviderInstalledCondition)),
e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for status.IntalledVersion to be set")
By("Waiting for status.InstalledVersion to be set")
WaitFor(ctx, For(ipamProvider).In(bootstrapCluster).ToSatisfy(func() bool {
return ptr.Equal(ipamProvider.Status.InstalledVersion, &ipamProvider.Spec.Version)
}), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
Expand Down Expand Up @@ -426,7 +426,7 @@ metadata:
HaveStatusCondition(&provider.Status.Conditions, operatorv1.ProviderInstalledCondition)),
e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for status.IntalledVersion to be set")
By("Waiting for status.InstalledVersion to be set")
WaitFor(ctx, For(provider).In(bootstrapCluster).ToSatisfy(func() bool {
return ptr.Equal(provider.Status.InstalledVersion, &provider.Spec.Version)
}), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
Expand Down Expand Up @@ -513,7 +513,7 @@ metadata:
HaveStatusCondition(&provider.Status.Conditions, operatorv1.ProviderInstalledCondition)),
e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for status.IntalledVersion to be set")
By("Waiting for status.InstalledVersion to be set")
WaitFor(ctx, For(provider).In(bootstrapCluster).ToSatisfy(func() bool {
return ptr.Equal(provider.Status.InstalledVersion, &provider.Spec.Version)
}), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
Expand Down Expand Up @@ -600,7 +600,7 @@ metadata:
HaveStatusCondition(&provider.Status.Conditions, operatorv1.ProviderInstalledCondition)),
e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for status.IntalledVersion to be set")
By("Waiting for status.InstalledVersion to be set")
WaitFor(ctx, For(provider).In(bootstrapCluster).ToSatisfy(func() bool {
return ptr.Equal(provider.Status.InstalledVersion, &provider.Spec.Version)
}), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
Expand All @@ -609,7 +609,7 @@ metadata:
provider.Spec.Version = "v0.0.2"
Expect(bootstrapCluster.Update(ctx, provider)).To(Succeed())

By("Waiting for status.IntalledVersion to be set")
By("Waiting for status.InstalledVersion to be set")
WaitFor(ctx, For(provider).In(bootstrapCluster).ToSatisfy(func() bool {
return ptr.Equal(provider.Status.InstalledVersion, &provider.Spec.Version)
}), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
Expand Down
Loading