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

bump client to latest, fix precision and yaxis.include_* fields #127

Merged
merged 1 commit into from
Nov 28, 2018
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
31 changes: 25 additions & 6 deletions datadog/resource_datadog_timeboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,23 @@ func resourceDatadogTimeboard() *schema.Resource {
"yaxis": &schema.Schema{
Type: schema.TypeMap,
Optional: true,
// `include_zero` and `include_units` are bool but Terraform treats them as strings
// as part of the `yaxis` map so we suppress the diff when
// value in the state and value from the api are the same
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
var oldBool, newBool bool
var err error

if oldBool, err = strconv.ParseBool(old); err != nil {
return false
}

if newBool, err = strconv.ParseBool(new); err != nil {
return false
}

return oldBool == newBool
},
},
"autoscale": &schema.Schema{
Type: schema.TypeBool,
Expand Down Expand Up @@ -440,12 +457,14 @@ func buildGraphs(terraformGraphs *[]interface{}) *[]datadog.Graph {
if v, ok := yaxis["scale"]; ok {
d.Definition.Yaxis.SetScale(v.(string))
}
if v, ok := t["include_zero"]; ok {
d.Definition.Yaxis.SetIncludeZero(v.(bool))
if v, ok := yaxis["include_zero"]; ok {
b, _ := strconv.ParseBool(v.(string))
d.Definition.Yaxis.SetIncludeZero(b)
}

if v, ok := t["include_units"]; ok {
d.Definition.Yaxis.SetIncludeUnits(v.(bool))
if v, ok := yaxis["include_units"]; ok {
b, _ := strconv.ParseBool(v.(string))
d.Definition.Yaxis.SetIncludeUnits(b)
}
}

Expand All @@ -460,7 +479,7 @@ func buildGraphs(terraformGraphs *[]interface{}) *[]datadog.Graph {
if precision, ok := t["precision"]; ok {
val := precision.(string)
if val != "" {
d.Definition.SetPrecision(json.Number(val))
d.Definition.SetPrecision(datadog.PrecisionT(val))
}
}

Expand Down Expand Up @@ -692,7 +711,7 @@ func buildTerraformGraph(datadogGraph datadog.Graph) map[string]interface{} {
}

if v, ok := definition.Yaxis.GetIncludeUnitsOk(); ok {
yaxis["include_unis"] = strconv.FormatBool(v)
yaxis["include_units"] = strconv.FormatBool(v)
}

graph["yaxis"] = yaxis
Expand Down
8 changes: 4 additions & 4 deletions datadog/resource_datadog_timeboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ resource "datadog_timeboard" "acceptance_test" {

func TestAccDatadogTimeboard_update(t *testing.T) {

step1 := resource.TestStep{
step0 := resource.TestStep{
Config: config1,
Check: resource.ComposeTestCheckFunc(
checkExists,
Expand All @@ -147,7 +147,7 @@ func TestAccDatadogTimeboard_update(t *testing.T) {
),
}

step2 := resource.TestStep{
step1 := resource.TestStep{
Config: config2,
Check: resource.ComposeTestCheckFunc(
checkExists,
Expand All @@ -171,7 +171,7 @@ func TestAccDatadogTimeboard_update(t *testing.T) {
),
}

step3 := resource.TestStep{
step2 := resource.TestStep{
Config: config3,
Check: resource.ComposeTestCheckFunc(
checkExists,
Expand Down Expand Up @@ -211,7 +211,7 @@ func TestAccDatadogTimeboard_update(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: checkDestroy,
Steps: []resource.TestStep{step1, step2, step3},
Steps: []resource.TestStep{step0, step1, step2},
})
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions vendor/github.com/zorkian/go-datadog-api/helpers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -932,12 +932,10 @@
"revisionTime": "2018-10-17T23:26:04Z"
},
{
"checksumSHA1": "789joLgasdUcxF6qQy8Pn+IfGhw=",
"checksumSHA1": "R+mXTTMaw8ucB7pQDD0p+X13dK8=",
"path": "github.com/zorkian/go-datadog-api",
"revision": "f3f6d2f4859047aae0cac1ce3d16689608480fd9",
"revisionTime": "2018-11-12T21:37:59Z",
"version": "v2.18.0",
"versionExact": "v2.18.0"
"revision": "1df5bda80d16ccfa8e99c543dbeb731665acbfca",
"revisionTime": "2018-11-27T19:12:41Z"
},
{
"checksumSHA1": "vE43s37+4CJ2CDU6TlOUOYE0K9c=",
Expand Down