Skip to content

Commit

Permalink
🌱 Add alias to GenericProviderReconciler type
Browse files Browse the repository at this point in the history
  • Loading branch information
dmvolod committed Feb 13, 2025
1 parent 6b72fcd commit e6d708e
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 37 deletions.
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
7 changes: 5 additions & 2 deletions 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"
ConfigMapVersionLabelName = "provider.cluster.x-k8s.io/version"
ProviderFinalizer = "provider.cluster.x-k8s.io"

ConfigMapVersionLabel = "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"
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.ConfigMapVersionLabel: provider.GetSpec().Version,
operatorv1.ConfigMapTypeLabel: provider.GetType(),
operatorv1.ConfigMapNameLabel: provider.GetName(),
operatorManagedLabel: "true",
}

if provider.GetSpec().FetchConfig != nil && provider.GetSpec().FetchConfig.OCI != "" {
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/phases.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,10 @@ func (p *phaseReconciler) configmapRepository(ctx context.Context, labelSelector
errMsg := "from the Name"

if cm.Labels != nil {
ver, ok := cm.Labels[operatorv1.ConfigMapVersionLabelName]
ver, ok := cm.Labels[operatorv1.ConfigMapVersionLabel]
if ok {
version = ver
errMsg = "from the Label " + operatorv1.ConfigMapVersionLabelName
errMsg = "from the Label " + operatorv1.ConfigMapVersionLabel
}
}

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.ConfigMapVersionLabel: 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

0 comments on commit e6d708e

Please sign in to comment.