From c73b1dff01a52e2944434c3cae68c3f5de0f15bd Mon Sep 17 00:00:00 2001 From: punkwalker Date: Thu, 26 Dec 2024 17:21:52 -0800 Subject: [PATCH 1/3] fix: e2e test by updating Secret ouput TemplateData Signed-off-by: punkwalker --- .goreleaser.yaml | 2 +- pkg/cmd/get/secrets.go | 10 +++++++--- tests/e2e/e2e.go | 12 ++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 8cc9ca8c..7e7578b5 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -5,7 +5,7 @@ before: - go mod tidy release: # Mark nightly build as prerelease based on tag - prerelease: '{{ contains .Tag "-nightly" }}' + prerelease: auto builds: - env: diff --git a/pkg/cmd/get/secrets.go b/pkg/cmd/get/secrets.go index e731b24c..6ccecb19 100644 --- a/pkg/cmd/get/secrets.go +++ b/pkg/cmd/get/secrets.go @@ -3,14 +3,15 @@ package get import ( "context" "fmt" - "github.com/cnoe-io/idpbuilder/pkg/entity" - "github.com/cnoe-io/idpbuilder/pkg/printer" "io" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "os" "path/filepath" "strings" + "github.com/cnoe-io/idpbuilder/pkg/entity" + "github.com/cnoe-io/idpbuilder/pkg/printer" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/cnoe-io/idpbuilder/api/v1alpha1" "github.com/cnoe-io/idpbuilder/pkg/build" "github.com/cnoe-io/idpbuilder/pkg/k8s" @@ -46,8 +47,11 @@ var ( ) type TemplateData struct { + IsCore bool `json:"isCore"` Name string `json:"name"` Namespace string `json:"namespace"` + Username string `json:"username"` + Password string `json:"password"` Data map[string]string `json:"data"` } diff --git a/tests/e2e/e2e.go b/tests/e2e/e2e.go index 86c355b8..d8c50c4f 100644 --- a/tests/e2e/e2e.go +++ b/tests/e2e/e2e.go @@ -275,10 +275,10 @@ func GetBasicAuth(ctx context.Context, name string) (BasicAuth, error) { continue } - for i := range secs { - if secs[i].Name == name { - out.Password = secs[i].Data["password"] - out.Username = secs[i].Data["username"] + for _, sec := range secs { + if sec.Name == name { + out.Password = sec.Password + out.Username = sec.Username break } } @@ -388,8 +388,8 @@ func TestGiteaRegistry(ctx context.Context, t *testing.T, cmd, giteaHost, giteaP assert.NoError(t, err) sec := secs[0] - user := sec.Data["username"] - pass := sec.Data["password"] + user := sec.Username + pass := sec.Password login, err := RunCommand(ctx, fmt.Sprintf("%s login %s:%s -u %s -p %s", cmd, giteaHost, giteaPort, user, pass), 10*time.Second) require.NoErrorf(t, err, "%s login err: %s", cmd, login) From 89a543152a71b0987807d1c6e513827072fb3edd Mon Sep 17 00:00:00 2001 From: punkwalker Date: Fri, 27 Dec 2024 10:44:00 -0800 Subject: [PATCH 2/3] fix: update secret struct Signed-off-by: punkwalker --- pkg/cmd/get/secrets.go | 3 --- tests/e2e/e2e.go | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pkg/cmd/get/secrets.go b/pkg/cmd/get/secrets.go index 6ccecb19..c51bd749 100644 --- a/pkg/cmd/get/secrets.go +++ b/pkg/cmd/get/secrets.go @@ -47,11 +47,8 @@ var ( ) type TemplateData struct { - IsCore bool `json:"isCore"` Name string `json:"name"` Namespace string `json:"namespace"` - Username string `json:"username"` - Password string `json:"password"` Data map[string]string `json:"data"` } diff --git a/tests/e2e/e2e.go b/tests/e2e/e2e.go index d8c50c4f..d25ff48a 100644 --- a/tests/e2e/e2e.go +++ b/tests/e2e/e2e.go @@ -18,7 +18,7 @@ import ( "code.gitea.io/sdk/gitea" argov1alpha1 "github.com/cnoe-io/argocd-api/api/argo/application/v1alpha1" - "github.com/cnoe-io/idpbuilder/pkg/cmd/get" + "github.com/cnoe-io/idpbuilder/pkg/entity" "github.com/cnoe-io/idpbuilder/pkg/k8s" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -268,7 +268,7 @@ func GetBasicAuth(ctx context.Context, name string) (BasicAuth, error) { } out := BasicAuth{} - secs := make([]get.TemplateData, 2) + secs := make([]entity.Secret, 2) if err = json.Unmarshal(b, &secs); err != nil { lastErr = err time.Sleep(httpRetryDelay) @@ -383,7 +383,7 @@ func TestGiteaRegistry(ctx context.Context, t *testing.T, cmd, giteaHost, giteaP b, err := RunCommand(ctx, fmt.Sprintf("%s get secrets -o json -p gitea", IdpbuilderBinaryLocation), 10*time.Second) assert.NoError(t, err) - secs := make([]get.TemplateData, 2) + secs := make([]entity.Secret, 1) err = json.Unmarshal(b, &secs) assert.NoError(t, err) From c81253b14fd5b1be9e990a5fcaf2a3220d2ddb00 Mon Sep 17 00:00:00 2001 From: punkwalker Date: Fri, 27 Dec 2024 11:05:32 -0800 Subject: [PATCH 3/3] fix: revert goreleaser change Signed-off-by: punkwalker --- .goreleaser.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 7e7578b5..8cc9ca8c 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -5,7 +5,7 @@ before: - go mod tidy release: # Mark nightly build as prerelease based on tag - prerelease: auto + prerelease: '{{ contains .Tag "-nightly" }}' builds: - env: