-
Notifications
You must be signed in to change notification settings - Fork 235
kro cli login command #656
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
base: main
Are you sure you want to change the base?
Conversation
Unknown CLA label state. Rechecking for CLA labels. Send feedback to sig-contributor-experience at kubernetes/community. /check-cla |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @DhairyaMajmudar ! left a few comments in line
loginCmd.PersistentFlags().StringVarP(&loginConfig.password, | ||
"password", "p", "", | ||
"Password for the registry (not recommended, use interactive mode)", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in general it is recommended to not pass passowrds as flags, let's maybe opt for --password-stdin
where users could pipe the password instead?
Auths map[string]RegistryAuth `json:"auths"` | ||
} | ||
|
||
var loginConfig = &LoginConfig{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: let's not declare this a high level variable
type LoginConfig struct { | ||
registry string | ||
username string | ||
password string | ||
} | ||
|
||
type RegistryAuth struct { | ||
Username string `json:"username"` | ||
Password string `json:"password"` | ||
Auth string `json:"auth"` | ||
} | ||
|
||
type ConfigFile struct { | ||
Auths map[string]RegistryAuth `json:"auths"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these structures aren't imported anywhere let's just keep them private. Also can you please add GoDocs for the structure and their fields?
switch registry { | ||
case "docker.io", "index.docker.io": | ||
return "https://index.docker.io/v1/", nil | ||
case "ghcr.io": | ||
return "ghcr.io", nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this really needed?
if !strings.Contains(registry, "://") { | ||
registry = "https://" + registry | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just rely on url.parse here?
generate "github.com/kro-run/kro/cmd/kro/commands/generate" | ||
login "github.com/kro-run/kro/cmd/kro/commands/login" | ||
validate "github.com/kro-run/kro/cmd/kro/commands/validate" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: import aliases not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we avoid updating top level go module? there is one for kro cmd now
if err != nil { | ||
return filepath.Join(".", ".kro", "registry", "config.json") | ||
} | ||
return filepath.Join(homeDir, ".config", "kro", "registry", "config.json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jakobmoellerdev thoughts on this? it's very similar to what helm does
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) | ||
if err != nil { | ||
return fmt.Errorf("failed to hash password: %w", err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how are you going to use a password if it's hashed? is it something standard?
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Description
The kro cli login command is used to store user credentials (passwords, username) for different registers into the config file.
storage location:
$HOME/.config/kro/registry/config.json
Usage
kro login -f [FILE] -r [REGISTRY_URL] -u [USER_NAME] -p [PASSWORD]
Flags:
Note: If username or password is not provided via flags the cli will prompt the user to provide them in further steps.
Demo
Screencast.from.2025-08-31.20-16-24.webm