diff --git a/src/replication/adapter/huawei/huawei_adapter.go b/src/replication/adapter/huawei/huawei_adapter.go index 7d647176b..b9362fc3c 100644 --- a/src/replication/adapter/huawei/huawei_adapter.go +++ b/src/replication/adapter/huawei/huawei_adapter.go @@ -45,6 +45,10 @@ type adapter struct { *native.Adapter registry *model.Registry 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 @@ -243,15 +247,19 @@ func newAdapter(registry *model.Registry) (adp.Adapter, error) { modifiers = append(modifiers, authorizer) } + transport := util.GetHTTPTransport(registry.Insecure) return &adapter{ Adapter: dockerRegistryAdapter, registry: registry, client: common_http.NewClient( &http.Client{ - Transport: util.GetHTTPTransport(registry.Insecure), + Transport: transport, }, modifiers..., ), + oriClient: &http.Client{ + Transport: transport, + }, }, nil } diff --git a/src/replication/adapter/huawei/image_registry.go b/src/replication/adapter/huawei/image_registry.go index 3738ea2e0..fa4be6eab 100644 --- a/src/replication/adapter/huawei/image_registry.go +++ b/src/replication/adapter/huawei/image_registry.go @@ -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("Authorization", "Bearer "+token.Token) - resp, err := a.client.Do(r) + resp, err := a.oriClient.Do(r) if err != nil { 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("Authorization", "Bearer "+token.Token) - resp, err := a.client.Do(r) + resp, err := a.oriClient.Do(r) if err != nil { return err }