diff --git a/job/replication/delete.go b/job/replication/delete.go index 8bf7813f8..1bec6378f 100644 --- a/job/replication/delete.go +++ b/job/replication/delete.go @@ -62,8 +62,8 @@ func NewDeleter(repository string, tags []string, dstURL, dstUsr, dstPwd string, dstClient: dstClient, logger: logger, } - deleter.logger.Infof("initialization completed: repository: %s, tags: %v, destination URL: %s, destination user: %s", - deleter.repository, deleter.tags, deleter.dstURL, deleter.dstUsr) + deleter.logger.Infof("initialization completed: repository: %s, tags: %v, destination URL: %s, insecure: %v, destination user: %s", + deleter.repository, deleter.tags, deleter.dstURL, deleter.insecure, deleter.dstUsr) return deleter, nil } diff --git a/job/replication/transfer.go b/job/replication/transfer.go index 30bbf88ae..dd2fba546 100644 --- a/job/replication/transfer.go +++ b/job/replication/transfer.go @@ -80,8 +80,8 @@ type BaseHandler struct { func InitBaseHandler(repository, srcURL, srcSecret, dstURL, dstUsr, dstPwd string, insecure bool, tags []string, logger *log.Logger) (*BaseHandler, error) { - logger.Infof("initializing: repository: %s, tags: %v, source URL: %s, destination URL: %s, destination user: %s", - repository, tags, srcURL, dstURL, dstUsr) + logger.Infof("initializing: repository: %s, tags: %v, source URL: %s, destination URL: %s, insecure: %v, destination user: %s", + repository, tags, srcURL, dstURL, insecure, dstUsr) base := &BaseHandler{ repository: repository, @@ -90,6 +90,7 @@ func InitBaseHandler(repository, srcURL, srcSecret, dstURL: dstURL, dstUsr: dstUsr, dstPwd: dstPwd, + insecure: insecure, blobsExistence: make(map[string]bool, 10), logger: logger, } @@ -102,6 +103,7 @@ func InitBaseHandler(repository, srcURL, srcSecret, srcClient, err := newRepositoryClient(base.srcURL, base.insecure, srcCred, base.repository, "repository", base.repository, "pull", "push", "*") if err != nil { + base.logger.Errorf("an error occurred while creating source repository client: %v", err) return nil, err } base.srcClient = srcClient @@ -110,6 +112,7 @@ func InitBaseHandler(repository, srcURL, srcSecret, dstClient, err := newRepositoryClient(base.dstURL, base.insecure, dstCred, base.repository, "repository", base.repository, "pull", "push", "*") if err != nil { + base.logger.Errorf("an error occurred while creating destination repository client: %v", err) return nil, err } base.dstClient = dstClient @@ -117,13 +120,14 @@ func InitBaseHandler(repository, srcURL, srcSecret, if len(base.tags) == 0 { tags, err := base.srcClient.ListTag() if err != nil { + base.logger.Errorf("an error occurred while listing tags for source repository: %v", err) return nil, err } base.tags = tags } - base.logger.Infof("initialization completed: project: %s, repository: %s, tags: %v, source URL: %s, destination URL: %s, destination user: %s", - base.project, base.repository, base.tags, base.srcURL, base.dstURL, base.dstUsr) + base.logger.Infof("initialization completed: project: %s, repository: %s, tags: %v, source URL: %s, destination URL: %s, insecure: %v, destination user: %s", + base.project, base.repository, base.tags, base.srcURL, base.dstURL, base.insecure, base.dstUsr) return base, nil } diff --git a/static/resources/js/components/replication/create-policy.directive.html b/static/resources/js/components/replication/create-policy.directive.html index 75fd8f35d..e08982861 100644 --- a/static/resources/js/components/replication/create-policy.directive.html +++ b/static/resources/js/components/replication/create-policy.directive.html @@ -59,19 +59,13 @@
- -
- // 'username_is_required' | tr // -
+
- -
- // 'password_is_required' | tr // -
+
@@ -89,4 +83,4 @@
- \ No newline at end of file + diff --git a/static/resources/js/components/system-management/create-destination.directive.html b/static/resources/js/components/system-management/create-destination.directive.html index 9f1e59140..07339d306 100644 --- a/static/resources/js/components/system-management/create-destination.directive.html +++ b/static/resources/js/components/system-management/create-destination.directive.html @@ -29,19 +29,13 @@
- -
- // 'username_is_required' | tr // -
+
- -
- // 'password_is_required' | tr // -
+
@@ -59,4 +53,4 @@
- \ No newline at end of file + diff --git a/utils/registry/registry.go b/utils/registry/registry.go index 75ad5bfa3..05ec2c33e 100644 --- a/utils/registry/registry.go +++ b/utils/registry/registry.go @@ -3,9 +3,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,10 +16,10 @@ package registry import ( "crypto/tls" "encoding/json" - "fmt" "io/ioutil" "net/http" "net/url" + "strings" registry_error "github.com/vmware/harbor/utils/registry/error" "github.com/vmware/harbor/utils/registry/utils" @@ -74,42 +72,52 @@ func NewRegistryWithModifiers(endpoint string, insecure bool, modifiers ...Modif // Catalog ... func (r *Registry) Catalog() ([]string, error) { repos := []string{} + suffix := "/v2/_catalog?n=1000" + var url string - req, err := http.NewRequest("GET", buildCatalogURL(r.Endpoint.String()), nil) - if err != nil { - return repos, err - } + for len(suffix) > 0 { + url = r.Endpoint.String() + suffix - resp, err := r.client.Do(req) - if err != nil { - return repos, parseError(err) - } + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return repos, err + } + resp, err := r.client.Do(req) + if err != nil { + return nil, parseError(err) + } - defer resp.Body.Close() - - b, err := ioutil.ReadAll(resp.Body) - if err != nil { - return repos, err - } - - if resp.StatusCode == http.StatusOK { - catalogResp := struct { - Repositories []string `json:"repositories"` - }{} - - if err := json.Unmarshal(b, &catalogResp); err != nil { + defer resp.Body.Close() + b, err := ioutil.ReadAll(resp.Body) + if err != nil { return repos, err } - repos = catalogResp.Repositories + if resp.StatusCode == http.StatusOK { + catalogResp := struct { + Repositories []string `json:"repositories"` + }{} - return repos, nil - } + if err := json.Unmarshal(b, &catalogResp); err != nil { + return repos, err + } - return repos, ®istry_error.Error{ - StatusCode: resp.StatusCode, - Detail: string(b), + repos = append(repos, catalogResp.Repositories...) + //Link: ; rel="next" + link := resp.Header.Get("Link") + if strings.HasSuffix(link, `rel="next"`) && strings.Index(link, "<") >= 0 && strings.Index(link, ">") >= 0 { + suffix = link[strings.Index(link, "<")+1 : strings.Index(link, ">")] + } else { + suffix = "" + } + } else { + return repos, ®istry_error.Error{ + StatusCode: resp.StatusCode, + Detail: string(b), + } + } } + return repos, nil } // Ping ... @@ -140,7 +148,3 @@ func (r *Registry) Ping() error { Detail: string(b), } } - -func buildCatalogURL(endpoint string) string { - return fmt.Sprintf("%s/v2/_catalog", endpoint) -}