Skip to content

Commit 3fb5e43

Browse files
Daniel-Maryniczbeni0888beltran-rubo
authored
Support AuthorizationHeader in OciAPIClient (#8015)
<!-- Before you open the request please review the following guidelines and tips to help it be more easily integrated: - Describe the scope of your change - i.e. what the change does. - Describe any known limitations with your change. - Please run any tests or examples that can exercise your modified code. Thank you for contributing! --> ### Description of the change This should fix #7862 ### Benefits You can work with private helm packages. ### Possible drawbacks None ### Applicable issues <!-- Enter any applicable Issues here (You can reference an issue using #) --> - fixes #7862 ### Additional information <!-- If there's anything else that's important and relevant to your pull request, mention that information here.--> --------- Co-authored-by: Jesús Miguel Benito Calzada <[email protected]> Co-authored-by: Beltran Rueda <[email protected]>
1 parent a966785 commit 3fb5e43

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cmd/asset-syncer/server/utils.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ type OciAPIClient struct {
374374
// aims to work around some of the shortfalls of the OCI Distribution spec
375375
// API
376376
GrpcClient ocicatalog.OCICatalogServiceClient
377+
AuthorizationHeader string
377378
}
378379

379380
func (o *OciAPIClient) getOrasRepoClient(appName string, userAgent string) (*remote.Repository, error) {
@@ -393,6 +394,9 @@ func (o *OciAPIClient) getOrasRepoClient(appName string, userAgent string) (*rem
393394
if userAgent != "" {
394395
header.Set("User-Agent", userAgent)
395396
}
397+
if o.AuthorizationHeader != "" {
398+
header.Set("Authorization", o.AuthorizationHeader)
399+
}
396400
orasRepoClient.Client = &auth.Client{
397401
Client: o.HttpClient,
398402
Cache: auth.DefaultCache,
@@ -916,7 +920,7 @@ func getOCIRepo(namespace, name, repoURL, authorizationHeader string, filter *ap
916920
repositories: ociRepos,
917921
AppRepositoryInternal: &models.AppRepositoryInternal{Namespace: namespace, Name: name, URL: url.String(), AuthorizationHeader: authorizationHeader},
918922
puller: &helm.OCIPuller{Resolver: ociResolver},
919-
ociCli: &OciAPIClient{RegistryNamespaceUrl: url, HttpClient: netClient, GrpcClient: *grpcClient},
923+
ociCli: &OciAPIClient{RegistryNamespaceUrl: url, HttpClient: netClient, GrpcClient: *grpcClient, AuthorizationHeader: authorizationHeader},
920924
filter: filter,
921925
manager: manager,
922926
}, nil

0 commit comments

Comments
 (0)