Skip to content

Conversation

DhairyaMajmudar
Copy link
Member

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:

Shorthand Flag Usage
-f --file Path to the ResourceGroupDefinition file
-r --ref Remote reference to publish the OCI image to (e.g., 'ghcr.io/user/repo:tag')
-u --username Username for the remote registry (Optional)
-p --password Password for the remote registry (Optional)

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

@k8s-triage-robot
Copy link

Unknown CLA label state. Rechecking for CLA labels.

Send feedback to sig-contributor-experience at kubernetes/community.

/check-cla
/easycla

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 12, 2025
Copy link
Member

@a-hilaly a-hilaly left a 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

Comment on lines +59 to +62
loginCmd.PersistentFlags().StringVarP(&loginConfig.password,
"password", "p", "",
"Password for the registry (not recommended, use interactive mode)",
)
Copy link
Member

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{}
Copy link
Member

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

Comment on lines +32 to +46
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"`
}
Copy link
Member

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?

Comment on lines +115 to +120
switch registry {
case "docker.io", "index.docker.io":
return "https://index.docker.io/v1/", nil
case "ghcr.io":
return "ghcr.io", nil
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really needed?

Comment on lines +122 to +124
if !strings.Contains(registry, "://") {
registry = "https://" + registry
}
Copy link
Member

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?

Comment on lines 20 to 22
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"
Copy link
Member

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

Copy link
Member

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")
Copy link
Member

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

Comment on lines +157 to +160
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
if err != nil {
return fmt.Errorf("failed to hash password: %w", err)
}
Copy link
Member

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?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 26, 2025
@k8s-ci-robot
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants