Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use data field in Secrets #2795

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/flux/bootstrap_git.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,12 @@ func transportForURL(u *url.URL) (transport.AuthMethod, error) {
}

func promptPublicKey(ctx context.Context, secret corev1.Secret, _ sourcesecret.Options) error {
ppk, ok := secret.StringData[sourcesecret.PublicKeySecretKey]
ppk, ok := secret.Data[sourcesecret.PublicKeySecretKey]
if !ok {
return nil
}

logger.Successf("public key: %s", strings.TrimSpace(ppk))
logger.Successf("public key: %s", strings.TrimSpace(string(ppk)))

if !gitArgs.silent {
prompt := promptui.Prompt{
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/create_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func upsertSecret(ctx context.Context, kubeClient client.Client, secret corev1.S
return err
}

existing.StringData = secret.StringData
existing.Data = secret.Data
if err := kubeClient.Update(ctx, &existing); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/create_secret_git.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func createSecretGitCmdRun(cmd *cobra.Command, args []string) error {
return err
}

if ppk, ok := s.StringData[sourcesecret.PublicKeySecretKey]; ok {
if ppk, ok := s.Data[sourcesecret.PublicKeySecretKey]; ok {
logger.Generatef("deploy key: %s", ppk)
}

Expand Down
8 changes: 4 additions & 4 deletions cmd/flux/create_source_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,15 @@ func createSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
Namespace: *kubeconfigArgs.Namespace,
Labels: sourceLabels,
},
StringData: map[string]string{},
Data: map[string][]byte{},
}

if sourceBucketArgs.accessKey != "" && sourceBucketArgs.secretKey != "" {
secret.StringData["accesskey"] = sourceBucketArgs.accessKey
secret.StringData["secretkey"] = sourceBucketArgs.secretKey
secret.Data["accesskey"] = []byte(sourceBucketArgs.accessKey)
secret.Data["secretkey"] = []byte(sourceBucketArgs.secretKey)
}

if len(secret.StringData) > 0 {
if len(secret.Data) > 0 {
logger.Actionf("applying secret with the bucket credentials")
if err := upsertSecret(ctx, kubeClient, secret); err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions cmd/flux/create_source_git.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,11 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
if err = yaml.Unmarshal([]byte(secret.Content), &s); err != nil {
return err
}
if len(s.StringData) > 0 {
if hk, ok := s.StringData[sourcesecret.KnownHostsSecretKey]; ok {
if len(s.Data) > 0 {
if hk, ok := s.Data[sourcesecret.KnownHostsSecretKey]; ok {
logger.Successf("collected public key from SSH server:\n%s", hk)
}
if ppk, ok := s.StringData[sourcesecret.PublicKeySecretKey]; ok {
if ppk, ok := s.Data[sourcesecret.PublicKeySecretKey]; ok {
logger.Generatef("deploy key: %s", ppk)
if !sourceGitArgs.silent {
prompt := promptui.Prompt{
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/create_source_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func createSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
if err = yaml.Unmarshal([]byte(secret.Content), &s); err != nil {
return err
}
if len(s.StringData) > 0 {
if len(s.Data) > 0 {
logger.Actionf("applying secret with repository credentials")
if err := upsertSecret(ctx, kubeClient, s); err != nil {
return err
Expand Down
21 changes: 5 additions & 16 deletions cmd/flux/testdata/create_secret/git/git-ssh-secret-password.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +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YS1zaGEyLW5pc3RwMjU2IEFBQUFFMlZqWkhOaExYTm9ZVEl0Ym1semRIQXlOVFlBQUFBSWJtbHpkSEF5TlRZQUFBQkJCRW1LU0VOalFFZXpPbXhrWk15N29wS2d3RkI5bmt0NVlScllNak51RzVOODd1UmdnNkNMcmJvNXdBZFQveTZ2MG1LVjBVMncwV1oyWUIvKytUcG9ja2c9
password: cGFzc3dvcmQ=
kind: Secret
metadata:
name: podinfo-auth
namespace: my-namespace
stringData:
identity: |
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABA9i7hZ7m
UBPxF7GuUswZiXAAAAEAAAAAEAAABoAAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlz
dHAyNTYAAABBBOOAQfhwylg6WhJRXha2K1dJY5BG12nsS7YyFlKPAovOAC8d8rTOzjjDWu
kG24JVRrXoWUN6eWWvxDvMd5pZT1wAAADAepYZPGTQnH6genhU+y9aD1GFO8BsODIllxEq
T8n2eLAmPWYLv4HhgtmbqtsOmTE9sVM5ynYj/dAX1SreoGeoMEVFIt1cYtWgyuJccEiK4t
1JQLFLMKnBRTY+yIdD6gX7tLRRL/jqzMR4XZF5/Yf48lvU4h+ljuOitWH3ea9142izl2Wk
eXAfeoezJaDntZUUEYvKMI5U6iWVni+c7vOcJFTZgBeV4i54ua06tY5mE/mWARldiSDtJG
yGEOankDnf
-----END OPENSSH PRIVATE KEY-----
identity.pub: |
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOOAQfhwylg6WhJRXha2K1dJY5BG12nsS7YyFlKPAovOAC8d8rTOzjjDWukG24JVRrXoWUN6eWWvxDvMd5pZT1w=
known_hosts: github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=
password: password

18 changes: 4 additions & 14 deletions cmd/flux/testdata/create_secret/git/git-ssh-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
---
apiVersion: v1
data:
identity: LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0KYjNCbGJuTnphQzFyWlhrdGRqRUFBQUFBQkc1dmJtVUFBQUFFYm05dVpRQUFBQUFBQUFBQkFBQUFhQUFBQUJObFkyUnpZUwoxemFHRXlMVzVwYzNSd01qVTJBQUFBQ0c1cGMzUndNalUyQUFBQVFRVHVpdStnR3dMSXU5RTVKNHZSc2hvSUJIU2NLeDRZCmY5b25pV01zTEZIWHE1cDlHSi9lYjlDcjNqZ05BQ25HT0lHT3Fsd0JRdlA1ckNKdWFKMHBDUktVQUFBQXVORTFHdHZSTlIKcmJBQUFBRTJWalpITmhMWE5vWVRJdGJtbHpkSEF5TlRZQUFBQUlibWx6ZEhBeU5UWUFBQUJCQk82Szc2QWJBc2k3MFRrbgppOUd5R2dnRWRKd3JIaGgvMmllSll5d3NVZGVybW4wWW45NXYwS3ZlT0EwQUtjWTRnWTZxWEFGQzgvbXNJbTVvblNrSkVwClFBQUFBaEFQYU82UGlOKzEyMzhLTXJIZzM0TTdYZGZ0R3lwdDIvVUtFejJMMlBmNDB5QUFBQUgzTnZiWFJ2WTJocGIyNTUKWld0M1pYSmxRRk52YlhSdlkyaHBjeTFOUWxBPQotLS0tLUVORCBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0K
identity.pub: ZWNkc2Etc2hhMi1uaXN0cDI1NiBBQUFBRTJWalpITmhMWE5vWVRJdGJtbHpkSEF5TlRZQUFBQUlibWx6ZEhBeU5UWUFBQUJCQk82Szc2QWJBc2k3MFRrbmk5R3lHZ2dFZEp3ckhoaC8yaWVKWXl3c1VkZXJtbjBZbjk1djBLdmVPQTBBS2NZNGdZNnFYQUZDOC9tc0ltNW9uU2tKRXBRPQo=
known_hosts: Z2l0aHViLmNvbSBlY2RzYS1zaGEyLW5pc3RwMjU2IEFBQUFFMlZqWkhOaExYTm9ZVEl0Ym1semRIQXlOVFlBQUFBSWJtbHpkSEF5TlRZQUFBQkJCRW1LU0VOalFFZXpPbXhrWk15N29wS2d3RkI5bmt0NVlScllNak51RzVOODd1UmdnNkNMcmJvNXdBZFQveTZ2MG1LVjBVMncwV1oyWUIvKytUcG9ja2c9
kind: Secret
metadata:
name: podinfo-auth
namespace: my-namespace
stringData:
identity: |
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAaAAAABNlY2RzYS
1zaGEyLW5pc3RwMjU2AAAACG5pc3RwMjU2AAAAQQTuiu+gGwLIu9E5J4vRshoIBHScKx4Y
f9oniWMsLFHXq5p9GJ/eb9Cr3jgNACnGOIGOqlwBQvP5rCJuaJ0pCRKUAAAAuNE1GtvRNR
rbAAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBO6K76AbAsi70Tkn
i9GyGggEdJwrHhh/2ieJYywsUdermn0Yn95v0KveOA0AKcY4gY6qXAFC8/msIm5onSkJEp
QAAAAhAPaO6PiN+1238KMrHg34M7XdftGypt2/UKEz2L2Pf40yAAAAH3NvbXRvY2hpb255
ZWt3ZXJlQFNvbXRvY2hpcy1NQlA=
-----END OPENSSH PRIVATE KEY-----
identity.pub: |
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBO6K76AbAsi70Tkni9GyGggEdJwrHhh/2ieJYywsUdermn0Yn95v0KveOA0AKcY4gY6qXAFC8/msIm5onSkJEpQ=
known_hosts: github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=

6 changes: 3 additions & 3 deletions cmd/flux/testdata/create_secret/git/secret-git-basic.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
apiVersion: v1
data:
password: bXktcGFzc3dvcmQ=
username: bXktdXNlcm5hbWU=
kind: Secret
metadata:
name: podinfo-auth
namespace: my-namespace
stringData:
password: my-password
username: my-username

6 changes: 3 additions & 3 deletions cmd/flux/testdata/create_secret/helm/secret-helm.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
apiVersion: v1
data:
password: bXktcGFzc3dvcmQ=
username: bXktdXNlcm5hbWU=
kind: Secret
metadata:
name: helm-secret
namespace: my-namespace
stringData:
password: my-password
username: my-username

Loading