Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add insecure flag #26

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions cmd/harbor/root/login.go
Expand Up @@ -15,6 +15,7 @@ type loginOptions struct {
serverAddress string
username string
password string
insecure bool
}

// LoginCommand creates a new `harbor login` command
Expand All @@ -33,8 +34,8 @@ func LoginCommand() *cobra.Command {
}

flags := cmd.Flags()
flags.StringVarP(&opts.name, "name", "", "", "name for the set of credentials")

flags.StringVarP(&opts.name, "name", "n", "", "name for the set of credentials")
flags.StringVarP(&opts.username, "username", "u", "", "Username")
if err := cmd.MarkFlagRequired("username"); err != nil {
panic(err)
Expand All @@ -43,6 +44,7 @@ func LoginCommand() *cobra.Command {
if err := cmd.MarkFlagRequired("password"); err != nil {
panic(err)
}
flags.BoolVarP(&opts.insecure, "insecure", "i", false, "Allow insecure server connections when using SSL")

return cmd
}
Expand All @@ -52,6 +54,7 @@ func runLogin(opts loginOptions) error {
URL: opts.serverAddress,
Username: opts.username,
Password: opts.password,
Insecure: opts.insecure,
}
client := utils.GetClientByConfig(clientConfig)

Expand All @@ -69,7 +72,7 @@ func runLogin(opts loginOptions) error {
}

if err = utils.StoreCredential(cred, true); err != nil {
return fmt.Errorf("Failed to store the credential: %s", err)
return fmt.Errorf("failed to store the credential: %s", err)
}
return nil
}