Merge pull request #7084 from hashicorp/packer_inspect_sensitive

make packer inspect not print sensitive variables.
This commit is contained in:
Adrien Delorme 2018-12-10 12:16:55 +01:00 committed by GitHub
commit ecc20cf816
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -50,6 +50,11 @@ func (c *InspectCommand) Run(args []string) int {
} else {
requiredHeader := false
for k, v := range tpl.Variables {
for _, sensitive := range tpl.SensitiveVariables {
if ok := strings.Compare(sensitive.Default, v.Default); ok == 0 {
v.Default = "<sensitive>"
}
}
if v.Required {
if !requiredHeader {
requiredHeader = true
@ -82,6 +87,11 @@ func (c *InspectCommand) Run(args []string) int {
if v.Required {
continue
}
for _, sensitive := range tpl.SensitiveVariables {
if ok := strings.Compare(sensitive.Default, v.Default); ok == 0 {
v.Default = "<sensitive>"
}
}
padding := strings.Repeat(" ", max-len(k))
output := fmt.Sprintf(" %s%s = %s", k, padding, v.Default)