Skip to content

Commit

Permalink
Merge pull request #247 from stefanprodan/diff-immutable
Browse files Browse the repository at this point in the history
Handle immutable resources at dry-run
  • Loading branch information
stefanprodan authored Nov 17, 2023
2 parents 60c918d + acf1956 commit 3e598a6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cmd/timoni/dyff.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (
"github.com/homeport/dyff/pkg/dyff"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"sigs.k8s.io/yaml"

apiv1 "github.com/stefanprodan/timoni/api/v1alpha1"
)

// DyffPrinter is a printer that prints dyff reports.
Expand Down Expand Up @@ -100,7 +102,18 @@ func instanceDryRunDiff(ctx context.Context,

change, liveObject, mergedObject, err := rm.Diff(ctx, r, diffOpts)
if err != nil {
log.Error(err, "diff failed")
if ssa.IsImmutableError(err) {
if ssa.AnyInMetadata(r, map[string]string{
apiv1.ForceAction: apiv1.EnabledValue,
}) {
log.Info(colorizeJoin(r, ssa.CreatedAction, dryRunServer))
} else {
log.Error(nil, colorizeJoin(r, "immutable", dryRunServer))
}
} else {
log.Error(err, colorizeUnstructured(r))
}

continue
}

Expand Down

0 comments on commit 3e598a6

Please sign in to comment.