UniStore: Add non interactive mode for CLI migration (#103407)

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
This commit is contained in:
maicon
2025-04-07 17:23:47 -03:00
committed by GitHub
parent 66006928b8
commit fa7ea6ee00
2 changed files with 27 additions and 0 deletions
+7
View File
@@ -148,6 +148,13 @@ var adminCommands = []*cli.Command{
Name: "to-unified-storage",
Usage: "Migrates classic SQL data into unified storage",
Action: runDbCommand(datamigrations.ToUnifiedStorage),
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "non-interactive",
Usage: "Non interactive mode. Just run the migration.",
Value: false,
},
},
},
},
},
@@ -67,6 +67,26 @@ func ToUnifiedStorage(c utils.CommandLine, cfg *setting.Cfg, sqlStore db.DB) err
nil, provisioning, sort.ProvideService(),
)
if c.Bool("non-interactive") {
client, err := newUnifiedClient(cfg, sqlStore)
if err != nil {
return err
}
opts.Store = client
opts.BlobStore = client
rsp, err := migrator.Migrate(ctx, opts)
if err != nil {
return err
}
fmt.Printf("Unified storage export: %s\n", time.Since(start))
if rsp != nil {
jj, _ := json.MarshalIndent(rsp, "", " ")
fmt.Printf("%s\n", string(jj))
}
return nil
}
yes, err := promptYesNo(fmt.Sprintf("Count legacy resources for namespace: %s?", opts.Namespace))
if err != nil {
return err