From 3c3100ba1bc2683ff9b73dbe806297c49a835f73 Mon Sep 17 00:00:00 2001 From: Rafael Matias Date: Wed, 30 Oct 2024 16:49:00 +0100 Subject: [PATCH 1/6] fix: handle no docker auth --- .../docker_config_storage_creator.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/docker_config_storage_creator/docker_config_storage_creator.go b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/docker_config_storage_creator/docker_config_storage_creator.go index 47a4ffd962..671ff68a6e 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/docker_config_storage_creator/docker_config_storage_creator.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/docker_config_storage_creator/docker_config_storage_creator.go @@ -116,7 +116,10 @@ func storeConfigInVolume( if err != nil { return stacktrace.NewError("An error occurred getting auth for registry '%v' from Docker config: %v", registry, err) } - cfg.Auths[registry] = *creds + // creds can be nil if the registry doesn't have auth + if creds != nil { + cfg.Auths[registry] = *creds + } } cfgJsonStr, err := json.Marshal(cfg) From 4e9bad9ef05cfbb5c09ea6c21795ab0f1402fbe7 Mon Sep 17 00:00:00 2001 From: Rafael Matias Date: Wed, 30 Oct 2024 16:51:02 +0100 Subject: [PATCH 2/6] docker auth: add no auth test --- .../docker/docker_manager/docker_auth_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_auth_test.go b/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_auth_test.go index 1f328911e2..efc7b6d0b5 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_auth_test.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_auth_test.go @@ -27,6 +27,13 @@ func writeStaticConfig(t *testing.T, configContent string) string { return tmpDir } +func TestGetNoAuth(t *testing.T) { + os.Setenv(ENV_DOCKER_CONFIG, "/does/not/exist") + authConfig, err := GetAuthFromDockerConfig("my-repo/my-image:latest") + assert.NoError(t, err) + assert.Nil(t, authConfig, "Auth config should be nil") +} + func TestGetAuthConfigForRepoPlain(t *testing.T) { expectedUser := "user" expectedPassword := "password" From 2c2874999e62744f7f9e2f7bf79d4bec1188f078 Mon Sep 17 00:00:00 2001 From: Rafael Matias Date: Wed, 30 Oct 2024 16:57:51 +0100 Subject: [PATCH 3/6] docker auth: only log and don't fail if some auth creds were not able to be obtained --- .../docker_config_storage_creator.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/docker_config_storage_creator/docker_config_storage_creator.go b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/docker_config_storage_creator/docker_config_storage_creator.go index 671ff68a6e..e5a22cfa36 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/docker_config_storage_creator/docker_config_storage_creator.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/docker_config_storage_creator/docker_config_storage_creator.go @@ -114,10 +114,10 @@ func storeConfigInVolume( for _, registry := range registries { creds, err := docker_manager.GetAuthFromDockerConfig(registry) if err != nil { - return stacktrace.NewError("An error occurred getting auth for registry '%v' from Docker config: %v", registry, err) + logrus.Warnf("An error occurred getting auth for registry '%v' from Docker config: %v", registry, err) } // creds can be nil if the registry doesn't have auth - if creds != nil { + if err != nil && creds != nil { cfg.Auths[registry] = *creds } } From ffe0bc25ddee6e52ac710d9f2de73617d59d56be Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Wed, 30 Oct 2024 23:59:45 -0700 Subject: [PATCH 4/6] rename test --- .../backend_impls/docker/docker_manager/docker_auth_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_auth_test.go b/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_auth_test.go index efc7b6d0b5..6e11673768 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_auth_test.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_auth_test.go @@ -27,8 +27,7 @@ func writeStaticConfig(t *testing.T, configContent string) string { return tmpDir } -func TestGetNoAuth(t *testing.T) { - os.Setenv(ENV_DOCKER_CONFIG, "/does/not/exist") +func TestGetAuthWithNoAuthSetReturnsNilAndNoError(t *testing.T) { authConfig, err := GetAuthFromDockerConfig("my-repo/my-image:latest") assert.NoError(t, err) assert.Nil(t, authConfig, "Auth config should be nil") From c643435d66c3a4f8429533a02095d7757114abd5 Mon Sep 17 00:00:00 2001 From: Rafael Matias Date: Thu, 31 Oct 2024 11:38:07 +0100 Subject: [PATCH 5/6] trigger CI From 55607e68dce4afb02b9bb12ede2aa094b6a0b701 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 31 Oct 2024 08:42:05 -0700 Subject: [PATCH 6/6] trigger ci