Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
Signed-off-by: Lixia (Sylvia) Lei <[email protected]>
  • Loading branch information
Wwwsylvia committed Sep 25, 2023
1 parent c0cff95 commit ff87cba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions registry/remote/auth/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (c *Client) Do(originalReq *http.Request) (*http.Response, error) {
req.Header.Set("Authorization", "Basic "+token)
}
case SchemeBearer:
// merge per-host scopes with generic scopes
// merge per-host scopes with global scopes
scopes := GetScopesForHost(ctx, host)
if moreScopes := GetScopes(ctx); len(moreScopes) > 0 {
scopes = append(scopes, moreScopes...)
Expand Down Expand Up @@ -231,7 +231,7 @@ func (c *Client) Do(originalReq *http.Request) (*http.Response, error) {
scopes := GetScopesForHost(ctx, host)
cleanScopeLen := len(scopes)
if moreScopes := GetScopes(ctx); len(moreScopes) > 0 {
// merge per-host scopes with generic scopes
// merge per-host scopes with global scopes
scopes = append(scopes, moreScopes...)
}
if paramScope := params["scope"]; paramScope != "" {
Expand Down
3 changes: 2 additions & 1 deletion registry/remote/auth/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ func AppendScopesForHost(ctx context.Context, host string, scopes ...string) con
return WithScopesForHost(ctx, host, append(oldScopes, scopes...)...)
}

// GetScopesForHost returns the scopes in the context for the given host.
// GetScopesForHost returns the scopes in the context for the given host,
// excluding the global scopes added by [WithScopes] and [AppendScopes].
func GetScopesForHost(ctx context.Context, host string) []string {
if scopes, ok := ctx.Value(scopesForHostContextKey(host)).([]string); ok {
return slices.Clone(scopes)
Expand Down

0 comments on commit ff87cba

Please sign in to comment.