From 620f01488e2ebb093e7fc0dbfd092bb30c6f9327 Mon Sep 17 00:00:00 2001 From: 2022H1030026G Date: Thu, 17 Nov 2022 03:57:27 +0530 Subject: [PATCH] Includes sensitive flag in yaml/json output of porter explain. (#2440) * Included sensitive flag in yaml/json output Signed-off-by: MadhuMPandurangi * Set "writeonly ":true in the parameters definition Signed-off-by: MadhuMPandurangi Signed-off-by: MadhuMPandurangi Co-authored-by: Carolyn Van Slyck --- CONTRIBUTORS.md | 1 + pkg/porter/explain.go | 2 ++ pkg/porter/testdata/explain/expected-json-output.json | 9 ++++++--- pkg/porter/testdata/explain/expected-yaml-output.yaml | 3 +++ pkg/porter/testdata/explain/params-bundle.json | 3 ++- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index dcf627b2e..9e510e27e 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -74,3 +74,4 @@ and we will add you. **All** contributors belong here. 💯 * [Kevin Barbour](https://github.com/kevinbarbour) * [Epsxy](https://github.com/epsxy) * [Jens Arnfast](https://github.com/jarnfast) +* [Madhu M Pandurangi](https://github.com/MadhuMPandurangi) diff --git a/pkg/porter/explain.go b/pkg/porter/explain.go index 8b5ffbe61..a46866a86 100644 --- a/pkg/porter/explain.go +++ b/pkg/porter/explain.go @@ -90,6 +90,7 @@ type PrintableParameter struct { ApplyTo string `json:"applyTo" yaml:"applyTo"` Description string `json:"description" yaml:"description"` Required bool `json:"required" yaml:"required"` + Sensitive bool `json:"sensitive" yaml:"sensitive"` } type SortPrintableParameter []PrintableParameter @@ -251,6 +252,7 @@ func generatePrintable(bun cnab.ExtendedBundle, action string) (*PrintableBundle pp.ApplyTo = generateApplyToString(v.ApplyTo) pp.Required = v.Required pp.Description = v.Description + pp.Sensitive = bun.IsSensitiveParameter((p)) if shouldIncludeInExplainOutput(&v, action) { pb.Parameters = append(pb.Parameters, pp) diff --git a/pkg/porter/testdata/explain/expected-json-output.json b/pkg/porter/testdata/explain/expected-json-output.json index bce5d3d95..87bdd7611 100644 --- a/pkg/porter/testdata/explain/expected-json-output.json +++ b/pkg/porter/testdata/explain/expected-json-output.json @@ -10,7 +10,8 @@ "default": null, "applyTo": "upgrade", "description": "", - "required": false + "required": false, + "sensitive": false }, { "name": "region", @@ -18,7 +19,8 @@ "default": "mars", "applyTo": "All Actions", "description": "", - "required": false + "required": false, + "sensitive": false }, { "name": "seed", @@ -26,7 +28,8 @@ "default": null, "applyTo": "All Actions", "description": "", - "required": true + "required": true, + "sensitive": true } ], "mixins": [ diff --git a/pkg/porter/testdata/explain/expected-yaml-output.yaml b/pkg/porter/testdata/explain/expected-yaml-output.yaml index 50fde1a4b..f49721c8c 100644 --- a/pkg/porter/testdata/explain/expected-yaml-output.yaml +++ b/pkg/porter/testdata/explain/expected-yaml-output.yaml @@ -9,18 +9,21 @@ parameters: applyTo: upgrade description: "" required: false + sensitive: false - name: region type: string default: mars applyTo: All Actions description: "" required: false + sensitive: false - name: seed type: boolean default: null applyTo: All Actions description: "" required: true + sensitive: true mixins: - helm - terraform diff --git a/pkg/porter/testdata/explain/params-bundle.json b/pkg/porter/testdata/explain/params-bundle.json index fa760dadb..0090755ea 100644 --- a/pkg/porter/testdata/explain/params-bundle.json +++ b/pkg/porter/testdata/explain/params-bundle.json @@ -23,7 +23,8 @@ "type": "string" }, "seed": { - "type": "boolean" + "type": "boolean", + "writeOnly": true }, "namespace": { "type": "string"