feat: added sessions cmd

This commit is contained in:
David Allen 2025-05-26 22:46:14 -06:00
parent 2596e8945f
commit d6deff4808
Signed by: towk
GPG key ID: 0430CDBE22619155

View file

@ -139,7 +139,7 @@ var sessionLoginCmd = &cobra.Command{
case "yaml": case "yaml":
util.PrintYAML(newSessions) util.PrintYAML(newSessions)
default: default:
log.Error().Msg("unrecognized output sessionOutputFormat") log.Error().Msg("unrecognized output format")
os.Exit(1) os.Exit(1)
} }
}, },
@ -226,7 +226,7 @@ var sessionLogoutCmd = &cobra.Command{
var sessionStatusCmd = &cobra.Command{ var sessionStatusCmd = &cobra.Command{
Use: "status", Use: "status",
Example: ` // show the host's session service status in YAML sessionOutputFormat Example: ` // show the host's session service status in YAML format
magellan sessions status https://172.21.0.2:5000 -u $bmc_username -p $bmc_password -i -F yaml`, magellan sessions status https://172.21.0.2:5000 -u $bmc_username -p $bmc_password -i -F yaml`,
Args: cobra.MinimumNArgs(1), Args: cobra.MinimumNArgs(1),
Short: "Show the status of the session service", Short: "Show the status of the session service",
@ -283,7 +283,7 @@ var sessionListCmd = &cobra.Command{
case FORMAT_YAML: case FORMAT_YAML:
util.PrintYAML(session) util.PrintYAML(session)
default: default:
log.Error().Msg("unrecognized output sessionOutputFormat") log.Error().Msg("unrecognized output format")
os.Exit(1) os.Exit(1)
} }
@ -311,7 +311,7 @@ var sessionListCmd = &cobra.Command{
case FORMAT_YAML: case FORMAT_YAML:
util.PrintYAML(sessionIDs) util.PrintYAML(sessionIDs)
default: default:
log.Error().Msg("unrecognized output sessionOutputFormat") log.Error().Msg("unrecognized output format")
os.Exit(1) os.Exit(1)
} }
} }
@ -339,7 +339,7 @@ func init() {
sessionCmd.PersistentFlags().StringVarP(&password, "password", "p", "", "Set the password for BMC login") sessionCmd.PersistentFlags().StringVarP(&password, "password", "p", "", "Set the password for BMC login")
sessionCmd.PersistentFlags().StringVar(&sessionTokenPath, "session-token-file", "", "Set the session token from a file") sessionCmd.PersistentFlags().StringVar(&sessionTokenPath, "session-token-file", "", "Set the session token from a file")
sessionCmd.PersistentFlags().StringVar(&sessionToken, "session-token", "", "Set the session token") sessionCmd.PersistentFlags().StringVar(&sessionToken, "session-token", "", "Set the session token")
sessionCmd.PersistentFlags().StringVarP(&sessionOutputFormat, "sessionOutputFormat", "F", "list", "Set the output sessionOutputFormat (list|json|yaml)") sessionCmd.PersistentFlags().StringVarP(&sessionOutputFormat, "format", "F", "list", "Set the output sessionOutputFormat (list|json|yaml)")
sessionCmd.PersistentFlags().StringVarP(&secretsFile, "secrets-file", "f", "secrets.json", "Set the path to secrets store file to store credentials") sessionCmd.PersistentFlags().StringVarP(&secretsFile, "secrets-file", "f", "secrets.json", "Set the path to secrets store file to store credentials")
sessionCmd.MarkFlagRequired("username") sessionCmd.MarkFlagRequired("username")