From 3fb5e4357300be381c3df424a9928e83b15c7166 Mon Sep 17 00:00:00 2001 From: Daniel Marynicz Date: Mon, 23 Dec 2024 17:12:09 +0100 Subject: [PATCH] Support AuthorizationHeader in OciAPIClient (#8015) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Description of the change This should fix /~https://github.com/vmware-tanzu/kubeapps/issues/7862 ### Benefits You can work with private helm packages. ### Possible drawbacks None ### Applicable issues - fixes #7862 ### Additional information --------- Co-authored-by: Jesús Miguel Benito Calzada Co-authored-by: Beltran Rueda --- cmd/asset-syncer/server/utils.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/asset-syncer/server/utils.go b/cmd/asset-syncer/server/utils.go index 38625cc3ea7..f3353afd357 100644 --- a/cmd/asset-syncer/server/utils.go +++ b/cmd/asset-syncer/server/utils.go @@ -374,6 +374,7 @@ type OciAPIClient struct { // aims to work around some of the shortfalls of the OCI Distribution spec // API GrpcClient ocicatalog.OCICatalogServiceClient + AuthorizationHeader string } func (o *OciAPIClient) getOrasRepoClient(appName string, userAgent string) (*remote.Repository, error) { @@ -393,6 +394,9 @@ func (o *OciAPIClient) getOrasRepoClient(appName string, userAgent string) (*rem if userAgent != "" { header.Set("User-Agent", userAgent) } + if o.AuthorizationHeader != "" { + header.Set("Authorization", o.AuthorizationHeader) + } orasRepoClient.Client = &auth.Client{ Client: o.HttpClient, Cache: auth.DefaultCache, @@ -916,7 +920,7 @@ func getOCIRepo(namespace, name, repoURL, authorizationHeader string, filter *ap repositories: ociRepos, AppRepositoryInternal: &models.AppRepositoryInternal{Namespace: namespace, Name: name, URL: url.String(), AuthorizationHeader: authorizationHeader}, puller: &helm.OCIPuller{Resolver: ociResolver}, - ociCli: &OciAPIClient{RegistryNamespaceUrl: url, HttpClient: netClient, GrpcClient: *grpcClient}, + ociCli: &OciAPIClient{RegistryNamespaceUrl: url, HttpClient: netClient, GrpcClient: *grpcClient, AuthorizationHeader: authorizationHeader}, filter: filter, manager: manager, }, nil