Skip to content

Commit

Permalink
Fix wrong deletion message on flux diff
Browse files Browse the repository at this point in the history
If implemented, when an error happens when dry-running an object, we
return early. This match pkg ssa implementation

Signed-off-by: Soule BA <[email protected]>
  • Loading branch information
souleb committed Feb 5, 2022
1 parent 4b4e6b1 commit 8dc2a98
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions internal/build/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func (b *Builder) Diff() (string, bool, error) {

// create an inventory of objects to be reconciled
newInventory := newInventory()
oldStatus := b.kustomization.Status.DeepCopy()
for _, obj := range objects {
diffOptions := ssa.DiffOptions{
Exclusions: map[string]string{
Expand All @@ -86,12 +87,7 @@ func (b *Builder) Diff() (string, bool, error) {
}
change, liveObject, mergedObject, err := resourceManager.Diff(ctx, obj, diffOptions)
if err != nil {
if b.kustomization.Spec.Force && ssa.IsImmutableError(err) {
output.WriteString(writeString(fmt.Sprintf("► %s created\n", obj.GetName()), bunt.Green))
} else {
output.WriteString(writeString(fmt.Sprintf("✗ %v\n", err), bunt.Red))
}
continue
return "", createdOrDrifted, err
}

// if the object is a sops secret, we need to
Expand Down Expand Up @@ -125,7 +121,6 @@ func (b *Builder) Diff() (string, bool, error) {
}

if b.kustomization.Spec.Prune {
oldStatus := b.kustomization.Status.DeepCopy()
if oldStatus.Inventory != nil {
diffObjects, err := diffInventory(oldStatus.Inventory, newInventory)
if err != nil {
Expand Down

0 comments on commit 8dc2a98

Please sign in to comment.