Skip to content

Commit

Permalink
Merge pull request #1682 from authzed/fix-datastore-command-program-name
Browse files Browse the repository at this point in the history
fixes datastore command not using the `spicedb` prefix for ENV
  • Loading branch information
jzelinskie authored Dec 12, 2023
2 parents 01c462b + cee32ce commit 9baeea1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/cmd/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@ import (
func RegisterDatastoreRootFlags(_ *cobra.Command) {
}

func NewDatastoreCommand(_ string) (*cobra.Command, error) {
func NewDatastoreCommand(programName string) (*cobra.Command, error) {
datastoreCmd := &cobra.Command{
Use: "datastore",
Short: "datastore operations",
Long: "Operations against the configured datastore",
}

migrateCmd := NewMigrateCommand(datastoreCmd.Use)
migrateCmd := NewMigrateCommand(programName)
RegisterMigrateFlags(migrateCmd)
datastoreCmd.AddCommand(migrateCmd)

cfg := datastore.Config{}

gcCmd := NewGCDatastoreCommand(datastoreCmd.Use, &cfg)
gcCmd := NewGCDatastoreCommand(programName, &cfg)
if err := datastore.RegisterDatastoreFlagsWithPrefix(gcCmd.Flags(), "", &cfg); err != nil {
return nil, err
}
datastoreCmd.AddCommand(gcCmd)

repairCmd := NewRepairDatastoreCommand(datastoreCmd.Use, &cfg)
repairCmd := NewRepairDatastoreCommand(programName, &cfg)
if err := datastore.RegisterDatastoreFlagsWithPrefix(repairCmd.Flags(), "", &cfg); err != nil {
return nil, err
}
Expand Down Expand Up @@ -77,7 +77,10 @@ func NewGCDatastoreCommand(programName string, cfg *datastore.Config) *cobra.Com
return fmt.Errorf("datastore of type %T does not support garbage collection", ds)
}

log.Ctx(ctx).Info().Msg("Running garbage collection...")
log.Ctx(ctx).Info().
Float64("gc_window_seconds", cfg.GCWindow.Seconds()).
Float64("gc_max_operation_time_seconds", cfg.GCMaxOperationTime.Seconds()).
Msg("Running garbage collection...")
err = common.RunGarbageCollection(gc, cfg.GCWindow, cfg.GCMaxOperationTime)
if err != nil {
return err
Expand Down

0 comments on commit 9baeea1

Please sign in to comment.