Merge pull request #1477 from reasonerjt/dev

fix the 'v2' URL conflict issue, and remove the workaround
This commit is contained in:
Daniel Jiang 2017-02-28 12:43:22 +08:00 committed by GitHub
commit 660fd4a80a
4 changed files with 10 additions and 18 deletions

View File

@ -62,8 +62,8 @@ http {
return 404; return 404;
} }
location ~ ^/v2/(.*)/_trust/(.*) { location /notary/v2/ {
proxy_pass http://notary-server/v2/$$1/_trust/$$2; proxy_pass http://notary-server/v2/;
proxy_set_header Host $$http_host; proxy_set_header Host $$http_host;
proxy_set_header X-Real-IP $$remote_addr; proxy_set_header X-Real-IP $$remote_addr;
proxy_set_header X-Forwarded-For $$proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $$proxy_add_x_forwarded_for;
@ -74,6 +74,7 @@ http {
proxy_buffering off; proxy_buffering off;
proxy_request_buffering off; proxy_request_buffering off;
} }
location /v2/ { location /v2/ {
proxy_pass http://registry/v2/; proxy_pass http://registry/v2/;
proxy_set_header Host $$http_host; proxy_set_header Host $$http_host;

View File

@ -20,7 +20,7 @@
"type": "token", "type": "token",
"options": { "options": {
"realm": "$token_endpoint/service/token", "realm": "$token_endpoint/service/token",
"service": "harbor-registry", "service": "harbor-notary",
"issuer": "harbor-token-issuer", "issuer": "harbor-token-issuer",
"rootcertbundle": "/config/root.crt" "rootcertbundle": "/config/root.crt"
} }

View File

@ -62,10 +62,7 @@ func InitCreators() {
service: registry, service: registry,
filterMap: map[string]accessFilter{ filterMap: map[string]accessFilter{
"repository": &repositoryFilter{ "repository": &repositoryFilter{
//Workaround, had to use same service for both notary and registry parser: &basicParser{},
parser: &endpointParser{
endpoint: ext,
},
}, },
"registry": &registryFilter{}, "registry": &registryFilter{},
}, },
@ -102,15 +99,10 @@ func (e endpointParser) parse(s string) (*image, error) {
if len(repo) < 2 { if len(repo) < 2 {
return nil, fmt.Errorf("Unable to parse image from string: %s", s) return nil, fmt.Errorf("Unable to parse image from string: %s", s)
} }
//Workaround, need to use endpoint Parser to handle both cases. if repo[0] != e.endpoint {
if strings.ContainsRune(repo[0], '.') { return nil, fmt.Errorf("Mismatch endpoint from string: %s, expected endpoint: %s", s, e.endpoint)
if repo[0] != e.endpoint {
log.Warningf("Mismatch endpoint from string: %s, expected endpoint: %s, fallback to basic parser", s, e.endpoint)
return parseImg(s)
}
return parseImg(repo[1])
} }
return parseImg(s) return parseImg(repo[1])
} }
//build Image accepts a string like library/ubuntu:14.04 and build a image struct //build Image accepts a string like library/ubuntu:14.04 and build a image struct

View File

@ -169,9 +169,8 @@ func TestEndpointParser(t *testing.T) {
} }
testList := []parserTestRec{parserTestRec{"10.117.4.142:5000/library/ubuntu:14.04", image{"library", "ubuntu", "14.04"}, false}, testList := []parserTestRec{parserTestRec{"10.117.4.142:5000/library/ubuntu:14.04", image{"library", "ubuntu", "14.04"}, false},
parserTestRec{"myimage:14.04", image{}, true}, parserTestRec{"myimage:14.04", image{}, true},
//Test the temp workaround parserTestRec{"10.117.4.142:80/library/myimage:14.04", image{}, true},
parserTestRec{"10.117.4.142:80/library/myimage:14.04", image{"10.117.4.142:80", "library/myimage", "14.04"}, false}, parserTestRec{"library/myimage:14.04", image{}, true},
parserTestRec{"library/myimage:14.04", image{"library", "myimage", "14.04"}, false},
parserTestRec{"10.117.4.142:5000/myimage:14.04", image{}, true}, parserTestRec{"10.117.4.142:5000/myimage:14.04", image{}, true},
parserTestRec{"10.117.4.142:5000/org/team/img", image{"org", "team/img", ""}, false}, parserTestRec{"10.117.4.142:5000/org/team/img", image{"org", "team/img", ""}, false},
} }