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

Set Registry Server Name #465

Merged
merged 10 commits into from
Jan 27, 2023
Merged

Set Registry Server Name #465

merged 10 commits into from
Jan 27, 2023

Conversation

guineveresaenger
Copy link
Contributor

@guineveresaenger guineveresaenger commented Jan 24, 2023

This PR adds support for not requiring the registry server name to be explicitly set.
Instead, we make a good faith attempt to infer it from the fully qualified image name, giving some basic error messages.
Additionally, some special case handling for Dockerhub is included - if we wanted to push to Dockerhub by default, this is where we could set that.

Fixes #466

  • Adds logic to parse registry name from a fully qualified image name.
  • Do not require registry:server
  • Re-generate schema
  • Re-generate SDKs

The new `getRegistryAddr` will supply the web address of the registry
server for the purpose of looking up the registry auth in the host
machine's docker config.
When a registryServer is not supplied, the `getRegistryAddr` function
will attempt to parse the registry server address from the fully
qualified image name.
It will handle some special case logic around
Dockerhub as well.
With the logic atted to image.go, the user no longer needs to explicitly
set the registry server name, as it can be inferred from a fully
qualified registry image name.
We updated a few versions, so a new schema is in order.
@guineveresaenger guineveresaenger changed the title Set Registry Server Naem Set Registry Server Name Jan 24, 2023
@guineveresaenger guineveresaenger self-assigned this Jan 24, 2023
@github-actions
Copy link

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

@guineveresaenger guineveresaenger requested a review from a team January 24, 2023 00:27
provider/image.go Show resolved Hide resolved
provider/image.go Show resolved Hide resolved
provider/image_test.go Show resolved Hide resolved
@github-actions
Copy link

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

@AaronFriel AaronFriel requested a review from iwahbe January 24, 2023 18:58
@github-actions
Copy link

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

Copy link
Member

@iwahbe iwahbe left a comment

Choose a reason for hiding this comment

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

I'm not deep into the space, but the semantics look good to me. I left a couple of nits to address before merging.

provider/image.go Outdated Show resolved Hide resolved
return "https://index.docker.io/v1/", nil
}
// we need the full server address for the lookup
serverAddr = "https://" + addr
Copy link
Member

Choose a reason for hiding this comment

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

Is it ever valid for addr to start with https:// or http:// or some other url prefix? Should we error if addr starts with http(s?)://, or should we trim it?

Especially considering L466-471.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The https:// is being added for the purpose of looking up the registry from the host docker config and we should not trim it.

As far as I know, with the special snowflake exception of docker.io there is no other url prefix that is valid here. The else block is a best effort attempt to make sure we can always look up the registry from the host config if necessary, since including it is always valid.

Comment on lines 472 to 473
// TODO: this is where we would default to Docker if we wanted to do so.
// A valid registry address includes a `.` so we could add additional helper checks here.
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to default to docker? If we're going to check in a TODO, it would be great to have the TODO associated with an issue.

Uses the
https://github.com/distribution/distribution/blob/main/reference/reference.go
package to verify correct format of a fully qualified image name. Note
that this does not verify the registry itslef; only that the image name
has valid format.
Additionally, adds error message to clarify a fully qualified image name
is required in all cases, which should catch anyone trying to use
Dockerhub shortnames..
@github-actions
Copy link

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

1 similar comment
@github-actions
Copy link

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

provider/image.go Outdated Show resolved Hide resolved
Also improves the output for the error message, removing the print
statement and wrapping the error instead.
@github-actions
Copy link

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

@guineveresaenger guineveresaenger merged commit b929d2b into master Jan 27, 2023
@guineveresaenger guineveresaenger deleted the registry-address branch January 27, 2023 00:31
@AaronFriel AaronFriel added this to the 0.84 milestone Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default Dockerhub behavior
3 participants