Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
builder: fix panic on login (#78)
Browse files Browse the repository at this point in the history
Fixes #75

Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
  • Loading branch information
dweomer authored Sep 1, 2021
1 parent 23c4980 commit 252a8d0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/client/builder/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (s *Login) Do(_ context.Context, k *client.Interface, server string) error
login, err := k.Core.Secret().Get(k.Namespace, "kim-docker-config", metav1.GetOptions{})
if apierr.IsNotFound(err) {
dockerConfigJSON := credentialprovider.DockerConfigJSON{
Auths: map[string]credentialprovider.DockerConfigEntry{
Auths: credentialprovider.DockerConfig{
server: {
Username: s.Username,
Password: s.Password,
Expand All @@ -51,12 +51,17 @@ func (s *Login) Do(_ context.Context, k *client.Interface, server string) error
_, err = k.Core.Secret().Create(login)
return err
}
var dockerConfigJSON credentialprovider.DockerConfigJSON
dockerConfigJSON := credentialprovider.DockerConfigJSON{
Auths: credentialprovider.DockerConfig{},
}
if dockerConfigJSONBytes, ok := login.Data[corev1.DockerConfigJsonKey]; ok {
if err := json.Unmarshal(dockerConfigJSONBytes, &dockerConfigJSON); err != nil {
return err
}
}
if dockerConfigJSON.Auths == nil {
dockerConfigJSON.Auths = credentialprovider.DockerConfig{}
}
dockerConfigJSON.Auths[server] = credentialprovider.DockerConfigEntry{
Username: s.Username,
Password: s.Password,
Expand Down

0 comments on commit 252a8d0

Please sign in to comment.