fix: skip remote Kustomizations on recursive diff

When recursively diffing Kustomization objects on a cluster, each
Kustomization is built and then a server-side dry-run apply is
performed. This isn't practical to perform if the Kustomization
references a remote cluster via `kubeConfig.secretRef`.

Currently, because it's not skipped, it's treated as though it's
being applied to the context cluster, not the remote cluter, which
results in an incorrect diff.

Instead, write out special message / warnings indicating that it
has been skipped:
```
► Kustomization/my-ns/my-kst skipped: diff not supported for remote clusters
```

Signed-off-by: Milas Bowman <devnull@milas.dev>
pull/5071/head
Milas Bowman 2 months ago
parent 9f854cb7e2
commit 7697699e65
No known key found for this signature in database

@ -146,14 +146,18 @@ func (b *Builder) diff() (string, bool, error) {
} }
if !kustomizationsEqual(k, b.kustomization) { if !kustomizationsEqual(k, b.kustomization) {
subOutput, subCreatedOrDrifted, err := b.kustomizationDiff(k) if k.Spec.KubeConfig != nil {
if err != nil { output.WriteString(writeString(fmt.Sprintf("⚠️ %s skipped: diff not supported for remote clusters\n", ssautil.FmtUnstructured(obj)), bunt.Orange))
diffErrs = append(diffErrs, err) } else {
} subOutput, subCreatedOrDrifted, err := b.kustomizationDiff(k)
if subCreatedOrDrifted { if err != nil {
createdOrDrifted = true diffErrs = append(diffErrs, err)
output.WriteString(bunt.Sprint(fmt.Sprintf("📁 %s changed\n", ssautil.FmtUnstructured(obj)))) }
output.WriteString(subOutput) if subCreatedOrDrifted {
createdOrDrifted = true
output.WriteString(bunt.Sprint(fmt.Sprintf("📁 %s changed\n", ssautil.FmtUnstructured(obj))))
output.WriteString(subOutput)
}
} }
// finished with Kustomization diff // finished with Kustomization diff

Loading…
Cancel
Save