Skip to content

Commit

Permalink
feat: Expose show-changes option for exports
Browse files Browse the repository at this point in the history
  • Loading branch information
DanThePutzer committed Mar 13, 2022
1 parent 6e55f7e commit cbff6a8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/cmd/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func init() {
graphCmd.PersistentFlags().String("version", "", "The diagram version, will be displayed in the PDF output")
graphCmd.PersistentFlags().String("out-dir", "", "The directory the diagram should be exported to")
graphCmd.PersistentFlags().String("file-name", "", "The name of the exported PDF")
graphCmd.PersistentFlags().Bool("show-changes", false, "Determines whether the exported PDF highlights changes made in the latest Terraform plan or outputs a general diagram of the infrastructure")
graphCmd.PersistentFlags().Bool("skip-plan", false, "Generates a diagram without running plan again (needs pluralith state from previous plan run)")
graphCmd.PersistentFlags().Bool("generate-md", false, "Generate markdown output with exported PDF link and preview image for pull request comments")
}
4 changes: 4 additions & 0 deletions app/pkg/graph/ExportDiagram.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"pluralith/pkg/auxiliary"
"pluralith/pkg/ci"
"pluralith/pkg/ux"
"strconv"
"strings"
)

Expand Down Expand Up @@ -50,6 +51,8 @@ func ExportDiagram(diagramValues map[string]interface{}) error {
exportSpinner := ux.NewSpinner("Generating Diagram PDF", "PDF Export Successful!", "PDF Export Failed", true)
exportSpinner.Start()

fmt.Println(strconv.FormatBool(diagramValues["ShowChanges"].(bool)))

cmd := exec.Command(
graphModulePath,
"graph",
Expand All @@ -60,6 +63,7 @@ func ExportDiagram(diagramValues map[string]interface{}) error {
"--fileName", diagramValues["FileName"].(string),
"--outDir", diagramValues["OutDir"].(string),
"--planStatePath", diagramValues["PlanStatePath"].(string),
"--showChanges", strconv.FormatBool(diagramValues["ShowChanges"].(bool)),
)

// Defining sinks for std data
Expand Down
1 change: 1 addition & 0 deletions app/pkg/graph/GetDiagramValues.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func GetDiagramValues(flags *pflag.FlagSet) (map[string]interface{}, error) {
diagramValues["FileName"], _ = flags.GetString("file-name")
diagramValues["SkipPlan"], _ = flags.GetBool("skip-plan")
diagramValues["GenerateMd"], _ = flags.GetBool("generate-md")
diagramValues["ShowChanges"], _ = flags.GetBool("show-changes")

// If no explicit output directory given -> Write to current working directory
if diagramValues["OutDir"] == "" {
Expand Down

0 comments on commit cbff6a8

Please sign in to comment.