reduce scope of DockerConfigEntryWithAuth
This commit is contained in:
parent
5458f05679
commit
72c0709f18
@ -147,9 +147,9 @@ func readDockerConfigFileFromBytes(contents []byte) (cfg DockerConfig, err error
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// DockerConfigEntryWithAuth is used solely for deserializing the Auth field
|
// dockerConfigEntryWithAuth is used solely for deserializing the Auth field
|
||||||
// into a dockerConfigEntry during JSON deserialization.
|
// into a dockerConfigEntry during JSON deserialization.
|
||||||
type DockerConfigEntryWithAuth struct {
|
type dockerConfigEntryWithAuth struct {
|
||||||
Username string `json:"username,omitempty"`
|
Username string `json:"username,omitempty"`
|
||||||
Password string `json:"password,omitempty"`
|
Password string `json:"password,omitempty"`
|
||||||
Email string `json:"email,omitempty"`
|
Email string `json:"email,omitempty"`
|
||||||
@ -157,7 +157,7 @@ type DockerConfigEntryWithAuth struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ident *DockerConfigEntry) UnmarshalJSON(data []byte) error {
|
func (ident *DockerConfigEntry) UnmarshalJSON(data []byte) error {
|
||||||
var tmp DockerConfigEntryWithAuth
|
var tmp dockerConfigEntryWithAuth
|
||||||
err := json.Unmarshal(data, &tmp)
|
err := json.Unmarshal(data, &tmp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -195,8 +195,8 @@ func decodeDockerConfigFieldAuth(field string) (username, password string, err e
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ident DockerConfigEntry) ConvertToDockerConfigCompatible() DockerConfigEntryWithAuth {
|
func (ident DockerConfigEntry) ConvertToDockerConfigCompatible() dockerConfigEntryWithAuth {
|
||||||
ret := DockerConfigEntryWithAuth{ident.Username, ident.Password, ident.Email, ""}
|
ret := dockerConfigEntryWithAuth{ident.Username, ident.Password, ident.Email, ""}
|
||||||
ret.Auth = encodeDockerConfigFieldAuth(ident.Username, ident.Password)
|
ret.Auth = encodeDockerConfigFieldAuth(ident.Username, ident.Password)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
@ -239,12 +239,8 @@ func TestPullWithNoSecrets(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPullWithSecrets(t *testing.T) {
|
func TestPullWithSecrets(t *testing.T) {
|
||||||
dockercfgAuth := credentialprovider.DockerConfigEntry{
|
// auth value is equivalent to: "username":"passed-user","password":"passed-password"
|
||||||
Username: "passed-user",
|
dockerCfg := map[string]map[string]string{"index.docker.io/v1/": {"email": "passed-email", "auth": "cGFzc2VkLXVzZXI6cGFzc2VkLXBhc3N3b3Jk"}}
|
||||||
Password: "passed-password",
|
|
||||||
Email: "passed-email",
|
|
||||||
}.ConvertToDockerConfigCompatible()
|
|
||||||
dockerCfg := map[string]credentialprovider.DockerConfigEntryWithAuth{"index.docker.io/v1/": dockercfgAuth}
|
|
||||||
dockercfgContent, err := json.Marshal(dockerCfg)
|
dockercfgContent, err := json.Marshal(dockerCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user