diff --git a/Makefile b/Makefile index 63d1d796..3cd1f60b 100644 --- a/Makefile +++ b/Makefile @@ -36,14 +36,14 @@ all: cli cli: ## Compile the cli @docker build . --target cli \ --platform local \ - --build-arg BUILD_TAGS=e2e,kube \ + --build-arg BUILD_TAGS=e2e \ --build-arg GIT_TAG=$(GIT_TAG) \ --output ./bin e2e-win-ci: ## Run end to end local tests on Windows CI, no Docker for Linux containers available ATM. Set E2E_TEST=TestName to run a single test go test -count=1 -v $(TEST_FLAGS) ./local/e2e/cli-only -e2e-ecs: ## Run End to end ECS tests. Set E2E_TEST=TestName to run a single test +e2e-ecs: cli ## Run End to end ECS tests. Set E2E_TEST=TestName to run a single test go test -timeout 30m -count=1 -v $(TEST_FLAGS) ./ecs/e2e/ecs cross: ## Compile the CLI for linux, darwin and windows @@ -54,7 +54,6 @@ cross: ## Compile the CLI for linux, darwin and windows test: ## Run unit tests @docker build --progress=plain . \ - --build-arg BUILD_TAGS=kube \ --build-arg GIT_TAG=$(GIT_TAG) \ --target test @@ -63,7 +62,7 @@ cache-clear: ## Clear the builder cache lint: ## run linter(s) @docker build . \ - --build-arg BUILD_TAGS=kube,e2e \ + --build-arg BUILD_TAGS=e2e \ --build-arg GIT_TAG=$(GIT_TAG) \ --target lint diff --git a/builder.Makefile b/builder.Makefile index 82411988..bc3ef1d3 100644 --- a/builder.Makefile +++ b/builder.Makefile @@ -36,9 +36,6 @@ GO_BUILD=$(STATIC_FLAGS) go build -trimpath -ldflags=$(LDFLAGS) BINARY?=bin/compose-ecs BINARY_WITH_EXTENSION=$(BINARY)$(EXTENSION) -COMPOSE_BINARY?=bin/docker-compose -COMPOSE_BINARY_WITH_EXTENSION=$(COMPOSE_BINARY)$(EXTENSION) - WORK_DIR:=$(shell mktemp -d) TAGS:= diff --git a/cli/cmd/secrets.go b/cli/cmd/secrets.go index 65f890d3..ff2acf3f 100644 --- a/cli/cmd/secrets.go +++ b/cli/cmd/secrets.go @@ -55,6 +55,7 @@ func createSecret() *cobra.Command { if len(args) == 2 { file = args[1] } + fmt.Println("create secret from " + file) if len(file) == 0 { return fmt.Errorf("secret data source empty: %q", file) } @@ -63,11 +64,12 @@ func createSecret() *cobra.Command { case "-": in = os.Stdin default: - in, err := os.Open(file) + f, err := os.Open(file) if err != nil { return err } - defer func() { _ = in.Close() }() + in = f + defer in.Close() //nolint:errcheck } content, err := io.ReadAll(in) if err != nil { diff --git a/ecs/e2e/ecs/e2e-ecs_test.go b/ecs/e2e/ecs/e2e-ecs_test.go index 58482bb3..0e5d8813 100644 --- a/ecs/e2e/ecs/e2e-ecs_test.go +++ b/ecs/e2e/ecs/e2e-ecs_test.go @@ -39,22 +39,25 @@ func TestSecrets(t *testing.T) { secretFile := filepath.Join(t.TempDir(), "secret.txt") err := os.WriteFile(secretFile, []byte("pass1"), 0644) assert.Check(t, err == nil) - res := icmd.RunCommand("compose-ecs", "secret", "create", secretName, secretFile) - assert.Check(t, strings.Contains(res.Stdout(), secretName), res.Stdout()) + res := icmd.RunCommand(composeECS(), "secret", "create", secretName, secretFile) + stdout := res.Stdout() + stderr := res.Stderr() + fmt.Println(stderr) + assert.Check(t, strings.Contains(stdout, secretName), stdout) }) t.Run("list secrets", func(t *testing.T) { - res := icmd.RunCommand("compose-ecs", "secret", "list") + res := icmd.RunCommand(composeECS(), "secret", "list") assert.Check(t, strings.Contains(res.Stdout(), secretName), res.Stdout()) }) t.Run("inspect secret", func(t *testing.T) { - res := icmd.RunCommand("compose-ecs", "secret", "inspect", secretName) + res := icmd.RunCommand(composeECS(), "secret", "inspect", secretName) assert.Check(t, strings.Contains(res.Stdout(), `"Name": "`+secretName+`"`), res.Stdout()) }) t.Run("rm secret", func(t *testing.T) { - icmd.RunCommand("compose-ecs", "secret", "rm", secretName) + icmd.RunCommand(composeECS(), "secret", "rm", secretName) res := icmd.RunCommand("secret", "list") assert.Check(t, !strings.Contains(res.Stdout(), secretName), res.Stdout()) }) @@ -62,13 +65,13 @@ func TestSecrets(t *testing.T) { func TestCompose(t *testing.T) { t.Run("compose-ecs up", func(t *testing.T) { - res := icmd.RunCommand("compose-ecs", "up") + res := icmd.RunCommand(composeECS(), "up") res.Assert(t, icmd.Success) }) var webURL, wordsURL, secretsURL string t.Run("compose-ecs ps", func(t *testing.T) { - res := icmd.RunCommand("compose-ecs", "ps") + res := icmd.RunCommand(composeECS(), "ps") lines := strings.Split(strings.TrimSpace(res.Stdout()), "\n") assert.Equal(t, 5, len(lines)) @@ -126,7 +129,7 @@ func TestCompose(t *testing.T) { }) t.Run("compose-ecs down", func(t *testing.T) { - res := icmd.RunCommand("compose-ecs", "down") + res := icmd.RunCommand(composeECS(), "down") checkUp := func(t poll.LogT) poll.Result { out := res.Combined() @@ -139,6 +142,10 @@ func TestCompose(t *testing.T) { }) } +func composeECS() string { + return filepath.Clean("./../../../bin/compose-ecs") +} + // HTTPGetWithRetry performs an HTTP GET on an `endpoint`, using retryDelay also as a request timeout. // In the case of an error or the response status is not the expected one, it retries the same request, // returning the response body as a string (empty if we could not reach it)