Skip to content

Commit

Permalink
Support RFC-0005 revision format
Browse files Browse the repository at this point in the history
This updates all the comparisons to make use of `HasRevision` which
supports the RFC-0005 and legacy revision formats.

Signed-off-by: Hidde Beydals <hello@hidde.co>
  • Loading branch information
hiddeco committed Feb 13, 2023
1 parent df9dd9b commit 5380574
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
7 changes: 3 additions & 4 deletions controllers/kustomization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,8 @@ func (r *KustomizationReconciler) reconcile(
src sourcev1.Source,
patcher *patch.SerialPatcher) error {

revision := src.GetArtifact().Revision
isNewRevision := obj.Status.LastAppliedRevision != revision

// Update status with the reconciliation progress.
revision := src.GetArtifact().Revision
progressingMsg := fmt.Sprintf("Fetching manifests for revision %s with a timeout of %s", revision, obj.GetTimeout().String())
conditions.MarkUnknown(obj, meta.ReadyCondition, meta.ProgressingReason, "Reconciliation in progress")
conditions.MarkReconciling(obj, meta.ProgressingReason, progressingMsg)
Expand Down Expand Up @@ -439,6 +437,7 @@ func (r *KustomizationReconciler) reconcile(
}

// Run the health checks for the last applied resources.
isNewRevision := !src.GetArtifact().HasRevision(obj.Status.LastAppliedRevision)
if err := r.checkHealth(ctx,
resourceManager,
patcher,
Expand Down Expand Up @@ -491,7 +490,7 @@ func (r *KustomizationReconciler) checkDependencies(ctx context.Context,
if k.Spec.SourceRef.Name == obj.Spec.SourceRef.Name &&
k.Spec.SourceRef.Namespace == obj.Spec.SourceRef.Namespace &&
k.Spec.SourceRef.Kind == obj.Spec.SourceRef.Kind &&
source.GetArtifact().Revision != k.Status.LastAppliedRevision {
!source.GetArtifact().HasRevision(k.Status.LastAppliedRevision) {
return fmt.Errorf("dependency '%s' revision is not up to date", dName)
}
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/kustomization_indexers.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (r *KustomizationReconciler) requestsForRevisionChangeOf(indexKey string) f
for _, d := range list.Items {
// If the revision of the artifact equals to the last attempted revision,
// we should not make a request for this Kustomization
if repo.GetArtifact().Revision == d.Status.LastAttemptedRevision {
if repo.GetArtifact().HasRevision(d.Status.LastAttemptedRevision) {
continue
}
dd = append(dd, d.DeepCopy())
Expand Down
2 changes: 1 addition & 1 deletion controllers/source_predicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (SourceRevisionChangePredicate) Update(e event.UpdateEvent) bool {
}

if oldSource.GetArtifact() != nil && newSource.GetArtifact() != nil &&
oldSource.GetArtifact().Revision != newSource.GetArtifact().Revision {
!oldSource.GetArtifact().HasRevision(newSource.GetArtifact().Revision) {
return true
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/fluxcd/pkg/ssa v0.23.0
github.com/fluxcd/pkg/tar v0.2.0
github.com/fluxcd/pkg/testserver v0.4.0
github.com/fluxcd/source-controller/api v0.34.0
github.com/fluxcd/source-controller/api v0.34.1-0.20230210193059-0d50ac3eef23
github.com/hashicorp/vault/api v1.8.3
github.com/onsi/gomega v1.26.0
github.com/ory/dockertest/v3 v3.9.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ github.com/fluxcd/pkg/testserver v0.4.0 h1:pDZ3gistqYhwlf3sAjn1Q8NzN4Qe6I1BEmHMH
github.com/fluxcd/pkg/testserver v0.4.0/go.mod h1:gjOKX41okmrGYOa4oOF2fiLedDAfPo1XaG/EzrUUGBI=
github.com/fluxcd/source-controller/api v0.34.0 h1:M2kD95IdpmHcDNy78K6T6p7niC38LGwSrKq8XAZEJY0=
github.com/fluxcd/source-controller/api v0.34.0/go.mod h1:w3PDdR+FZyq3zyyUDxz6vY3CKByZfYAjkzJUxuUXCuc=
github.com/fluxcd/source-controller/api v0.34.1-0.20230210193059-0d50ac3eef23 h1:KyzCcKiJHOCAPy8MYcwfgnChtJkr1Iga5s024aAi6wg=
github.com/fluxcd/source-controller/api v0.34.1-0.20230210193059-0d50ac3eef23/go.mod h1:w3PDdR+FZyq3zyyUDxz6vY3CKByZfYAjkzJUxuUXCuc=
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
github.com/frankban/quicktest v1.13.0 h1:yNZif1OkDfNoDfb9zZa9aXIpejNR4F23Wely0c+Qdqk=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
Expand Down

0 comments on commit 5380574

Please sign in to comment.