-
Notifications
You must be signed in to change notification settings - Fork 18.6k
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
Cleanup: Replace ResolveRepositoryName with RepositoryInfo{} #8456
Conversation
Pretty big commit :/ |
Also |
Fix for TestSearchOnCentralRegistry committed |
I hope that +700 lines of code is mostly because of tests :) |
+522 -53 lines are from tests ;) |
@dkjer Hehe, now we have panic in tests :) |
for _, name := range names { | ||
pullCmd := exec.Command(dockerBinary, "pull", name) | ||
out, exitCode, err := runCommandWithOutput(pullCmd) | ||
errorOut(err, t, fmt.Sprintf("%s %s", out, err)) |
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.
just a note, we removed the errorOut()
function in a cleanup PR
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.
Thanks @jfrazelle I have updated the PR
@dkjer needs a rebase :) |
@tiborvass rebased |
I like this change as well after a quick glance through. I will give it a more thorough look later in the week. |
@@ -35,7 +35,7 @@ const ( | |||
ConnectTimeout | |||
) | |||
|
|||
func newClient(jar http.CookieJar, roots *x509.CertPool, cert *tls.Certificate, timeout TimeoutType) *http.Client { | |||
var newClient = func(jar http.CookieJar, roots *x509.CertPool, cert *tls.Certificate, timeout TimeoutType) *http.Client { |
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.
Is this intentional?
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.
Yes, that was needed for wrapping newClient calls during tests.
See registry_mock_test.go func useInsecureHttpsClient()
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.
k, thanks for pointing me there
// First try the happy case | ||
if c, found := config.Configs[hostname]; found { | ||
if c, found := config.Configs[configKey]; found || repoInfo.IsOfficialIndex { |
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.
When is found false while IsOfficialIndex is true and why return an empty config in that case?
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.
This was just to preserve the existing behavior. If we are using the IndexServerAddress we return Configs[IndexServerAddress()] even if it is empty:
func (config *ConfigFile) ResolveAuthConfig(hostname string) AuthConfig {
if hostname == IndexServerAddress() || len(hostname) == 0 {
// default to the index server
return config.Configs[IndexServerAddress()]
}
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 thought perhaps you understood why that is the behavior. I agree there is no behavior change and no need to address further.
This is great. The |
Yes, we should. Separation of naming and transport: what was floated around before was going with something like In that scenario, mirroring suddenly becomes trivial (from a client perspective). Also, this opens the door for different transport types, eg:
Indeed, let's get to a proposal. |
There is a pull behavioral change with this PR. Before the name as given on the command line is used as the local name of the repository, now the name is always canonicalized and that is used locally. The effect being |
@dkjer careful with --insecure-registry - it's a problematic flag in its current state (ping @tiborvass @proppy ) ping @dmcgowan for additional review |
Also relevant: #8887 |
@dmp42 Yeah, --insecure-registry was also missing tests (everything passed, before reimplementing). I tried to just preserve existing functionality; however this sets me up to resolve conflicts for each --insecure-registry change that happens |
log.Fatal(err) | ||
} | ||
|
||
// load registry service |
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.
Could the original flow stay the same, Register + Install and rather just update the Install call to
registry.NewService(registryCfg).Install(eng)
. This would keep builtins from needing to be changed and match the refactor change from the linked commit.
@jfrazelle @tiborvass wanted to test this thoroughly because we almost have no tests for registry. |
ah cool carry on :) On Mon, Dec 22, 2014 at 9:22 PM, Alexander Morozov <notifications@github.com
|
@@ -232,6 +738,7 @@ func TestSearchRepositories(t *testing.T) { | |||
assertEqual(t, results.Results[0].StarCount, 42, "Expected 'fakeimage' a ot hae 42 stars") | |||
} | |||
|
|||
<<<<<<< HEAD |
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.
@dkjer bad rebase :)
Passing RepositoryInfo to ResolveAuthConfig, pullRepository, and pushRepository Moving --registry-mirror configuration to registry config Created resolve_repository job Repo names with 'index.docker.io' or 'docker.io' are now synonymous with omitting an index name. Adding test for RepositoryInfo Adding tests for opts.StringSetOpts and registry.ValidateMirror Fixing search term use of repoInfo Adding integration tests for registry mirror configuration Normalizing LookupImage image name to match LocalName parsing rules Normalizing repository LocalName to avoid multiple references to an official image Removing errorOut use in tests Removing TODO comment gofmt changes golint comments cleanup. renaming RegistryOptions => registry.Options, and RegistryServiceConfig => registry.ServiceConfig Splitting out builtins.Registry and registry.NewService calls Stray whitespace cleanup Moving integration tests for Mirrors and InsecureRegistries into TestNewIndexInfo unit test Factoring out ValidateRepositoryName from NewRepositoryInfo Removing unused IndexServerURL Allowing json marshaling of ServiceConfig. Exposing ServiceConfig in /info Switching to CamelCase for json marshaling PR cleanup; removing 'Is' prefix from boolean members. Removing unneeded json tags. Removing non-cleanup related fix for 'localhost:[port]' in splitReposName Merge fixes for gh9735 Fixing integration test Reapplying #9754 Adding comment on config.IndexConfigs use from isSecureIndex Remove unused error return value from isSecureIndex Signed-off-by: Don Kjer <don.kjer@gmail.com> Adding back comment in isSecureIndex Signed-off-by: Don Kjer <don.kjer@gmail.com>
…nfig.go Signed-off-by: Don Kjer <don.kjer@gmail.com>
LGTM Tested locally, cause drone doesn't like go1.3 syntax since it's using go1.4 gofmt. |
Signed-off-by: Don Kjer <don.kjer@gmail.com>
Haha, drone is happy. |
Cleanup: Replace ResolveRepositoryName with RepositoryInfo{}
Thanks so much @dkjer for your awesome contribution and infinite patience! Happy new year :) |
Reason for cleanup
Currently, we breakdown a repository name using a combination of ResolveRepositoryName, and NewEndpoint as follows:
However, policies around whether or not repository is using the 'official index' or an 'official repository' are sprinkled throughout the code. Also, rules regarding remoteName for the official repositories ('library/ prefix'), localName, which mirrors to use, etc, are also sprinkled throughout the code.
This results in awkward follow-up checks against repository names, such as
Having to track down these pieces of logic throughout the code makes modifications to repository name parsing fragile, and hard to test.
Refactors made
ResolveRepositoryName(repoName) deprecated.
Replaced with the following:
RepositoryInfo
Returned by ParseRepositoryInfo, or ResolveRepositoryInfo.