From 4fd5684277b71ea2da242d4cad25e2dc0a082297 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Sat, 30 Jan 2021 15:07:48 +0200 Subject: [PATCH 1/2] Fix create secret commands Regression bug introduced in https://github.com/fluxcd/flux2/pull/788 Signed-off-by: Stefan Prodan --- cmd/flux/create_secret.go | 2 ++ cmd/flux/create_secret_git.go | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cmd/flux/create_secret.go b/cmd/flux/create_secret.go index 6ca3b438..17139794 100644 --- a/cmd/flux/create_secret.go +++ b/cmd/flux/create_secret.go @@ -51,6 +51,8 @@ func makeSecret(name string) (corev1.Secret, error) { Namespace: rootArgs.namespace, Labels: secretLabels, }, + StringData: map[string]string{}, + Data: nil, }, nil } diff --git a/cmd/flux/create_secret_git.go b/cmd/flux/create_secret_git.go index eab2cb85..38ea028e 100644 --- a/cmd/flux/create_secret_git.go +++ b/cmd/flux/create_secret_git.go @@ -133,10 +133,10 @@ func createSecretGitCmdRun(cmd *cobra.Command, args []string) error { return err } - secret.Data = map[string][]byte{ - "identity": pair.PrivateKey, - "identity.pub": pair.PublicKey, - "known_hosts": hostKey, + secret.StringData = map[string]string{ + "identity": string(pair.PrivateKey), + "identity.pub": string(pair.PublicKey), + "known_hosts": string(hostKey), } if !createArgs.export { @@ -148,9 +148,9 @@ func createSecretGitCmdRun(cmd *cobra.Command, args []string) error { } // TODO: add cert data when it's implemented in source-controller - secret.Data = map[string][]byte{ - "username": []byte(secretGitArgs.username), - "password": []byte(secretGitArgs.password), + secret.StringData = map[string]string{ + "username": secretGitArgs.username, + "password": secretGitArgs.password, } default: return fmt.Errorf("git URL scheme '%s' not supported, can be: ssh, http and https", u.Scheme) From 4e8a600f347f69457c0e90f30c1d76a77ad73f34 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Sat, 30 Jan 2021 15:19:45 +0200 Subject: [PATCH 2/2] Add e2e tests for create secret commands Signed-off-by: Stefan Prodan --- .github/workflows/e2e.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index a06ce120..7e05737a 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -50,6 +50,15 @@ jobs: - name: flux install --manifests run: | ./bin/flux install --manifests ./manifests/install/ + - name: flux create secret + run: | + ./bin/flux create secret git git-ssh-test \ + --url ssh://git@github.com/stefanprodan/podinfo + ./bin/flux create secret git git-https-test \ + --url https://github.com/stefanprodan/podinfo \ + --username=test --password=test + ./bin/flux create secret helm helm-test \ + --username=test --password=test - name: flux create source git run: | ./bin/flux create source git podinfo \