Skip to content

Commit

Permalink
Support AuthorizationHeader in OciAPIClient (#8015)
Browse files Browse the repository at this point in the history
<!--
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 <jesus.benito@broadcom.com>
Co-authored-by: Beltran Rueda <beltranrueda@vmware.com>
  • Loading branch information
3 people authored Dec 23, 2024
1 parent a966785 commit 3fb5e43
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/asset-syncer/server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3fb5e43

Please sign in to comment.