Skip to content

Commit

Permalink
New option: -mask-sensitive to allow masking sensitive values (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
magodo authored Aug 9, 2024
1 parent 79ace00 commit 59efdda
Show file tree
Hide file tree
Showing 7 changed files with 354 additions and 142 deletions.
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Usage: tfadd [global options] state [options]
Options:
-full Output all non-computed properties in the generated config
-mask-sensitive Mask sensitive properties
-target=addr Only generate for the specified resource (can specify multiple times)
`
return strings.TrimSpace(helpText)
Expand All @@ -82,6 +83,7 @@ Options:
func (r *stateCommand) Run(args []string) int {
fset := defaultFlagSet("state")
flagFull := fset.Bool("full", false, "Whether to generate all non-computed properties")
flagMaskSensitive := fset.Bool("mask-sensitive", false, "Whether to mask sensitive properties")
var flagTargets arrayFlag
fset.Var(&flagTargets, "target", "Only generate for the specified resource")
if err := fset.Parse(args); err != nil {
Expand All @@ -103,7 +105,10 @@ func (r *stateCommand) Run(args []string) int {
fmt.Fprintf(os.Stderr, err.Error())
return 1
}
opts := []tfadd.StateOption{tfadd.Full(*flagFull)}
opts := []tfadd.OptionSetter{
tfadd.Full(*flagFull),
tfadd.MaskSenstitive(*flagMaskSensitive),
}

var template []byte
if len(flagTargets) == 0 {
Expand Down
7 changes: 7 additions & 0 deletions tfadd/internal/option.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package internal

type Option struct {
// Whether to mask the sensitive attributes in the generated config?
// Set via MaskSensitive option.
MaskSensitive bool
}
Loading

0 comments on commit 59efdda

Please sign in to comment.