Skip to content

Commit f678259

Browse files
author
Chanwit Kaewkasi
authored
Merge pull request #406 from weaveworks/fix-check-deps
check output secret of the dependencies
2 parents b7c13da + 5e9b031 commit f678259

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

controllers/tf_controller.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"crypto/sha1"
2323
"crypto/sha256"
2424
"fmt"
25-
"github.com/fluxcd/pkg/runtime/dependency"
2625
"io"
2726
"net/http"
2827
"net/url"
@@ -31,6 +30,7 @@ import (
3130
"time"
3231

3332
"github.com/fluxcd/pkg/apis/meta"
33+
"github.com/fluxcd/pkg/runtime/dependency"
3434
"github.com/fluxcd/pkg/runtime/events"
3535
"github.com/fluxcd/pkg/runtime/metrics"
3636
"github.com/fluxcd/pkg/runtime/predicates"
@@ -422,9 +422,26 @@ func (r *TerraformReconciler) checkDependencies(source sourcev1.Source, terrafor
422422
return fmt.Errorf("dependency '%s' is not ready", dName)
423423
}
424424

425-
if tf.Spec.SourceRef.Name == terraform.Spec.SourceRef.Name && tf.Spec.SourceRef.Namespace == terraform.Spec.SourceRef.Namespace && tf.Spec.SourceRef.Kind == terraform.Spec.SourceRef.Kind && source.GetArtifact().Revision != tf.Status.LastAppliedRevision {
425+
revision := source.GetArtifact().Revision
426+
if tf.Spec.SourceRef.Name == terraform.Spec.SourceRef.Name &&
427+
tf.Spec.SourceRef.Namespace == terraform.Spec.SourceRef.Namespace &&
428+
tf.Spec.SourceRef.Kind == terraform.Spec.SourceRef.Kind &&
429+
revision != tf.Status.LastAppliedRevision &&
430+
revision != tf.Status.LastPlannedRevision {
426431
return fmt.Errorf("dependency '%s' is not updated yet", dName)
427432
}
433+
434+
if tf.Spec.WriteOutputsToSecret != nil {
435+
outputSecret := tf.Spec.WriteOutputsToSecret.Name
436+
outputSecretName := types.NamespacedName{
437+
Namespace: tf.GetNamespace(),
438+
Name: outputSecret,
439+
}
440+
if err := r.Get(context.Background(), outputSecretName, &corev1.Secret{}); err != nil {
441+
return fmt.Errorf("dependency output secret: '%s' of '%s' is not ready yet", outputSecret, dName)
442+
}
443+
}
444+
428445
}
429446

430447
return nil

0 commit comments

Comments
 (0)