mirror of
https://github.com/openziti/zrok.git
synced 2024-11-22 08:03:49 +01:00
admin migrate
This commit is contained in:
parent
041330b54f
commit
8ba741a550
41
cmd/zrok/adminMigrate.go
Normal file
41
cmd/zrok/adminMigrate.go
Normal 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")
|
||||
}
|
Loading…
Reference in New Issue
Block a user