diff --git a/cmd/server/info.go b/cmd/server/info.go new file mode 100644 index 00000000..b1a7eeb2 --- /dev/null +++ b/cmd/server/info.go @@ -0,0 +1,37 @@ +package server + +import ( + "github.com/spf13/cobra" + "github.com/tensorleap/helm-charts/pkg/server" + "github.com/tensorleap/leap-cli/pkg/log" + "gopkg.in/yaml.v3" +) + +func NewInfoCmd() *cobra.Command { + + cmd := &cobra.Command{ + Use: "info", + Short: "Server installation information", + Long: "Server installation information", + RunE: func(cmd *cobra.Command, args []string) error { + installationParams, err := server.LoadInstallationParamsFromPrevious() + if err == server.ErrNoInstallationParams { + log.Info("No installation information found") + return nil + } + if err != nil { + return err + } + + log.Info("Installation information:") + installationParamsYaml, err := yaml.Marshal(installationParams) + if err != nil { + return err + } + log.Info(string(installationParamsYaml)) + return nil + }, + } + + return cmd +} diff --git a/cmd/server/root_unix.go b/cmd/server/root_unix.go index 90c915ff..a53fa7c8 100644 --- a/cmd/server/root_unix.go +++ b/cmd/server/root_unix.go @@ -15,6 +15,7 @@ func init() { RootCommand.AddCommand(NewUpgradeCmd()) RootCommand.AddCommand(NewReinstallCmd()) RootCommand.AddCommand(NewUninstallCmd()) + RootCommand.AddCommand(NewInfoCmd()) RootCommand.AddCommand(server.NewRunCmd()) RootCommand.AddCommand(server.NewStopCmd()) RootCommand.AddCommand(server.NewToolCmd())