Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,12 @@ func syncMain(ctx context.Context, filenames []string, dry bool, parallelism,
jsonOutput.Errors = []string{}
jsonOutput.Warnings = []string{}
jsonOutput.Changes = diff.EntityChanges{
Creating: []diff.EntityState{},
Updating: []diff.EntityState{},
Deleting: []diff.EntityState{},
Creating: []diff.EntityState{},
Updating: []diff.EntityState{},
Deleting: []diff.EntityState{},
DroppedCreations: []diff.EntityState{},
DroppedUpdates: []diff.EntityState{},
DroppedDeletions: []diff.EntityState{},
}
}
targetContent, err := file.GetContentFromFiles(filenames, false)
Expand Down Expand Up @@ -691,20 +694,18 @@ func performDiff(ctx context.Context, currentState, targetState *state.KongState
}

stats, errs, changes := s.Solve(ctx, parallelism, dry, enableJSONOutput)
totalOps := stats.CreateOps.Count() + stats.UpdateOps.Count() + stats.DeleteOps.Count()
// print stats before error to report completed operations
if !enableJSONOutput {
printStats(stats)
}
if errs != nil {
return 0, reconcilerUtils.ErrArray{Errors: errs}
}
totalOps := stats.CreateOps.Count() + stats.UpdateOps.Count() + stats.DeleteOps.Count()

if enableJSONOutput {
} else {
jsonOutput.Changes = diff.EntityChanges{
Creating: append(jsonOutput.Changes.Creating, changes.Creating...),
Updating: append(jsonOutput.Changes.Updating, changes.Updating...),
Deleting: append(jsonOutput.Changes.Deleting, changes.Deleting...),
Creating: append(jsonOutput.Changes.Creating, changes.Creating...),
Updating: append(jsonOutput.Changes.Updating, changes.Updating...),
Deleting: append(jsonOutput.Changes.Deleting, changes.Deleting...),
DroppedCreations: append(jsonOutput.Changes.DroppedCreations, changes.DroppedCreations...),
DroppedUpdates: append(jsonOutput.Changes.DroppedUpdates, changes.DroppedUpdates...),
DroppedDeletions: append(jsonOutput.Changes.DroppedDeletions, changes.DroppedDeletions...),
}
jsonOutput.Summary = diff.Summary{
Creating: stats.CreateOps.Count(),
Expand All @@ -713,6 +714,10 @@ func performDiff(ctx context.Context, currentState, targetState *state.KongState
Total: totalOps,
}
}
if errs != nil {
return 0, reconcilerUtils.ErrArray{Errors: errs}
}

return int(totalOps), nil
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/fatih/color v1.18.0
github.com/google/go-cmp v0.7.0
github.com/kong/go-apiops v0.2.1
github.com/kong/go-database-reconciler v1.31.0
github.com/kong/go-database-reconciler v1.31.1-0.20251222062637-7b26eddcaf74
github.com/kong/go-kong v0.71.0
github.com/mitchellh/go-homedir v1.1.0
github.com/spf13/cobra v1.9.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/q
github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/kong/go-apiops v0.2.1 h1:6HtyQyOj+CLA86iRtXA6rpTqemp7VqJJ6gpHyNHdB7o=
github.com/kong/go-apiops v0.2.1/go.mod h1:yPwbl3P2eQinVGAEA0d3legaYmzPJ+WtJf9fSeGF4b8=
github.com/kong/go-database-reconciler v1.31.0 h1:LITt0L/EhajVaSNDMj/TOxh4Cst7CRhiTykYMMlOoLk=
github.com/kong/go-database-reconciler v1.31.0/go.mod h1:kw4+JGF6iv70LcLBmuY2UuMr8KSdqop77IR86B1mYvU=
github.com/kong/go-database-reconciler v1.31.1-0.20251222062637-7b26eddcaf74 h1:CZH3uu/dNY3U53w/LycO03pt+ekR6YqznkWgdjkjzeo=
github.com/kong/go-database-reconciler v1.31.1-0.20251222062637-7b26eddcaf74/go.mod h1:kw4+JGF6iv70LcLBmuY2UuMr8KSdqop77IR86B1mYvU=
github.com/kong/go-kong v0.71.0 h1:unPik6osV1DD3DF+jLs9oMedxWQsnepPYTm1dRQSIa4=
github.com/kong/go-kong v0.71.0/go.mod h1:J0vGB3wsZ2i99zly1zTRe3v7rOKpkhQZRwbcTFP76qM=
github.com/kong/go-slugify v1.0.0 h1:vCFAyf2sdoSlBtLcrmDWUFn0ohlpKiKvQfXZkO5vSKY=
Expand Down
Loading