admin migrate

This commit is contained in:
Michael Quigley 2023-06-27 11:44:38 -04:00
parent 041330b54f
commit 8ba741a550
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62

41
cmd/zrok/adminMigrate.go Normal file
View File

@ -0,0 +1,41 @@
package main
import (
"github.com/michaelquigley/cf"
"github.com/openziti/zrok/controller/config"
"github.com/openziti/zrok/controller/store"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
func init() {
adminCmd.AddCommand(newAdminMigrate().cmd)
}
type adminMigrate struct {
cmd *cobra.Command
}
func newAdminMigrate() *adminMigrate {
cmd := &cobra.Command{
Use: "migrate <configPath>",
Short: "Migrate the underlying datastore",
Args: cobra.ExactArgs(1),
}
command := &adminMigrate{cmd}
cmd.Run = command.run
return command
}
func (cmd *adminMigrate) run(_ *cobra.Command, args []string) {
configPath := args[0]
inCfg, err := config.LoadConfig(configPath)
if err != nil {
panic(err)
}
logrus.Info(cf.Dump(inCfg, cf.DefaultOptions()))
if _, err := store.Open(inCfg.Store); err != nil {
panic(err)
}
logrus.Info("migration complete")
}