mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-19 15:17:43 +01:00
Merge pull request #9887 from chlins/fix/replication-huawei-adapter-authorization
fix(replication): huawei adapter multi authorization
This commit is contained in:
commit
8809b7aa5d
@ -45,6 +45,10 @@ type adapter struct {
|
|||||||
*native.Adapter
|
*native.Adapter
|
||||||
registry *model.Registry
|
registry *model.Registry
|
||||||
client *common_http.Client
|
client *common_http.Client
|
||||||
|
// original http client with no modifer,
|
||||||
|
// huawei's some api interface with basic authorization,
|
||||||
|
// some with bearer token authorization.
|
||||||
|
oriClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// Info gets info about Huawei SWR
|
// Info gets info about Huawei SWR
|
||||||
@ -243,15 +247,19 @@ func newAdapter(registry *model.Registry) (adp.Adapter, error) {
|
|||||||
modifiers = append(modifiers, authorizer)
|
modifiers = append(modifiers, authorizer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
transport := util.GetHTTPTransport(registry.Insecure)
|
||||||
return &adapter{
|
return &adapter{
|
||||||
Adapter: dockerRegistryAdapter,
|
Adapter: dockerRegistryAdapter,
|
||||||
registry: registry,
|
registry: registry,
|
||||||
client: common_http.NewClient(
|
client: common_http.NewClient(
|
||||||
&http.Client{
|
&http.Client{
|
||||||
Transport: util.GetHTTPTransport(registry.Insecure),
|
Transport: transport,
|
||||||
},
|
},
|
||||||
modifiers...,
|
modifiers...,
|
||||||
),
|
),
|
||||||
|
oriClient: &http.Client{
|
||||||
|
Transport: transport,
|
||||||
|
},
|
||||||
}, nil
|
}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ func (a *adapter) ManifestExist(repository, reference string) (exist bool, diges
|
|||||||
r.Header.Add("content-type", "application/json; charset=utf-8")
|
r.Header.Add("content-type", "application/json; charset=utf-8")
|
||||||
r.Header.Add("Authorization", "Bearer "+token.Token)
|
r.Header.Add("Authorization", "Bearer "+token.Token)
|
||||||
|
|
||||||
resp, err := a.client.Do(r)
|
resp, err := a.oriClient.Do(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return exist, digest, err
|
return exist, digest, err
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ func (a *adapter) DeleteManifest(repository, reference string) error {
|
|||||||
r.Header.Add("content-type", "application/json; charset=utf-8")
|
r.Header.Add("content-type", "application/json; charset=utf-8")
|
||||||
r.Header.Add("Authorization", "Bearer "+token.Token)
|
r.Header.Add("Authorization", "Bearer "+token.Token)
|
||||||
|
|
||||||
resp, err := a.client.Do(r)
|
resp, err := a.oriClient.Do(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user