Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var (
useJson bool
metrics bool
prettyJSON bool
hideDetails bool
)

func init() {
Expand All @@ -34,6 +35,7 @@ func init() {
summarizeCmd.Flags().BoolVarP(&useJson, "json", "j", false, "Use JSON output")
summarizeCmd.Flags().BoolVarP(&metrics, "metrics", "s", false, "Output metrics")
summarizeCmd.Flags().BoolVarP(&prettyJSON, "pretty-json", "p", false, "Pretty JSON output")
summarizeCmd.Flags().BoolVarP(&hideDetails, "hide-details", "d", false, "Hide details of changes")
}

// summarizeCmd will parse the tf plan output json to scrape created|updated|deleted resources in a clear outout
Expand All @@ -57,7 +59,7 @@ var summarizeCmd = &cobra.Command{
panic(err)
}

parser.Parser(output, showTags, showUnchanged, compact, useMarkdown, useJson, metrics, prettyJSON)
parser.Parser(output, showTags, showUnchanged, compact, useMarkdown, useJson, metrics, prettyJSON, hideDetails)
},
}

Expand Down
8 changes: 4 additions & 4 deletions internal/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ var (
resourcesList = make(map[string][]string)
)

func Parser(output []byte, showTags, showUnchanged, compact, useMarkdown bool, useJson bool, metrics bool, prettyJSON bool) {
func Parser(output []byte, showTags, showUnchanged, compact, useMarkdown bool, useJson bool, metrics bool, prettyJSON bool, hideDetails bool) {
var data tfjson.Plan
if err := json.Unmarshal(output, &data); err != nil {
fmt.Printf("Error unmarshalling plan: %v\n", err)
return
}

for _, resourceChange := range data.ResourceChanges {
processResourceChange(resourceChange, showTags)
processResourceChange(resourceChange, showTags, hideDetails)
}

PrintPlanSummary(showTags, showUnchanged, compact, useMarkdown, useJson, metrics, prettyJSON)
}

func processResourceChange(resourceChange *tfjson.ResourceChange, showTags bool) {
func processResourceChange(resourceChange *tfjson.ResourceChange, showTags bool, hideDetails bool) {
isUpdate := contains(resourceChange.Change.Actions, tfjson.ActionUpdate)

if isUpdate {
Expand All @@ -60,7 +60,7 @@ func processResourceChange(resourceChange *tfjson.ResourceChange, showTags bool)
}

detailedChanges := processDetailedChanges(resourceChange)
if detailedChanges != "" {
if detailedChanges != "" && !hideDetails {
addActionToResourceListWithDetails(resourceChange.Change.Actions, resourceChange.Address, detailedChanges)
} else {
addActionToResourceList(resourceChange.Change.Actions, resourceChange.Address)
Expand Down