From 3961ec2c4040187e4023f2938daefdb24bfd12d4 Mon Sep 17 00:00:00 2001 From: Sam Weston Date: Thu, 1 Oct 2020 12:08:08 +0100 Subject: [PATCH 1/2] fix: Hardcoded username for registry authentication --- docker/config/config.go | 7 +++++-- docker/config/config_test.go | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docker/config/config.go b/docker/config/config.go index 80efe00..333d8da 100644 --- a/docker/config/config.go +++ b/docker/config/config.go @@ -7,6 +7,7 @@ import ( "os" "strings" + log "github.com/sirupsen/logrus" "github.com/ivanilves/lstags/docker/config/credhelper" "github.com/moby/moby/api/types" @@ -56,7 +57,7 @@ func (c *Config) GetCredentials(registry string) (string, string, bool) { func getAuthJSONString(username, password string) string { b, err := json.Marshal(types.AuthConfig{ - Username: "_json_key", + Username: username, Password: password, }) @@ -76,9 +77,11 @@ func (c *Config) GetRegistryAuth(registry string) string { if !defined { return "" } + authJSONString := getAuthJSONString(username, password) + log.Debugf("JSON Auth String: %s", authJSONString) return base64.StdEncoding.EncodeToString( - []byte(getAuthJSONString(username, password)), + []byte(authJSONString), ) } diff --git a/docker/config/config_test.go b/docker/config/config_test.go index b7b21a8..9707841 100644 --- a/docker/config/config_test.go +++ b/docker/config/config_test.go @@ -10,8 +10,8 @@ var configFile = "../../fixtures/docker/config.json" func TestGetRegistryAuth(t *testing.T) { examples := map[string]string{ - "registry.company.io": "eyJ1c2VybmFtZSI6Il9qc29uX2tleSIsInBhc3N3b3JkIjoicGFzczEifQ==", - "registry.hub.docker.com": "eyJ1c2VybmFtZSI6Il9qc29uX2tleSIsInBhc3N3b3JkIjoicGFzczIifQ==", + "registry.company.io": "eyJ1c2VybmFtZSI6InVzZXIxIiwicGFzc3dvcmQiOiJwYXNzMSJ9", + "registry.hub.docker.com": "eyJ1c2VybmFtZSI6InVzZXIyIiwicGFzc3dvcmQiOiJwYXNzMiJ9", "registry.mindundi.org": "", } From 834d53b962aaa6debc57a139abaf429810968202 Mon Sep 17 00:00:00 2001 From: Sam Weston Date: Thu, 1 Oct 2020 09:54:46 +0100 Subject: [PATCH 2/2] fix: Resolve problem when running release in Circle CI --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index fec1b47..9b1eb16 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -77,6 +77,7 @@ jobs: - run: name: Build release assets and binaries command: | + git reset --hard make release ./dist/assets/lstags-linux/lstags --version