summarylogtreecommitdiffstats
path: root/no_mask.patch
blob: bc2204ea3b35e2aee31383cf259ca12756579241 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/diff/diff.go b/staging/src/k8s.io/kubectl/pkg/cmd/diff/diff.go
index 72d16b716da..37bb247f5bd 100644
--- a/staging/src/k8s.io/kubectl/pkg/cmd/diff/diff.go
+++ b/staging/src/k8s.io/kubectl/pkg/cmd/diff/diff.go
@@ -17,6 +17,7 @@ limitations under the License.
 package diff
 
 import (
+	"encoding/base64"
 	"fmt"
 	"io"
 	"os"
@@ -556,6 +557,29 @@ func NewDiffer(from, to string) (*Differ, error) {
 	return &differ, nil
 }
 
+func fixSecret(src runtime.Object) runtime.Object {
+	u, ok := src.(*unstructured.Unstructured)
+	if !ok {
+		return src
+	}
+	data, found, err := unstructured.NestedMap(u.UnstructuredContent(), "data")
+	if err != nil || !found {
+		return src
+	}
+	for k, v := range data {
+		if s, ok := v.(string); ok {
+			decoded, _ := base64.StdEncoding.DecodeString(s)
+			data[k] = string(decoded)
+		}
+	}
+	if err := unstructured.SetNestedMap(u.UnstructuredContent(), data, "stringData"); err != nil {
+		return src
+	}
+
+	unstructured.SetNestedMap(u.UnstructuredContent(), nil, "data")
+	return u
+}
+
 // Diff diffs to versions of a specific object, and print both versions to directories.
 func (d *Differ) Diff(obj Object, printer Printer, showManagedFields bool) error {
 	from, err := d.From.getObject(obj)
@@ -572,13 +596,9 @@ func (d *Differ) Diff(obj Object, printer Printer, showManagedFields bool) error
 		to = omitManagedFields(to)
 	}
 
-	// Mask secret values if object is V1Secret
 	if gvk := to.GetObjectKind().GroupVersionKind(); gvk.Version == "v1" && gvk.Kind == "Secret" {
-		m, err := NewMasker(from, to)
-		if err != nil {
-			return err
-		}
-		from, to = m.From(), m.To()
+		from = fixSecret(from)
+		to = fixSecret(to)
 	}
 
 	if err := d.From.Print(obj.Name(), from, printer); err != nil {
diff --git a/vendor/gopkg.in/yaml.v2/emitterc.go b/vendor/gopkg.in/yaml.v2/emitterc.go
index a1c2cc52627..466957fd32c 100644
--- a/vendor/gopkg.in/yaml.v2/emitterc.go
+++ b/vendor/gopkg.in/yaml.v2/emitterc.go
@@ -830,11 +830,11 @@ func yaml_emitter_select_scalar_style(emitter *yaml_emitter_t, event *yaml_event
 			style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
 		}
 	}
-	if style == yaml_LITERAL_SCALAR_STYLE || style == yaml_FOLDED_SCALAR_STYLE {
-		if !emitter.scalar_data.block_allowed || emitter.flow_level > 0 || emitter.simple_key_context {
-			style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
-		}
-	}
+	// if style == yaml_LITERAL_SCALAR_STYLE || style == yaml_FOLDED_SCALAR_STYLE {
+	// 	if !emitter.scalar_data.block_allowed || emitter.flow_level > 0 || emitter.simple_key_context {
+	// 		style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
+	// 	}
+	// }
 
 	if no_tag && !event.quoted_implicit && style != yaml_PLAIN_SCALAR_STYLE {
 		emitter.tag_data.handle = []byte{'!'}
diff --git a/vendor/gopkg.in/yaml.v3/emitterc.go b/vendor/gopkg.in/yaml.v3/emitterc.go
index 0f47c9ca8ad..1d9b16ab618 100644
--- a/vendor/gopkg.in/yaml.v3/emitterc.go
+++ b/vendor/gopkg.in/yaml.v3/emitterc.go
@@ -162,10 +162,9 @@ func yaml_emitter_emit(emitter *yaml_emitter_t, event *yaml_event_t) bool {
 // Check if we need to accumulate more events before emitting.
 //
 // We accumulate extra
-//  - 1 event for DOCUMENT-START
-//  - 2 events for SEQUENCE-START
-//  - 3 events for MAPPING-START
-//
+//   - 1 event for DOCUMENT-START
+//   - 2 events for SEQUENCE-START
+//   - 3 events for MAPPING-START
 func yaml_emitter_need_more_events(emitter *yaml_emitter_t) bool {
 	if emitter.events_head == len(emitter.events) {
 		return true
@@ -241,7 +240,7 @@ func yaml_emitter_increase_indent(emitter *yaml_emitter_t, flow, indentless bool
 			emitter.indent += 2
 		} else {
 			// Everything else aligns to the chosen indentation.
-			emitter.indent = emitter.best_indent*((emitter.indent+emitter.best_indent)/emitter.best_indent)
+			emitter.indent = emitter.best_indent * ((emitter.indent + emitter.best_indent) / emitter.best_indent)
 		}
 	}
 	return true
@@ -1036,11 +1035,11 @@ func yaml_emitter_select_scalar_style(emitter *yaml_emitter_t, event *yaml_event
 			style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
 		}
 	}
-	if style == yaml_LITERAL_SCALAR_STYLE || style == yaml_FOLDED_SCALAR_STYLE {
-		if !emitter.scalar_data.block_allowed || emitter.flow_level > 0 || emitter.simple_key_context {
-			style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
-		}
-	}
+	// if style == yaml_LITERAL_SCALAR_STYLE || style == yaml_FOLDED_SCALAR_STYLE {
+	// 	if !emitter.scalar_data.block_allowed || emitter.flow_level > 0 || emitter.simple_key_context {
+	// 		style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
+	// 	}
+	// }
 
 	if no_tag && !event.quoted_implicit && style != yaml_PLAIN_SCALAR_STYLE {
 		emitter.tag_data.handle = []byte{'!'}