Skip to content
Open
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
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ linters:
alias: utilruntime
- pkg: sigs.k8s.io/controller-runtime
alias: ctrl
- pkg: sigs.k8s.io/cluster-api/api/v1beta1
- pkg: sigs.k8s.io/cluster-api/api/core/v1beta2
alias: clusterv1
- pkg: sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3
alias: clusterctlv1
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -309,16 +309,16 @@ download-cluster-api-crd: generate-modules ## Run to download Cluster API CRDs f
DOCKER_TEMPLATES := test/e2e/data/addons-helm

.PHONY: generate-e2e-templates
generate-e2e-templates: $(KUSTOMIZE) $(addprefix generate-e2e-templates-, v1.5 main) ## Generate cluster templates for all versions
generate-e2e-templates: $(KUSTOMIZE) $(addprefix generate-e2e-templates-, v1beta1 main) ## Generate cluster templates for all versions

.PHONY: generate-e2e-templates-v1.5
generate-e2e-templates-v1.5: $(KUSTOMIZE)
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1.5/cluster-template --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1.5/cluster-template.yaml
.PHONY: generate-e2e-templates-v1beta1
generate-e2e-templates-v1beta1: $(KUSTOMIZE)
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/cluster-template --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta1/cluster-template.yaml

.PHONY: generate-e2e-templates-main
generate-e2e-templates-main: $(KUSTOMIZE) ## Generate templates for e2e tests on main branch.
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/cluster-template --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta1/cluster-template.yaml
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta1/cluster-template-upgrades --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta1/cluster-template-upgrades.yaml
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta2/cluster-template --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta2/cluster-template.yaml
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v1beta2/cluster-template-upgrades --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v1beta2/cluster-template-upgrades.yaml

.PHONY: generate-flavors
generate-flavors: $(KUSTOMIZE) ## Generate template flavors.
Expand Down
10 changes: 4 additions & 6 deletions api/v1alpha1/condition_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ limitations under the License.

package v1alpha1

import clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"

// HelmChartProxy Conditions and Reasons.
const (
// HelmReleaseProxySpecsUpToDateCondition indicates that the HelmReleaseProxy specs are up to date with the HelmChartProxy specs,
// meaning that the HelmReleaseProxies are created/updated, value template parsing succeeded, and the orphaned HelmReleaseProxies are deleted.
HelmReleaseProxySpecsUpToDateCondition clusterv1.ConditionType = "HelmReleaseProxySpecsUpToDate"
HelmReleaseProxySpecsUpToDateCondition = "HelmReleaseProxySpecsUpToDate"

// HelmReleaseProxySpecsUpdatingReason indicates that the HelmReleaseProxy entity is not yet updated by the corresponding controller.
HelmReleaseProxySpecsUpdatingReason = "HelmReleaseProxySpecsUpdating"
Expand All @@ -44,13 +42,13 @@ const (

// HelmReleaseProxiesReadyCondition indicates that the HelmReleaseProxies are ready, meaning that the Helm installation, upgrade
// or deletion is complete.
HelmReleaseProxiesReadyCondition clusterv1.ConditionType = "HelmReleaseProxiesReady"
HelmReleaseProxiesReadyCondition = "HelmReleaseProxiesReady"
)

// HelmReleaseProxy Conditions and Reasons.
const (
// HelmReleaseReadyCondition indicates the current status of the underlying Helm release managed by the HelmReleaseProxy.
HelmReleaseReadyCondition clusterv1.ConditionType = "HelmReleaseReady"
HelmReleaseReadyCondition = "HelmReleaseReady"

// PreparingToHelmInstallReason indicates that the HelmReleaseProxy is preparing to install the Helm release.
PreparingToHelmInstallReason = "PreparingToHelmInstall"
Expand All @@ -71,7 +69,7 @@ const (
HelmReleaseGetFailedReason = "HelmReleaseGetFailed"

// ClusterAvailableCondition indicates that the Cluster to install the Helm release on is available.
ClusterAvailableCondition clusterv1.ConditionType = "ClusterAvailable"
ClusterAvailableCondition = "ClusterAvailable"

// GetClusterFailedReason indicates that the HelmReleaseProxy failed to get the Cluster.
GetClusterFailedReason = "GetClusterFailed"
Expand Down
10 changes: 5 additions & 5 deletions api/v1alpha1/helmchartproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
)

// ReconcileStrategy is a string representation of the reconciliation strategy of a HelmChartProxy.
Expand Down Expand Up @@ -242,7 +242,7 @@ type TLSConfig struct {
type HelmChartProxyStatus struct {
// Conditions defines current state of the HelmChartProxy.
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`

// MatchingClusters is the list of references to Clusters selected by the ClusterSelector.
// +optional
Expand All @@ -269,7 +269,7 @@ type HelmChartProxy struct {
Status HelmChartProxyStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// HelmChartProxyList contains a list of HelmChartProxy.
type HelmChartProxyList struct {
Expand All @@ -279,12 +279,12 @@ type HelmChartProxyList struct {
}

// GetConditions returns the list of conditions for an HelmChartProxy API object.
func (c *HelmChartProxy) GetConditions() clusterv1.Conditions {
func (c *HelmChartProxy) GetConditions() []metav1.Condition {
return c.Status.Conditions
}

// SetConditions will set the given conditions on an HelmChartProxy object.
func (c *HelmChartProxy) SetConditions(conditions clusterv1.Conditions) {
func (c *HelmChartProxy) SetConditions(conditions []metav1.Condition) {
c.Status.Conditions = conditions
}

Expand Down
9 changes: 4 additions & 5 deletions api/v1alpha1/helmreleaseproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package v1alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

const (
Expand Down Expand Up @@ -95,7 +94,7 @@ type HelmReleaseProxySpec struct {
type HelmReleaseProxyStatus struct {
// Conditions defines current state of the HelmReleaseProxy.
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`

// Status is the current status of the Helm release.
// +optional
Expand Down Expand Up @@ -129,7 +128,7 @@ type HelmReleaseProxy struct {
Status HelmReleaseProxyStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// HelmReleaseProxyList contains a list of HelmReleaseProxy.
type HelmReleaseProxyList struct {
Expand All @@ -139,12 +138,12 @@ type HelmReleaseProxyList struct {
}

// GetConditions returns the list of conditions for an HelmReleaseProxy API object.
func (r *HelmReleaseProxy) GetConditions() clusterv1.Conditions {
func (r *HelmReleaseProxy) GetConditions() []metav1.Condition {
return r.Status.Conditions
}

// SetConditions will set the given conditions on an HelmReleaseProxy object.
func (r *HelmReleaseProxy) SetConditions(conditions clusterv1.Conditions) {
func (r *HelmReleaseProxy) SetConditions(conditions []metav1.Condition) {
r.Status.Conditions = conditions
}

Expand Down
5 changes: 2 additions & 3 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 29 additions & 24 deletions config/crd/bases/addons.cluster.x-k8s.io_helmchartproxies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -322,51 +322,56 @@ spec:
conditions:
description: Conditions defines current state of the HelmChartProxy.
items:
description: Condition defines an observation of a Cluster API resource
operational state.
description: Condition contains details for one aspect of the current
state of this API Resource.
properties:
lastTransitionTime:
description: |-
lastTransitionTime is the last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when
the API field changed is acceptable.
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: |-
message is a human readable message indicating details about the transition.
This field may be empty.
maxLength: 10240
minLength: 1
This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: |-
observedGeneration represents the .metadata.generation that the condition was set based upon.
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
with respect to the current state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: |-
reason is the reason for the condition's last transition in CamelCase.
The specific API may choose whether or not this field is considered a guaranteed API.
This field may be empty.
maxLength: 256
reason contains a programmatic identifier indicating the reason for the condition's last transition.
Producers of specific condition types may define expected values and meanings for this field,
and whether the values are considered a guaranteed API.
The value should be a CamelCase string.
This field may not be empty.
maxLength: 1024
minLength: 1
type: string
severity:
description: |-
severity provides an explicit classification of Reason code, so the users or machines can immediately
understand the current situation and act accordingly.
The Severity field MUST be set only when Status=False.
maxLength: 32
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: |-
type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
can be useful (see .node.status.conditions), the ability to deconflict is important.
maxLength: 256
minLength: 1
description: type of condition in CamelCase or in foo.example.com/CamelCase.
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
Expand Down
53 changes: 29 additions & 24 deletions config/crd/bases/addons.cluster.x-k8s.io_helmreleaseproxies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -328,51 +328,56 @@ spec:
conditions:
description: Conditions defines current state of the HelmReleaseProxy.
items:
description: Condition defines an observation of a Cluster API resource
operational state.
description: Condition contains details for one aspect of the current
state of this API Resource.
properties:
lastTransitionTime:
description: |-
lastTransitionTime is the last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when
the API field changed is acceptable.
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: |-
message is a human readable message indicating details about the transition.
This field may be empty.
maxLength: 10240
minLength: 1
This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: |-
observedGeneration represents the .metadata.generation that the condition was set based upon.
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
with respect to the current state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: |-
reason is the reason for the condition's last transition in CamelCase.
The specific API may choose whether or not this field is considered a guaranteed API.
This field may be empty.
maxLength: 256
reason contains a programmatic identifier indicating the reason for the condition's last transition.
Producers of specific condition types may define expected values and meanings for this field,
and whether the values are considered a guaranteed API.
The value should be a CamelCase string.
This field may not be empty.
maxLength: 1024
minLength: 1
type: string
severity:
description: |-
severity provides an explicit classification of Reason code, so the users or machines can immediately
understand the current situation and act accordingly.
The Severity field MUST be set only when Status=False.
maxLength: 32
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: |-
type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
can be useful (see .node.status.conditions), the ability to deconflict is important.
maxLength: 256
minLength: 1
description: type of condition in CamelCase or in foo.example.com/CamelCase.
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
Expand Down
2 changes: 1 addition & 1 deletion config/default/manager_pull_policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ spec:
spec:
containers:
- name: manager
imagePullPolicy: Always
imagePullPolicy: IfNotPresent
12 changes: 6 additions & 6 deletions controllers/controllers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
addonsv1alpha1 "sigs.k8s.io/cluster-api-addon-provider-helm/api/v1alpha1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
"sigs.k8s.io/cluster-api/util/conditions"
"sigs.k8s.io/cluster-api/util/secret"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -81,8 +81,8 @@ var (
},
},
Spec: clusterv1.ClusterSpec{
ClusterNetwork: &clusterv1.ClusterNetwork{
APIServerPort: ptr.To(int32(1234)),
ClusterNetwork: clusterv1.ClusterNetwork{
APIServerPort: int32(1234),
},
},
}
Expand Down Expand Up @@ -152,7 +152,7 @@ var _ = Describe("Testing HelmChartProxy and HelmReleaseProxy reconcile", func()
Expect(err).ToNot(HaveOccurred())

patch := client.MergeFrom(cluster.DeepCopy())
conditions.MarkTrue(cluster, clusterv1.ControlPlaneInitializedCondition)
cluster.Status.Initialization.ControlPlaneInitialized = ptr.To(true)
err = k8sClient.Status().Patch(ctx, cluster, patch)
Expect(err).ToNot(HaveOccurred())

Expand Down Expand Up @@ -224,8 +224,8 @@ var _ = Describe("Testing HelmChartProxy and HelmReleaseProxy reconcile", func()

readyCondition := conditions.Get(helmChartProxy, clusterv1.ReadyCondition)
Expect(readyCondition).NotTo(BeNil())
Expect(readyCondition.Status).To(Equal(corev1.ConditionFalse))
Expect(readyCondition.Message).To(Equal(releaseFailedMessage))
Expect(readyCondition.Status).To(Equal(metav1.ConditionFalse))
Expect(readyCondition.Message).To(ContainSubstring(releaseFailedMessage))

By("Making HelmChartProxy uninstallable")
failedHelmUninstall = false
Expand Down
Loading