From b9a563f9c5b091717ccecb7b3cf618331491aeff Mon Sep 17 00:00:00 2001 From: Adam Gardner Date: Sun, 19 Jun 2022 10:19:04 -1000 Subject: [PATCH 1/3] feat(secrets): allow diffing stringData sections of secrets as well as data sections --- diff/diff.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/diff/diff.go b/diff/diff.go index 9ed30bbb..7fad29ed 100644 --- a/diff/diff.go +++ b/diff/diff.go @@ -2,6 +2,7 @@ package diff import ( "bytes" + "encoding/base64" "fmt" "io" "math" @@ -163,11 +164,29 @@ func redactSecrets(old, new *manifest.MappingResult) { if err := yaml.NewYAMLToJSONDecoder(bytes.NewBufferString(old.Content)).Decode(&oldSecret); err != nil { old.Content = fmt.Sprintf("Error parsing old secret: %s", err) } + if oldSecret.Data == nil { + oldSecret.Data = make(map[string][]byte, len(oldSecret.StringData)) + } + for k, v := range oldSecret.StringData { + data := []byte(v) + dst := make([]byte, base64.StdEncoding.EncodedLen(len(data))) + base64.StdEncoding.Encode(dst, data) + oldSecret.Data[k] = dst + } } if new != nil { if err := yaml.NewYAMLToJSONDecoder(bytes.NewBufferString(new.Content)).Decode(&newSecret); err != nil { new.Content = fmt.Sprintf("Error parsing new secret: %s", err) } + if newSecret.Data == nil { + newSecret.Data = make(map[string][]byte, len(newSecret.StringData)) + } + for k, v := range newSecret.StringData { + data := []byte(v) + dst := make([]byte, base64.StdEncoding.EncodedLen(len(data))) + base64.StdEncoding.Encode(dst, data) + newSecret.Data[k] = dst + } } if old != nil { oldSecret.StringData = make(map[string]string, len(oldSecret.Data)) From 90c8a2743c95020177cdd6b9eb60f81184d01fc6 Mon Sep 17 00:00:00 2001 From: Adam Gardner Date: Sun, 19 Jun 2022 11:26:40 -1000 Subject: [PATCH 2/3] Change database23 to philomory to allow installation of fork to succeed --- install-binary.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-binary.sh b/install-binary.sh index ea0e7cc0..2c0b8f7b 100755 --- a/install-binary.sh +++ b/install-binary.sh @@ -3,7 +3,7 @@ # Shamelessly copied from https://github.com/technosophos/helm-template PROJECT_NAME="helm-diff" -PROJECT_GH="databus23/$PROJECT_NAME" +PROJECT_GH="philomory/$PROJECT_NAME" export GREP_COLOR="never" # Convert HELM_BIN and HELM_PLUGIN_DIR to unix if cygpath is From af950d8cc048bcc2b62b219463b079d9b7e2b9be Mon Sep 17 00:00:00 2001 From: Adam Gardner Date: Sun, 19 Jun 2022 15:26:12 -1000 Subject: [PATCH 3/3] revert change made for local testing --- install-binary.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-binary.sh b/install-binary.sh index 2c0b8f7b..ea0e7cc0 100755 --- a/install-binary.sh +++ b/install-binary.sh @@ -3,7 +3,7 @@ # Shamelessly copied from https://github.com/technosophos/helm-template PROJECT_NAME="helm-diff" -PROJECT_GH="philomory/$PROJECT_NAME" +PROJECT_GH="databus23/$PROJECT_NAME" export GREP_COLOR="never" # Convert HELM_BIN and HELM_PLUGIN_DIR to unix if cygpath is