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

fix: pass global args to all crane invocations #709

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ahans
Copy link

@ahans ahans commented Oct 4, 2024

This fixes #527. Please let me know if I missed anything. Thanks!

@thesayyn
Copy link
Collaborator

thesayyn commented Oct 4, 2024

this change looks like a breaking change, before args are passed only to crane push, but now args are passed to every subcommand.

principled fix for this is to only pass global flags to all by plucking them out of args first.

@ahans
Copy link
Author

ahans commented Oct 4, 2024

this change looks like a breaking change, before args are passed only to crane push, but now args are passed to every subcommand.

principled fix for this is to only pass global flags to all by plucking them out of args first.

I see, so you only want to pass on the following flags?

Global Flags:
      --allow-nondistributable-artifacts   Allow pushing non-distributable (foreign) layers
      --insecure                           Allow image references to be fetched without TLS
      --platform platform                  Specifies the platform in the form os/arch[/variant][:osversion] (e.g. linux/amd64). (default all)
  -v, --verbose                            Enable debug logs

TBH, I found it a bit surprising that one is supposed to use args = ["--insecure"] to support repositories whose certificate can't be validated. I would prefer an explicit flag such as insecure_repository as we had with rules_docker. I'm not sure if it's such a good idea to allow the user to pass flags to crane. Isn't usage of crane an implementation detail here? Anyway, I'm happy to implement the approach above that filters out global flags, but would like to understand the motivation for this design first. What are other usecases for passing in args?

@thesayyn
Copy link
Collaborator

args something bazel adds support for runnable rules by default and there is no way to disable it. Also, crane is not implementation detail for oci_push unfortunately, we have supported passing arbitrary args to oci_push since the beginning of rules_oci.

@thesayyn
Copy link
Collaborator

I would prefer an explicit flag such as insecure_repository as we had with rules_docker

Not every flag deserves its own attribute, if it translates 1:1 to the underlying tool, if we did support something like this then there would be two different way of getting the same outcome, eg: args and insecure_repository and we'd have to maintain both and resolve conflicts if args = ["--insecure"] and insecure = True|False. I'd rather keep it simple and just pass all the global flags to all crane invocations.

@ahans ahans force-pushed the bugfix/always-pass-args-to-crane-in-push branch 2 times, most recently from 8b4d9dd to 465e2c2 Compare October 17, 2024 14:15
@ahans
Copy link
Author

ahans commented Oct 17, 2024

Ok, I think disabling args support would be the cleanest solution here. But since that's not possible and we want to maintain backwards compatibility, allowing users to pass everything via args makes sense. Thanks for the explanation, that helps a lot!

I updated the PR now to put all global flags into a GLOBAL_FLAGS list and pass that separately to each crane invocation. Since --verbose (or -v) is just one of those special global flags, I removed the special handling for that. I hope it's better now! Looking forward to your review!

@ahans ahans force-pushed the bugfix/always-pass-args-to-crane-in-push branch from 465e2c2 to e6e6e9b Compare October 18, 2024 11:22
@ahans
Copy link
Author

ahans commented Oct 21, 2024

Anything I can do about the test failure? Looks like some infrastructure issue ...

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.

oci_push with remote_tags does not work with insecure repositories
2 participants