Skip to content

Commit

Permalink
Merge pull request #521 from HardBrainer/main
Browse files Browse the repository at this point in the history
Add condition to checkDependencies when SourceRef is the same
  • Loading branch information
stefanprodan authored Jan 10, 2022
2 parents ed4d153 + 8435a5b commit 748120f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions controllers/kustomization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (r *KustomizationReconciler) Reconcile(ctx context.Context, req ctrl.Reques

// check dependencies
if len(kustomization.Spec.DependsOn) > 0 {
if err := r.checkDependencies(kustomization); err != nil {
if err := r.checkDependencies(source, kustomization); err != nil {
kustomization = kustomizev1.KustomizationNotReady(
kustomization, source.GetArtifact().Revision, meta.DependencyNotReadyReason, err.Error())
if err := r.patchStatus(ctx, req, kustomization.Status); err != nil {
Expand Down Expand Up @@ -470,7 +470,7 @@ func (r *KustomizationReconciler) reconcile(
), nil
}

func (r *KustomizationReconciler) checkDependencies(kustomization kustomizev1.Kustomization) error {
func (r *KustomizationReconciler) checkDependencies(source sourcev1.Source, kustomization kustomizev1.Kustomization) error {
for _, d := range kustomization.Spec.DependsOn {
if d.Namespace == "" {
d.Namespace = kustomization.GetNamespace()
Expand All @@ -489,6 +489,10 @@ func (r *KustomizationReconciler) checkDependencies(kustomization kustomizev1.Ku
if !apimeta.IsStatusConditionTrue(k.Status.Conditions, meta.ReadyCondition) {
return fmt.Errorf("dependency '%s' is not ready", dName)
}

if k.Spec.SourceRef.Name == kustomization.Spec.SourceRef.Name && k.Spec.SourceRef.Namespace == kustomization.Spec.SourceRef.Namespace && k.Spec.SourceRef.Kind == kustomization.Spec.SourceRef.Kind && source.GetArtifact().Revision != k.Status.LastAppliedRevision {
return fmt.Errorf("dependency '%s' is not updated yet", dName)
}
}

return nil
Expand Down

0 comments on commit 748120f

Please sign in to comment.