Skip to content

Commit

Permalink
Rename structs and func (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
bendbennett committed Dec 14, 2023
1 parent 309258f commit d64e88d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions tfexec/internal/e2etest/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ func TestShowFloat64(t *testing.T) {
t.Fatalf("error running Apply in test directory: %s", err)
}

actual, err := tf.Show(context.Background(), tfexec.JSON(tfexec.JSONConfig{UseJSONNumber: false}))
actual, err := tf.Show(context.Background(), tfexec.JSONNumber(tfexec.UseJSONNumber{UseJSONNumber: false}))
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -959,7 +959,7 @@ func TestShowStateFileFloat64(t *testing.T) {
t.Fatalf("error running Apply in test directory: %s", err)
}

actual, err := tf.ShowStateFile(context.Background(), filepath.Join(tf.WorkingDir(), "terraform.tfstate"), tfexec.JSON(tfexec.JSONConfig{UseJSONNumber: false}))
actual, err := tf.ShowStateFile(context.Background(), filepath.Join(tf.WorkingDir(), "terraform.tfstate"), tfexec.JSONNumber(tfexec.UseJSONNumber{UseJSONNumber: false}))
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -1069,7 +1069,7 @@ func TestShowPlanFileBigInt(t *testing.T) {
t.Fatalf("error running Plan in test directory: %s", err)
}

actual, err := tf.ShowPlanFile(context.Background(), filepath.Join(tf.WorkingDir(), "tfplan"), tfexec.JSON(tfexec.JSONConfig{UseJSONNumber: true}))
actual, err := tf.ShowPlanFile(context.Background(), filepath.Join(tf.WorkingDir(), "tfplan"), tfexec.JSONNumber(tfexec.UseJSONNumber{UseJSONNumber: true}))
if err != nil {
t.Fatal(err)
}
Expand Down
12 changes: 6 additions & 6 deletions tfexec/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,17 @@ func GraphPlan(file string) *GraphPlanOption {
return &GraphPlanOption{file}
}

// JSONConfig holds information which determines how JSON is decoded.
type JSONConfig struct {
// UseJSONNumber determines how numerical values are handled when JSON is decoded.
type UseJSONNumber struct {
UseJSONNumber bool
}

type JSONOption struct {
config JSONConfig
type UseJSONNumberOption struct {
useJSONNumber UseJSONNumber
}

func JSON(config JSONConfig) *JSONOption {
return &JSONOption{config}
func JSONNumber(config UseJSONNumber) *UseJSONNumberOption {
return &UseJSONNumberOption{config}
}

type PlatformOption struct {
Expand Down
6 changes: 3 additions & 3 deletions tfexec/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

type showConfig struct {
reattachInfo ReattachInfo
jsonConfig *JSONConfig
jsonConfig *UseJSONNumber
}

var defaultShowOptions = showConfig{}
Expand All @@ -23,8 +23,8 @@ type ShowOption interface {
configureShow(*showConfig)
}

func (opt *JSONOption) configureShow(conf *showConfig) {
conf.jsonConfig = &opt.config
func (opt *UseJSONNumberOption) configureShow(conf *showConfig) {
conf.jsonConfig = &opt.useJSONNumber
}

func (opt *ReattachOption) configureShow(conf *showConfig) {
Expand Down

0 comments on commit d64e88d

Please sign in to comment.