-
Notifications
You must be signed in to change notification settings - Fork 114
/
creds.go
34 lines (29 loc) · 1.15 KB
/
creds.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package image
import "net/url"
// Credentials represents the credentials for connecting to a private image
// repository. It implements the
// distribution/V3/registry/client/auth.CredentialStore interface.
type Credentials struct {
// Username identifies a principal, which combined with the value of the
// Password field, can be used for reading from some image repository.
Username string
// Password, when combined with the principal identified by the Username
// field, can be used for reading from some image repository.
Password string
refreshTokens map[string]string
}
// Basic implements distribution/V3/registry/client/auth.CredentialStore.
func (c Credentials) Basic(*url.URL) (string, string) {
return c.Username, c.Password
}
// RefreshToken implements distribution/V3/registry/client/auth.CredentialStore.
func (c Credentials) RefreshToken(_ *url.URL, service string) string {
return c.refreshTokens[service]
}
// SetRefreshToken implements
// distribution/V3/registry/client/auth.CredentialStore.
func (c Credentials) SetRefreshToken(_ *url.URL, service, token string) {
if c.refreshTokens != nil {
c.refreshTokens[service] = token
}
}