Use reconcile annotation helpers

Per https://github.com/fluxcd/pkg/issues/39
This commit is contained in:
Michael Bridgen 2020-10-22 12:26:48 +01:00
parent f39ef787c7
commit 0928cc1e4d
11 changed files with 25 additions and 19 deletions

View File

@ -3,7 +3,7 @@ module github.com/fluxcd/helm-controller/api
go 1.15
require (
github.com/fluxcd/pkg/apis/meta v0.0.2
github.com/fluxcd/pkg/apis/meta v0.1.0
github.com/fluxcd/pkg/runtime v0.1.0
k8s.io/api v0.18.9
k8s.io/apiextensions-apiserver v0.18.9

View File

@ -63,6 +63,8 @@ github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLi
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fluxcd/pkg/apis/meta v0.0.2 h1:kyA4Y0IzNjf1joBOnFqpWG7aNDHvtLExZcaHQM7qhRI=
github.com/fluxcd/pkg/apis/meta v0.0.2/go.mod h1:nCNps5JJOcEQr3MNDmZqI4o0chjePSUYL6Q2ktDtotU=
github.com/fluxcd/pkg/apis/meta v0.1.0 h1:CfOYHYaHslhcb3QlzgKCOXl4ziCbA5zG/fUa1qFlHis=
github.com/fluxcd/pkg/apis/meta v0.1.0/go.mod h1:nCNps5JJOcEQr3MNDmZqI4o0chjePSUYL6Q2ktDtotU=
github.com/fluxcd/pkg/runtime v0.1.0 h1:mCLj5GlQZqWtK3tvtZTmfgFOLsTUY1iqg3CmEyS1nRs=
github.com/fluxcd/pkg/runtime v0.1.0/go.mod h1:OXkrYtDLw3GhclbzvnzfSktUyxRmC3FFhXj0tVVaIX8=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=

View File

@ -627,10 +627,7 @@ type HelmReleaseStatus struct {
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
// LastHandledReconcileAt is the last manual reconciliation request (by
// annotating the HelmRelease) handled by the reconciler.
// +optional
LastHandledReconcileAt string `json:"lastHandledReconcileAt,omitempty"`
meta.ReconcileRequestStatus `json:",inline"`
// Conditions holds the conditions for the HelmRelease.
// +optional

View File

@ -214,6 +214,7 @@ func (in *HelmReleaseSpec) DeepCopy() *HelmReleaseSpec {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HelmReleaseStatus) DeepCopyInto(out *HelmReleaseStatus) {
*out = *in
out.ReconcileRequestStatus = in.ReconcileRequestStatus
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]meta.Condition, len(*in))

View File

@ -474,8 +474,8 @@ spec:
values of the last reconciliation attempt.
type: string
lastHandledReconcileAt:
description: LastHandledReconcileAt is the last manual reconciliation
request (by annotating the HelmRelease) handled by the reconciler.
description: LastHandledReconcileAt holds the value of the most recent
reconcile request value, so a change can be detected.
type: string
lastReleaseRevision:
description: LastReleaseRevision is the revision of the last successful

View File

@ -115,7 +115,7 @@ func (r *HelmChartWatcher) requestReconciliation(ctx context.Context, hr v2.Helm
if hr.Annotations == nil {
hr.Annotations = make(map[string]string)
}
hr.Annotations[meta.ReconcileAtAnnotation] = metav1.Now().String()
hr.Annotations[meta.ReconcileRequestAnnotation] = metav1.Now().String()
err = r.Update(ctx, &hr)
return
})

View File

@ -152,8 +152,8 @@ func (r *HelmReleaseReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error)
func (r *HelmReleaseReconciler) reconcile(ctx context.Context, log logr.Logger, hr v2.HelmRelease) (v2.HelmRelease, ctrl.Result, error) {
reconcileStart := time.Now()
// Record the value of the reconciliation request, if any
if v, ok := hr.GetAnnotations()[meta.ReconcileAtAnnotation]; ok {
hr.Status.LastHandledReconcileAt = v
if v, ok := meta.ReconcileAnnotationValue(hr.GetAnnotations()); ok {
hr.Status.SetLastHandledReconcileRequest(v)
}
// Observe HelmRelease generation.

View File

@ -846,15 +846,17 @@ int64
</tr>
<tr>
<td>
<code>lastHandledReconcileAt</code><br>
<code>ReconcileRequestStatus</code><br>
<em>
string
<a href="https://godoc.org/github.com/fluxcd/pkg/apis/meta#ReconcileRequestStatus">
github.com/fluxcd/pkg/apis/meta.ReconcileRequestStatus
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>LastHandledReconcileAt is the last manual reconciliation request (by
annotating the HelmRelease) handled by the reconciler.</p>
<p>
(Members of <code>ReconcileRequestStatus</code> are embedded into this type.)
</p>
</td>
</tr>
<tr>

4
go.mod
View File

@ -6,8 +6,8 @@ replace github.com/fluxcd/helm-controller/api => ./api
require (
github.com/fluxcd/helm-controller/api v0.1.3
github.com/fluxcd/pkg/apis/meta v0.0.2
github.com/fluxcd/pkg/runtime v0.1.0
github.com/fluxcd/pkg/apis/meta v0.1.0
github.com/fluxcd/pkg/runtime v0.1.2
github.com/fluxcd/source-controller/api v0.1.1
github.com/go-logr/logr v0.1.0
github.com/onsi/ginkgo v1.12.1

4
go.sum
View File

@ -194,8 +194,12 @@ github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fluxcd/pkg/apis/meta v0.0.2 h1:kyA4Y0IzNjf1joBOnFqpWG7aNDHvtLExZcaHQM7qhRI=
github.com/fluxcd/pkg/apis/meta v0.0.2/go.mod h1:nCNps5JJOcEQr3MNDmZqI4o0chjePSUYL6Q2ktDtotU=
github.com/fluxcd/pkg/apis/meta v0.1.0 h1:CfOYHYaHslhcb3QlzgKCOXl4ziCbA5zG/fUa1qFlHis=
github.com/fluxcd/pkg/apis/meta v0.1.0/go.mod h1:nCNps5JJOcEQr3MNDmZqI4o0chjePSUYL6Q2ktDtotU=
github.com/fluxcd/pkg/runtime v0.1.0 h1:mCLj5GlQZqWtK3tvtZTmfgFOLsTUY1iqg3CmEyS1nRs=
github.com/fluxcd/pkg/runtime v0.1.0/go.mod h1:OXkrYtDLw3GhclbzvnzfSktUyxRmC3FFhXj0tVVaIX8=
github.com/fluxcd/pkg/runtime v0.1.2 h1:bKhjJGVOJgTQTWjqhwasyt69lBItq1ZWjX04rUkiypo=
github.com/fluxcd/pkg/runtime v0.1.2/go.mod h1:HXYTNdkK8ulcT1mhuGhio9tsX65ACKaealtd/MsnkhM=
github.com/fluxcd/source-controller/api v0.1.1 h1:BYxl9qc8pCx3/Bn1885TlkJPwvXqz+rAL9mzpnCrj9A=
github.com/fluxcd/source-controller/api v0.1.1/go.mod h1:1ac/vj49YVPKF+xBHTo/9pfFj64TcLc1RLaxi4MwVEM=
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=

View File

@ -24,8 +24,8 @@
"docsURLTemplate": "https://godoc.org/github.com/fluxcd/pkg/runtime/dependency#CrossNamespaceDependencyReference"
},
{
"typeMatchPrefix": "^github.com/fluxcd/pkg/apis/meta\\.Condition$",
"docsURLTemplate": "https://godoc.org/github.com/fluxcd/pkg/apis/meta#Condition"
"typeMatchPrefix": "^github.com/fluxcd/pkg/apis/meta",
"docsURLTemplate": "https://godoc.org/github.com/fluxcd/pkg/apis/meta#{{ .TypeIdentifier }}"
}
],
"typeDisplayNamePrefixOverrides": {