Skip to content
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

Update pkg/runtime and apis/meta #421

Merged
merged 1 commit into from
Mar 18, 2022
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ api-docs: gen-crd-api-reference-docs

# Run go mod tidy
tidy:
cd api; rm -f go.sum; go mod tidy
rm -f go.sum; go mod tidy
cd api; rm -f go.sum; go mod tidy -compat=1.17
rm -f go.sum; go mod tidy -compat=1.17

# Run go fmt against code
fmt:
Expand Down
9 changes: 5 additions & 4 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ go 1.17

require (
github.com/fluxcd/pkg/apis/kustomize v0.3.1
github.com/fluxcd/pkg/apis/meta v0.10.2
github.com/fluxcd/pkg/runtime v0.12.5
github.com/fluxcd/pkg/apis/meta v0.12.1
k8s.io/apiextensions-apiserver v0.23.1
k8s.io/apimachinery v0.23.1
k8s.io/apimachinery v0.23.4
sigs.k8s.io/controller-runtime v0.11.0
)

Expand All @@ -20,11 +19,13 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
golang.org/x/net v0.0.0-20211215060638-4ddde0e984e9 // indirect
golang.org/x/sys v0.0.0-20211110154304-99a53858aa08 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/utils v0.0.0-20211208161948-7d6a63dca704 // indirect
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
)
52 changes: 13 additions & 39 deletions api/go.sum

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions api/v2beta1/condition_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,16 @@ const (
// GetLastReleaseFailedReason represents the fact that observing the last
// release failed.
GetLastReleaseFailedReason string = "GetLastReleaseFailed"

// DependencyNotReadyReason represents the fact that
// one of the dependencies is not ready.
DependencyNotReadyReason string = "DependencyNotReady"

// ReconciliationSucceededReason represents the fact that
// the reconciliation succeeded.
ReconciliationSucceededReason string = "ReconciliationSucceeded"

// ReconciliationFailedReason represents the fact that
// the reconciliation failed.
ReconciliationFailedReason string = "ReconciliationFailed"
)
64 changes: 38 additions & 26 deletions api/v2beta1/helmrelease_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import (
"time"

apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
apimeta "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"

"github.com/fluxcd/pkg/apis/kustomize"
"github.com/fluxcd/pkg/apis/meta"
"github.com/fluxcd/pkg/runtime/dependency"
)

const HelmReleaseKind = "HelmRelease"
Expand Down Expand Up @@ -64,7 +64,7 @@ type PostRenderer struct {

// HelmReleaseSpec defines the desired state of a Helm release.
type HelmReleaseSpec struct {
// Chart defines the template of the v1beta1.HelmChart that should be created
// Chart defines the template of the v1beta2.HelmChart that should be created
// for this HelmRelease.
// +required
Chart HelmChartTemplate `json:"chart"`
Expand Down Expand Up @@ -107,11 +107,11 @@ type HelmReleaseSpec struct {
// +optional
StorageNamespace string `json:"storageNamespace,omitempty"`

// DependsOn may contain a dependency.CrossNamespaceDependencyReference slice with
// DependsOn may contain a meta.NamespacedObjectReference slice with
// references to HelmRelease resources that must be ready before this HelmRelease
// can be reconciled.
// +optional
DependsOn []dependency.CrossNamespaceDependencyReference `json:"dependsOn,omitempty"`
DependsOn []meta.NamespacedObjectReference `json:"dependsOn,omitempty"`

// Timeout is the time to wait for any individual Kubernetes operation (like Jobs
// for hooks) during the performance of a Helm action. Defaults to '5m0s'.
Expand Down Expand Up @@ -221,32 +221,32 @@ type KubeConfig struct {
}

// HelmChartTemplate defines the template from which the controller will
// generate a v1beta1.HelmChart object in the same namespace as the referenced
// v1beta1.Source.
// generate a v1beta2.HelmChart object in the same namespace as the referenced
// v1beta2.Source.
type HelmChartTemplate struct {
// Spec holds the template for the v1beta1.HelmChartSpec for this HelmRelease.
// Spec holds the template for the v1beta2.HelmChartSpec for this HelmRelease.
// +required
Spec HelmChartTemplateSpec `json:"spec"`
}

// HelmChartTemplateSpec defines the template from which the controller will
// generate a v1beta1.HelmChartSpec object.
// generate a v1beta2.HelmChartSpec object.
type HelmChartTemplateSpec struct {
// The name or path the Helm chart is available at in the SourceRef.
// +required
Chart string `json:"chart"`

// Version semver expression, ignored for charts from v1beta1.GitRepository and
// v1beta1.Bucket sources. Defaults to latest when omitted.
// Version semver expression, ignored for charts from v1beta2.GitRepository and
// v1beta2.Bucket sources. Defaults to latest when omitted.
// +kubebuilder:default:=*
// +optional
Version string `json:"version,omitempty"`

// The name and namespace of the v1beta1.Source the chart is available at.
// The name and namespace of the v1beta2.Source the chart is available at.
// +required
SourceRef CrossNamespaceObjectReference `json:"sourceRef"`

// Interval at which to check the v1beta1.Source for updates. Defaults to
// Interval at which to check the v1beta2.Source for updates. Defaults to
// 'HelmReleaseSpec.Interval'.
// +optional
Interval *metav1.Duration `json:"interval,omitempty"`
Expand Down Expand Up @@ -276,7 +276,7 @@ type HelmChartTemplateSpec struct {
ValuesFile string `json:"valuesFile,omitempty"`
}

// GetInterval returns the configured interval for the v1beta1.HelmChart,
// GetInterval returns the configured interval for the v1beta2.HelmChart,
// or the given default.
func (in HelmChartTemplate) GetInterval(defaultInterval metav1.Duration) metav1.Duration {
if in.Spec.Interval == nil {
Expand All @@ -286,7 +286,7 @@ func (in HelmChartTemplate) GetInterval(defaultInterval metav1.Duration) metav1.
}

// GetNamespace returns the namespace targeted namespace for the
// v1beta1.HelmChart, or the given default.
// v1beta2.HelmChart, or the given default.
func (in HelmChartTemplate) GetNamespace(defaultNamespace string) string {
if in.Spec.SourceRef.Namespace == "" {
return defaultNamespace
Expand Down Expand Up @@ -841,23 +841,39 @@ func (in HelmReleaseStatus) GetHelmChart() (string, string) {
// 'Unknown' for meta.ProgressingReason.
func HelmReleaseProgressing(hr HelmRelease) HelmRelease {
hr.Status.Conditions = []metav1.Condition{}
meta.SetResourceCondition(&hr, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason,
"Reconciliation in progress")
newCondition := metav1.Condition{
Type: meta.ReadyCondition,
Status: metav1.ConditionUnknown,
Reason: meta.ProgressingReason,
Message: "Reconciliation in progress",
}
apimeta.SetStatusCondition(hr.GetStatusConditions(), newCondition)
resetFailureCounts(&hr)
return hr
}

// HelmReleaseNotReady registers a failed reconciliation of the given HelmRelease.
func HelmReleaseNotReady(hr HelmRelease, reason, message string) HelmRelease {
meta.SetResourceCondition(&hr, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
newCondition := metav1.Condition{
Type: meta.ReadyCondition,
Status: metav1.ConditionFalse,
Reason: reason,
Message: message,
}
apimeta.SetStatusCondition(hr.GetStatusConditions(), newCondition)
hr.Status.Failures++
return hr
}

// HelmReleaseReady registers a successful reconciliation of the given HelmRelease.
func HelmReleaseReady(hr HelmRelease) HelmRelease {
meta.SetResourceCondition(&hr, meta.ReadyCondition, metav1.ConditionTrue, meta.ReconciliationSucceededReason,
"Release reconciliation succeeded")
newCondition := metav1.Condition{
Type: meta.ReadyCondition,
Status: metav1.ConditionTrue,
Reason: ReconciliationSucceededReason,
Message: "Release reconciliation succeeded",
}
apimeta.SetStatusCondition(hr.GetStatusConditions(), newCondition)
hr.Status.LastAppliedRevision = hr.Status.LastAttemptedRevision
resetFailureCounts(&hr)
return hr
Expand Down Expand Up @@ -968,13 +984,9 @@ func (in HelmRelease) GetMaxHistory() int {
return *in.Spec.MaxHistory
}

// GetDependsOn returns the types.NamespacedName of the HelmRelease, and a
// dependency.CrossNamespaceDependencyReference slice it depends on.
func (in HelmRelease) GetDependsOn() (types.NamespacedName, []dependency.CrossNamespaceDependencyReference) {
return types.NamespacedName{
Namespace: in.Namespace,
Name: in.Namespace,
}, in.Spec.DependsOn
// GetDependsOn returns the list of dependencies across-namespaces.
func (in HelmRelease) GetDependsOn() []meta.NamespacedObjectReference {
return in.Spec.DependsOn
}

// GetStatusConditions returns a pointer to the Status.Conditions slice
Expand Down
4 changes: 2 additions & 2 deletions api/v2beta1/zz_generated.deepcopy.go

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

26 changes: 14 additions & 12 deletions config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ spec:
description: HelmReleaseSpec defines the desired state of a Helm release.
properties:
chart:
description: Chart defines the template of the v1beta1.HelmChart that
description: Chart defines the template of the v1beta2.HelmChart that
should be created for this HelmRelease.
properties:
spec:
description: Spec holds the template for the v1beta1.HelmChartSpec
description: Spec holds the template for the v1beta2.HelmChartSpec
for this HelmRelease.
properties:
chart:
description: The name or path the Helm chart is available
at in the SourceRef.
type: string
interval:
description: Interval at which to check the v1beta1.Source
description: Interval at which to check the v1beta2.Source
for updates. Defaults to 'HelmReleaseSpec.Interval'.
type: string
reconcileStrategy:
Expand All @@ -75,7 +75,7 @@ spec:
- Revision
type: string
sourceRef:
description: The name and namespace of the v1beta1.Source
description: The name and namespace of the v1beta2.Source
the chart is available at.
properties:
apiVersion:
Expand Down Expand Up @@ -120,7 +120,7 @@ spec:
version:
default: '*'
description: Version semver expression, ignored for charts
from v1beta1.GitRepository and v1beta1.Bucket sources. Defaults
from v1beta2.GitRepository and v1beta2.Bucket sources. Defaults
to latest when omitted.
type: string
required:
Expand All @@ -131,18 +131,19 @@ spec:
- spec
type: object
dependsOn:
description: DependsOn may contain a dependency.CrossNamespaceDependencyReference
description: DependsOn may contain a meta.NamespacedObjectReference
slice with references to HelmRelease resources that must be ready
before this HelmRelease can be reconciled.
items:
description: CrossNamespaceDependencyReference holds the reference
to a dependency.
description: NamespacedObjectReference contains enough information
to locate the referenced Kubernetes resource object in any namespace.
properties:
name:
description: Name holds the name reference of a dependency.
description: Name of the referent.
type: string
namespace:
description: Namespace holds the namespace reference of a dependency.
description: Namespace of the referent, when not specified it
acts as LocalObjectReference.
type: string
required:
- name
Expand Down Expand Up @@ -249,7 +250,7 @@ spec:
for reconciling the HelmRelease.
properties:
name:
description: Name of the referent
description: Name of the referent.
type: string
required:
- name
Expand Down Expand Up @@ -805,7 +806,8 @@ spec:
type: string
lastHandledReconcileAt:
description: LastHandledReconcileAt holds the value of the most recent
reconcile request value, so a change can be detected.
reconcile request value, so a change of the annotation value can
be detected.
type: string
lastReleaseRevision:
description: LastReleaseRevision is the revision of the last successful
Expand Down
4 changes: 2 additions & 2 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: helm-system
resources:
- https:/fluxcd/source-controller/releases/download/v0.21.1/source-controller.crds.yaml
- https:/fluxcd/source-controller/releases/download/v0.21.1/source-controller.deployment.yaml
- https:/fluxcd/source-controller/releases/download/v0.22.0/source-controller.crds.yaml
- https:/fluxcd/source-controller/releases/download/v0.22.0/source-controller.deployment.yaml
- ../crd
- ../rbac
- ../manager
Expand Down
2 changes: 1 addition & 1 deletion config/samples/source_v1beta1_gitrepository.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: source.toolkit.fluxcd.io/v1beta1
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: GitRepository
metadata:
name: podinfo
Expand Down
2 changes: 1 addition & 1 deletion config/samples/source_v1beta1_helmrepository.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: source.toolkit.fluxcd.io/v1beta1
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: HelmRepository
metadata:
name: podinfo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: source.toolkit.fluxcd.io/v1beta1
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: GitRepository
metadata:
name: this
Expand All @@ -13,4 +13,4 @@ spec:
{{- end}}
{{- if .Values.branch }}
tag: "{{ .Values.tag }}"
{{- end}}
{{- end}}
2 changes: 1 addition & 1 deletion config/testdata/sources/gitrepository.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: source.toolkit.fluxcd.io/v1beta1
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: GitRepository
metadata:
name: podinfo
Expand Down
Loading