-
Notifications
You must be signed in to change notification settings - Fork 235
kro cli publish command #655
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
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.
@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
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.
same comment as in #656
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.
same comment as in #656
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" |
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.
ditto
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) | ||
} |
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.
Users have to pass the password each time they need to publish their files?
publishConfig.password = string(bytePassword) | ||
} | ||
|
||
ctx := context.Background() |
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: context not used yet.
also let's have a timeout context instead?
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 |
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.
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
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:
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