Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publicly expose terraform.ParsePlanJSON function #1309

Merged
merged 1 commit into from
Jul 10, 2023
Merged
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
2 changes: 1 addition & 1 deletion modules/terraform/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func InitAndPlanAndShowWithStructE(t testing.TestingT, options *Options) (*PlanS
if err != nil {
return nil, err
}
return parsePlanJson(jsonOut)
return ParsePlanJSON(jsonOut)
}

// InitAndPlanWithExitCode runs terraform init and plan with the given options and returns exitcode for the plan command.
Expand Down
4 changes: 2 additions & 2 deletions modules/terraform/plan_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ type PlanStruct struct {
ResourceChangesMap map[string]*tfjson.ResourceChange
}

// parsePlanJson takes in the json string representation of the terraform plan and returns a go struct representation
// ParsePlanJSON takes in the json string representation of the terraform plan and returns a go struct representation
// for easy introspection.
func parsePlanJson(jsonStr string) (*PlanStruct, error) {
func ParsePlanJSON(jsonStr string) (*PlanStruct, error) {
plan := &PlanStruct{}

if err := json.Unmarshal([]byte(jsonStr), &plan.RawPlan); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions modules/terraform/plan_struct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestPlannedValuesMapWithBasicJson(t *testing.T) {

// Retrieve test data from the terraform-json project.
_, jsonData := http_helper.HttpGet(t, basicJsonUrl, nil)
plan, err := parsePlanJson(jsonData)
plan, err := ParsePlanJSON(jsonData)
require.NoError(t, err)

query := []string{
Expand All @@ -48,7 +48,7 @@ func TestPlannedValuesMapWithDeepModuleJson(t *testing.T) {

// Retrieve test data from the terraform-json project.
_, jsonData := http_helper.HttpGet(t, deepModuleJsonUrl, nil)
plan, err := parsePlanJson(jsonData)
plan, err := ParsePlanJSON(jsonData)
require.NoError(t, err)

query := []string{
Expand All @@ -64,7 +64,7 @@ func TestResourceChangesJson(t *testing.T) {

// Retrieve test data from the terraform-json project.
_, jsonData := http_helper.HttpGet(t, changesJsonUrl, nil)
plan, err := parsePlanJson(jsonData)
plan, err := ParsePlanJSON(jsonData)
require.NoError(t, err)

// Spot check a few changes to make sure the right address was registered
Expand Down
2 changes: 1 addition & 1 deletion modules/terraform/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func ShowWithStructE(t testing.TestingT, options *Options) (*PlanStruct, error)
if err != nil {
return nil, err
}
planStruct, err := parsePlanJson(json)
planStruct, err := ParsePlanJSON(json)
if err != nil {
return nil, err
}
Expand Down