mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-24 17:47:46 +01:00
Merge remote-tracking branch 'upstream/new-ui-with-sync-image' into author
This commit is contained in:
commit
19454bca74
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -59,19 +59,13 @@
|
||||
<div class="form-group col-md-12 form-group-custom">
|
||||
<label for="username" class="col-md-3 control-label">// 'username' | tr //:</label>
|
||||
<div class="col-md-9">
|
||||
<input type="text" class="form-control" id="username" ng-model="replication.destination.username" name="uUsername" ng-value="vm.username" required ng-disabled="!vm.targetEditable">
|
||||
<div ng-messages="form.$submitted && form.uUsername.$error">
|
||||
<span ng-message="required">// 'username_is_required' | tr //</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" id="username" ng-model="replication.destination.username" name="uUsername" ng-value="vm.username" ng-disabled="!vm.targetEditable">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-12 form-group-custom">
|
||||
<label for="password" class="col-md-3 control-label">// 'password' | tr //:</label>
|
||||
<div class="col-md-9">
|
||||
<input type="password" class="form-control" id="password" ng-model="replication.destination.password" name="uPassword" ng-value="vm.password" required ng-disabled="!vm.targetEditable">
|
||||
<div ng-messages="form.$submitted && form.uPassword.$error">
|
||||
<span ng-message="required">// 'password_is_required' | tr //</span>
|
||||
</div>
|
||||
<input type="password" class="form-control" id="password" ng-model="replication.destination.password" name="uPassword" ng-value="vm.password" ng-disabled="!vm.targetEditable">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-12 form-group-custom">
|
||||
|
@ -29,19 +29,13 @@
|
||||
<div class="form-group col-md-12 form-group-custom">
|
||||
<label for="username" class="col-md-3 control-label">// 'username' | tr //:</label>
|
||||
<div class="col-md-9">
|
||||
<input type="text" class="form-control" id="username" ng-model="destination.username" name="uUsername" required ng-disabled="!vm.editable">
|
||||
<div ng-messages="form.$submitted && form.uUsername.$error">
|
||||
<span ng-message="required">// 'username_is_required' | tr //</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" id="username" ng-model="destination.username" name="uUsername" ng-disabled="!vm.editable">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-12 form-group-custom">
|
||||
<label for="password" class="col-md-3 control-label">// 'password' | tr //:</label>
|
||||
<div class="col-md-9">
|
||||
<input type="password" class="form-control" id="password" ng-model="destination.password" name="uPassword" required ng-disabled="!vm.editable">
|
||||
<div ng-messages="form.$submitted && form.uPassword.$error">
|
||||
<span ng-message="required">// 'password_is_required' | tr //</span>
|
||||
</div>
|
||||
<input type="password" class="form-control" id="password" ng-model="destination.password" name="uPassword" ng-disabled="!vm.editable">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-12 form-group-custom">
|
||||
|
@ -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,19 +72,22 @@ 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)
|
||||
for len(suffix) > 0 {
|
||||
url = r.Endpoint.String() + suffix
|
||||
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
return repos, err
|
||||
}
|
||||
|
||||
resp, err := r.client.Do(req)
|
||||
if err != nil {
|
||||
return repos, parseError(err)
|
||||
return nil, parseError(err)
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return repos, err
|
||||
@ -101,16 +102,23 @@ func (r *Registry) Catalog() ([]string, error) {
|
||||
return repos, err
|
||||
}
|
||||
|
||||
repos = catalogResp.Repositories
|
||||
|
||||
return repos, nil
|
||||
repos = append(repos, catalogResp.Repositories...)
|
||||
//Link: </v2/_catalog?last=library%2Fhello-world-25&n=100>; 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 ...
|
||||
func (r *Registry) Ping() error {
|
||||
@ -140,7 +148,3 @@ func (r *Registry) Ping() error {
|
||||
Detail: string(b),
|
||||
}
|
||||
}
|
||||
|
||||
func buildCatalogURL(endpoint string) string {
|
||||
return fmt.Sprintf("%s/v2/_catalog", endpoint)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user