Skip to content

Conversation

@DhairyaMajmudar
Copy link
Member

Description

The new kro cli publish command is useful to publish an OCI image into container registries like docker hub, aws, gcr, etc....

Usage

kro package -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

kro-publish.webm

Copy link
Member

Choose a reason for hiding this comment

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

@DhairyaMajmudar Can we have a seperate go.mod file for the CLI? looks like our dependencies are growing with each command that we're adding

Copy link
Member

Choose a reason for hiding this comment

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

same comment as in #656

@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

Choose a reason for hiding this comment

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

same comment as in #656

Comment on lines 20 to 22
generate "github.com/kro-run/kro/cmd/kro/commands/generate"
publish "github.com/kro-run/kro/cmd/kro/commands/publish"
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.

ditto

Comment on lines +90 to +98
if publishConfig.password == "" {
fmt.Print("Password: ")
bytePassword, err := term.ReadPassword(int(os.Stdin.Fd()))
fmt.Println()
if err != nil {
return fmt.Errorf("failed to read password: %w", err)
}
publishConfig.password = string(bytePassword)
}
Copy link
Member

Choose a reason for hiding this comment

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

Users have to pass the password each time they need to publish their files?

publishConfig.password = string(bytePassword)
}

ctx := context.Background()
Copy link
Member

Choose a reason for hiding this comment

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

nit: context not used yet.
also let's have a timeout context instead?

Comment on lines +123 to +156
tempDir, err := os.MkdirTemp("", "kro-publish-*")
if err != nil {
return fmt.Errorf("failed to create temp dir: %w", err)
}
defer func() {
if err := os.RemoveAll(tempDir); err != nil {
fmt.Println("Warning: failed to remove temp dir", tempDir, ":", err)
}
}()

fmt.Println("Extracting", publishConfig.ociTarballPath, "to", tempDir, "...")
if err := untar(publishConfig.ociTarballPath, tempDir); err != nil {
return fmt.Errorf("failed to extract OCI tarball: %w", err)
}

store, err := oci.New(tempDir)
if err != nil {
return fmt.Errorf("failed to open OCI layout at %s: %w", tempDir, err)
}

rootDesc, err := findRootManifestDescriptor(tempDir)
if err != nil {
return fmt.Errorf("failed to find root manifest in OCI layout: %w", err)
}
fmt.Println("Found manifest to push:", rootDesc.Digest)

fmt.Println("Publishing to", publishConfig.remoteRef, "...")
_, err = oras.Copy(ctx, store, rootDesc.Digest.String(), repo, publishConfig.remoteRef, oras.DefaultCopyOptions)
if err != nil {
return fmt.Errorf("failed to publish OCI image: %w", err)
}

fmt.Println("Successfully published OCI image to", publishConfig.remoteRef)
return nil
Copy link
Member

Choose a reason for hiding this comment

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

I think we're missing the kro package command, i wouldn't expect kro publish to do any package/extracting here. It should just get a tarball file and sent it to OCI

@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.

@tjamet
Copy link

tjamet commented Nov 7, 2025

hi @DhairyaMajmudar I'm curious to understand how you integrate OCIs with kro
That would help understand how we could integrate OCI packages push in KRO CLI

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.

5 participants