Skip to content

Commit

Permalink
Wip: tfoutput changes
Browse files Browse the repository at this point in the history
  • Loading branch information
containerscrew committed May 7, 2024
1 parent 20209cb commit c77a026
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ SHELL:=/bin/sh
help: ## this help
@awk 'BEGIN {FS = ":.*?## "; printf "Usage:\n make \033[36m<target> \033[0m\n\nTargets:\n"} /^[a-zA-Z0-9_-]+:.*?## / {gsub("\\\\n",sprintf("\n%22c",""), $$2);printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

local-run: ## Run tftools locally
go run main.go summarize <demo.json

doctoc: ## Create table of contents with doctoc
doctoc .

Expand All @@ -25,6 +28,7 @@ gosec: ## Run gosec
update-dependencies: ## Update dependencies
go get -u ./...


##https://github.com/moovweb/gvm
##go get golang.org/x/tools/cmd/goimports
##go install golang.org/x/tools/cmd/goimports
3 changes: 2 additions & 1 deletion cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"log"
"os"
"runtime"

Expand Down Expand Up @@ -54,7 +55,7 @@ var summarizeCmd = &cobra.Command{

output, err := reader.Reader(os.Stdin)
if err != nil {
panic(err)
log.Fatal(err)
}

parser.Parser(output, showTags, showUnchanged, compact, useMarkdown, useJson, metrics, prettyJSON)
Expand Down
21 changes: 20 additions & 1 deletion demo.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"format_version": "1.1",
"terraform_version": "1.2.9",
"terraform_version": "1.8.1",
"planned_values": {
"outputs": {
"test": {
"sensitive": false,
"type": "string",
"value": "test2"
}
},
"root_module": {
"resources": [
{
Expand Down Expand Up @@ -567,6 +574,18 @@
}
}
],
"output_changes": {
"test": {
"actions": [
"update"
],
"before": "test1",
"after": "test2",
"after_unknown": false,
"before_sensitive": false,
"after_sensitive": false
}
},
"prior_state": {
"format_version": "1.0",
"terraform_version": "1.2.9",
Expand Down
2 changes: 2 additions & 0 deletions internal/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func Parser(output []byte, showTags, showUnchanged, compact, useMarkdown bool, u
return
}

// TODO: add also output changes using data.OutputChanges

Check failure on line 34 in internal/parser/parser.go

View workflow job for this annotation

GitHub Actions / Lint 🚀

File is not `gofmt`-ed with `-s` (gofmt)

Check failure on line 34 in internal/parser/parser.go

View workflow job for this annotation

GitHub Actions / Lint 🚀

File is not `gofmt`-ed with `-s` (gofmt)
for _, resourceChange := range data.ResourceChanges {
processResourceChange(resourceChange, showTags)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/reader/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ func Reader(stdin *os.File) ([]byte, error) {
}
return data, nil
}
return nil, fmt.Errorf("no data to be processed")
return nil, fmt.Errorf("no data to be processed. Please proide a valid tf plan json file")
}

0 comments on commit c77a026

Please sign in to comment.