Skip to content

Commit

Permalink
add missing auth
Browse files Browse the repository at this point in the history
  • Loading branch information
skylenet committed Oct 2, 2024
1 parent 41451af commit 181e6c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package docker_manager

import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"os"
Expand Down Expand Up @@ -74,7 +75,7 @@ func getCredentialsFromStore(credHelper string, registryURL string) (*registry.A
Username: creds.Username,
Password: creds.Secret,
ServerAddress: creds.ServerURL,
Auth: "",
Auth: base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", creds.Username, creds.Secret))),
Email: "",
IdentityToken: "",
RegistryToken: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestGetAuthConfigForRepoPlain(t *testing.T) {
Password: "password",
}

base64Auth := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", expectedAuth.Username, expectedAuth.Password)))
encodedAuth := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", expectedAuth.Username, expectedAuth.Password)))

cfg := fmt.Sprintf(`
{
Expand All @@ -43,13 +43,11 @@ func TestGetAuthConfigForRepoPlain(t *testing.T) {
"auth": "%s"
}
}
}`, base64Auth)
}`, encodedAuth)

tmpDir := WriteStaticConfig(t, cfg)
defer os.RemoveAll(tmpDir)

encodedAuth := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", expectedAuth.Username, expectedAuth.Password)))

// Test 1: Retrieve auth config for Docker Hub using docker.io domain
authConfig, err := GetAuthFromDockerConfig("docker.io/my-repo/my-image:latest")
assert.NoError(t, err)
Expand Down

0 comments on commit 181e6c9

Please sign in to comment.