Skip to content

Commit 7d262ac

Browse files
committed
feat(datastore): honor schema mode when writing bootstrap data
NewDatastore's bootstrap always wrote schema in legacy per-definition form regardless of the configured schema mode, so a server reading from the unified schema would find none. Add a BootstrapSchemaMode option so the bootstrap datalayer writes schema in the requested mode. The zero value preserves the prior (legacy) behavior.
1 parent 2158060 commit 7d262ac

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

pkg/cmd/datastore/datastore.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ type Config struct {
134134
BootstrapOverwrite bool `debugmap:"visible"`
135135
BootstrapTimeout time.Duration `debugmap:"visible"`
136136
CaveatTypeSet *caveattypes.TypeSet `debugmap:"hidden"`
137+
// BootstrapSchemaMode controls the schema storage mode used when writing bootstrap
138+
// data. The zero value (SchemaModeReadLegacyWriteLegacy) preserves prior behavior.
139+
BootstrapSchemaMode datalayer.SchemaMode `debugmap:"visible"`
137140

138141
// Hedging
139142
RequestHedgingEnabled bool `debugmap:"visible"`
@@ -482,7 +485,7 @@ func NewDatastore(ctx context.Context, options ...ConfigOption) (datastore.Datas
482485
}
483486

484487
if len(bootstrapContents) > 0 {
485-
bootstrapDL := datalayer.NewDataLayer(ds)
488+
bootstrapDL := datalayer.NewDataLayer(ds, datalayer.WithSchemaMode(opts.BootstrapSchemaMode))
486489
_, _, err = validationfile.PopulateFromFilesContents(ctx, bootstrapDL, opts.CaveatTypeSet, bootstrapContents)
487490
if err != nil {
488491
return nil, fmt.Errorf("failed to load bootstrap data: %w", err)

pkg/cmd/datastore/zz_generated.options.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)