Skip to content

Commit

Permalink
Includes sensitive flag in yaml/json output of porter explain. (getpo…
Browse files Browse the repository at this point in the history
…rter#2440)

* Included sensitive flag in yaml/json output

Signed-off-by: MadhuMPandurangi <[email protected]>

* Set "writeonly ":true in the parameters definition

Signed-off-by: MadhuMPandurangi <[email protected]>

Signed-off-by: MadhuMPandurangi <[email protected]>
Co-authored-by: Carolyn Van Slyck <[email protected]>
  • Loading branch information
MadhuMPandurangi and carolynvs authored Nov 16, 2022
1 parent c9cfdf5 commit 620f014
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 2 additions & 0 deletions pkg/porter/explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions pkg/porter/testdata/explain/expected-json-output.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,26 @@
"default": null,
"applyTo": "upgrade",
"description": "",
"required": false
"required": false,
"sensitive": false
},
{
"name": "region",
"type": "string",
"default": "mars",
"applyTo": "All Actions",
"description": "",
"required": false
"required": false,
"sensitive": false
},
{
"name": "seed",
"type": "boolean",
"default": null,
"applyTo": "All Actions",
"description": "",
"required": true
"required": true,
"sensitive": true
}
],
"mixins": [
Expand Down
3 changes: 3 additions & 0 deletions pkg/porter/testdata/explain/expected-yaml-output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion pkg/porter/testdata/explain/params-bundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"type": "string"
},
"seed": {
"type": "boolean"
"type": "boolean",
"writeOnly": true
},
"namespace": {
"type": "string"
Expand Down

0 comments on commit 620f014

Please sign in to comment.