Allow password to be passed as parameter during session creation

parent b6d1a8ce
Pipeline #85933607 passed with stage
in 43 seconds
......@@ -45,6 +45,7 @@ func activateSession(rc *registryclient.Client, name string) error {
var sessionsCmd = &cobra.Command{
Use: "sessions",
Run: func(cmd *cobra.Command, args []string) {
showSubcommandsList(cmd)
},
}
......@@ -52,13 +53,16 @@ var sessionsCreateCmd = &cobra.Command{
Use: "create",
Aliases: []string{"new"},
Run: func(cmd *cobra.Command, args []string) {
var err error
assertRegistry()
assertSessionName()
assertUsername()
password, err := speakeasy.Ask("Password: ")
if err != nil {
logger.Fatal().Err(err).Msg("Failed to read the password")
if password == "" {
password, err = speakeasy.Ask("Password: ")
if err != nil {
logger.Fatal().Err(err).Msg("Failed to read the password")
}
}
if _, err := sessions.CreateSession(sessionName, registry, username, password); err != nil {
......@@ -70,6 +74,7 @@ var sessionsCreateCmd = &cobra.Command{
func init() {
sessionsCreateCmd.Flags().StringVar(&username, "username", "", "Username in the session")
sessionsCreateCmd.Flags().StringVar(&password, "password", "", "Password in the session (optional)")
sessionsCmd.AddCommand(sessionsCreateCmd)
rootCmd.AddCommand(sessionsCmd)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment