Skip to content

Conversation

@saschagrunert
Copy link
Member

@saschagrunert saschagrunert commented Jun 28, 2021

This patch adds support for host[:port]/ns/…repo to auth.json while keeping the backwards compatible behavior.

Refers to #1276

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

I think we should walk the path. Let's assume we pull quay.io/repo/image:tag, I'd like the code to be able to find the following credentials in order:

  • quay.io/repo/image
  • quay.io/repo (to separate credentials for different users)
  • quay.io (also to remain backwards compat)

@saschagrunert saschagrunert changed the title RFC: Add support for registry paths in auth.json Add support for registry paths in auth.json Jun 28, 2021
Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

We’ll also need the write path (login/logout). Is that expected to be a separate PR? (That’s fine if so, this PR is big enough already — just to make sure this is on the radar.)

Note to self: Only skimmed the tests for now.

@saschagrunert
Copy link
Member Author

We’ll also need the write path (login/logout). Is that expected to be a separate PR? (That’s fine if so, this PR is big enough already — just to make sure this is on the radar.)

Yes, let's follow-up on this one in another PR.

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

WIP, to shorten the iteration cycle.

Overall looks good, I still need to read the tests.

v1Res := &V1Results{}

// Get credentials from authfile for the underlying hostname
// nolint: staticcheck
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a way to silence that specific warning and not everything from that linter?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, by adding a custom rules go .golangci.yml. Changed to use that instead of the comment.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ouch, that‘s worse than silencing the checker, and the ideal fix doesn’t work: golangci/golangci-lint#741

I have ended up with

	//lint:ignore SA1019 We can't use GetCredentialsForRef because we want to search the whole registry.
	auth, err := config.GetCredentials(sys, registry) //nolint:staticcheck // https://github.com/golangci/golangci-lint/issues/741

so that both a direct invocation of staticcheck and use via golangci-lint don’t complain.

Copy link
Member Author

@saschagrunert saschagrunert Jun 30, 2021

Choose a reason for hiding this comment

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

Fixed, thank you for your suggestion.

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

A full review now.

Still checking for URLs even if the caller submits a ref (because the primary caller is going to always submit one) is the only non-trivial concern, the rest is just nits and small cleanups.

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM

This patch adds support for `host[:port]/ns/…repo` to auth.json while
keeping the backwards compatible behavior.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Thanks!

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.

3 participants