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

add --digest flag #92

Closed
wants to merge 0 commits into from
Closed

add --digest flag #92

wants to merge 0 commits into from

Conversation

Horiodino
Copy link
Contributor

@Horiodino Horiodino commented Jul 19, 2024

related issue : #39

uses bsf oci --push --digest --auth=username:password

return err
}

fmt.Println("Digest:", digest)
Copy link
Contributor

Choose a reason for hiding this comment

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

we shouldn't print out in pkg/

cmd/oci/oci.go Outdated Show resolved Hide resolved
cmd/oci/oci.go Outdated
@@ -38,6 +38,8 @@ func init() {
OCICmd.Flags().BoolVarP(&dfSwap, "df-swap", "", false, "Modify base images in Dockerfile")
OCICmd.Flags().StringVarP(&tag, "tag", "t", "", "The tag that will be replaced with original tag in Dockerfile")
OCICmd.Flags().StringVar(&path, "path", "", "The path to Dockerfile")
OCICmd.Flags().BoolVar(&digest, "digest", false, "Get the digest of the image")
OCICmd.Flags().StringVar(&auth, "auth", "", "The auth to use to authenticate to the registry")
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use the same flag name as skopeo for now so this should be dest-creds.
Also, please add an example on how to use it in the Long section(for both auth and digest).

func Push(dir, imageName string, digest bool, auth string) error {
var cmd *exec.Cmd
if digest {
cmd = exec.Command("skopeo", "copy", "--insecure-policy", "dir:"+dir, "docker://"+imageName+"@@unknown-digest@@", "--digestfile=bsf-result/digest", "--dest-creds", auth)
Copy link
Contributor

Choose a reason for hiding this comment

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

We can't rely on the directory name being bsf-result. It is configurable by the user.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use dir argument somehow?

cmd/oci/oci.go Outdated
@@ -47,6 +49,7 @@ var OCICmd = &cobra.Command{
Long: `
bsf oci <artifact>
bsf oci <artifact> --platform <platform>
bsf oci <artifact> --push --dest-creds user:password
Copy link
Contributor

Choose a reason for hiding this comment

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

One more example for digest flag.

cmd := exec.Command("nix", "run", "nixpkgs#skopeo", "--", "copy", "--insecure-policy", "dir:"+dir, "docker://"+imageName)
func Push(dir, imageName string, digest bool, destcreds string) error {
var cmd *exec.Cmd
digestPath := strings.Split(dir, "/")[0] + "/digest"
Copy link
Contributor

Choose a reason for hiding this comment

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

can we get the digestPath as an argument? If empty, we do not push by digest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants