Skip to content

Commit d1b03d5

Browse files
committed
feat: no default injection during syncs
1 parent ef04ee6 commit d1b03d5

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

cmd/common.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/kong/go-database-reconciler/pkg/diff"
1818
"github.com/kong/go-database-reconciler/pkg/dump"
1919
"github.com/kong/go-database-reconciler/pkg/file"
20+
"github.com/kong/go-database-reconciler/pkg/schema"
2021
"github.com/kong/go-database-reconciler/pkg/state"
2122
reconcilerUtils "github.com/kong/go-database-reconciler/pkg/utils"
2223
"github.com/kong/go-kong/kong"
@@ -29,6 +30,8 @@ var (
2930
assumeYes bool
3031
noMaskValues bool
3132
syncCmdAssumeYes bool
33+
34+
schemaRegistry *schema.Registry
3235
)
3336

3437
type mode int
@@ -191,6 +194,10 @@ func syncMain(ctx context.Context, filenames []string, dry bool, parallelism,
191194
var kongClient *kong.Client
192195
mode := getMode(targetContent)
193196
if mode == modeKonnect {
197+
if skipDefaultsFill {
198+
dumpConfig.SkipDefaults = true
199+
}
200+
194201
// Konnect ConsumerGroup APIs don't support the query-parameter list_consumers yet
195202
if dumpConfig.SkipConsumersWithConsumerGroups {
196203
return errors.New("the flag --skip-consumers-with-consumer-groups can not be used with Konnect")
@@ -279,6 +286,9 @@ func syncMain(ctx context.Context, filenames []string, dry bool, parallelism,
279286
}
280287
}
281288

289+
schemaRegistry = schema.NewRegistry(ctx, kongClient, mode == modeKonnect)
290+
dumpConfig.SchemaRegistry = schemaRegistry
291+
282292
dumpConfig.IsConsumerGroupPolicyOverrideSet = determinePolicyOverride(*targetContent, dumpConfig)
283293

284294
dumpConfig.SelectorTags, err = determineSelectorTag(*targetContent, dumpConfig)
@@ -696,13 +706,15 @@ func performDiff(ctx context.Context, currentState, targetState *state.KongState
696706
shouldSkipDeletes := applyType == ApplyTypePartial
697707

698708
s, err := diff.NewSyncer(diff.SyncerOpts{
699-
CurrentState: currentState,
700-
TargetState: targetState,
701-
KongClient: client,
702-
StageDelaySec: delay,
703-
NoMaskValues: noMaskValues,
704-
IsKonnect: isKonnect,
705-
NoDeletes: shouldSkipDeletes,
709+
CurrentState: currentState,
710+
TargetState: targetState,
711+
KongClient: client,
712+
StageDelaySec: delay,
713+
NoMaskValues: noMaskValues,
714+
IsKonnect: isKonnect,
715+
NoDeletes: shouldSkipDeletes,
716+
SkipSchemaDefaults: isKonnect && skipDefaultsFill,
717+
SchemaRegistry: schemaRegistry,
706718
})
707719
if err != nil {
708720
return 0, err

cmd/root.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ var (
3737

3838
konnectRuntimeGroup string
3939
konnectControlPlane string
40+
41+
skipDefaultsFill bool
4042
)
4143

4244
// NewRootCmd represents the base command when called without any subcommands
@@ -432,6 +434,8 @@ func initKonnectConfig() error {
432434
token = strings.TrimRight(token, "\n")
433435
}
434436

437+
skipDefaultsFill = viper.GetBool("skip-defaults-fill")
438+
435439
disableAnalytics = !viper.GetBool("analytics")
436440
konnectConfig.Email = viper.GetString("konnect-email")
437441
konnectConfig.Password = password

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/fatih/color v1.18.0
1515
github.com/google/go-cmp v0.7.0
1616
github.com/kong/go-apiops v0.2.2
17-
github.com/kong/go-database-reconciler v1.31.5
17+
github.com/kong/go-database-reconciler v1.31.7-0.20260302110444-ed9ab212d32f
1818
github.com/kong/go-kong v0.72.1
1919
github.com/mitchellh/go-homedir v1.1.0
2020
github.com/spf13/cobra v1.9.1

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ github.com/kong/go-apiops v0.2.2 h1:Owdcl/PxTdtciqyZKgPScVhTKHgY2b8dGIC1Bms8NpI=
249249
github.com/kong/go-apiops v0.2.2/go.mod h1:yPwbl3P2eQinVGAEA0d3legaYmzPJ+WtJf9fSeGF4b8=
250250
github.com/kong/go-database-reconciler v1.31.5 h1:gQ5ACprRVQkMy0P3akxSHt1iMju0/pxAHfIqKG/U0Qg=
251251
github.com/kong/go-database-reconciler v1.31.5/go.mod h1:A6BBhnK1AQ7mQAsnLHoAitS62nJRGqUI8NbjC1aRGOc=
252+
github.com/kong/go-database-reconciler v1.31.7-0.20260302105910-4f907df38e32 h1:wF+RVgmkb/OapArrtyvvbp0vbeS9pBSWu+FUfup+Fdw=
253+
github.com/kong/go-database-reconciler v1.31.7-0.20260302105910-4f907df38e32/go.mod h1:A6BBhnK1AQ7mQAsnLHoAitS62nJRGqUI8NbjC1aRGOc=
254+
github.com/kong/go-database-reconciler v1.31.7-0.20260302110444-ed9ab212d32f h1:V2f/loHXw5ERcIkgrO+tchXl/z0kX3R30SX2ESVCF+o=
255+
github.com/kong/go-database-reconciler v1.31.7-0.20260302110444-ed9ab212d32f/go.mod h1:A6BBhnK1AQ7mQAsnLHoAitS62nJRGqUI8NbjC1aRGOc=
252256
github.com/kong/go-kong v0.72.1 h1:rQ69f3Wd0Fvc3JANkavo34vePqR4uZG/YQ2y5U7d2Po=
253257
github.com/kong/go-kong v0.72.1/go.mod h1:J0vGB3wsZ2i99zly1zTRe3v7rOKpkhQZRwbcTFP76qM=
254258
github.com/kong/go-slugify v1.0.0 h1:vCFAyf2sdoSlBtLcrmDWUFn0ohlpKiKvQfXZkO5vSKY=

0 commit comments

Comments
 (0)