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

Add support for more data_source json_data values #65

Closed
wants to merge 3 commits into from
Closed
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
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module github.com/terraform-providers/terraform-provider-grafana

go 1.12

require (
github.com/gobs/pretty v0.0.0-20180724170744-09732c25a95b // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/terraform v0.12.2
github.com/nytm/go-grafana-api v0.0.0-20181022152830-9cc848df7385
github.com/hashicorp/terraform v0.12.4
github.com/kalinon/go-grafana-api v0.0.0-20190712154808-9d3ff1ed93f4
)
101 changes: 14 additions & 87 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion grafana/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"

gapi "github.com/nytm/go-grafana-api"
gapi "github.com/kalinon/go-grafana-api"
)

func Provider() terraform.ResourceProvider {
Expand Down
2 changes: 1 addition & 1 deletion grafana/resource_alert_notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strconv"

"github.com/hashicorp/terraform/helper/schema"
gapi "github.com/nytm/go-grafana-api"
gapi "github.com/kalinon/go-grafana-api"
)

func ResourceAlertNotification() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion grafana/resource_alert_notification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strconv"
"testing"

gapi "github.com/nytm/go-grafana-api"
gapi "github.com/kalinon/go-grafana-api"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
Expand Down
2 changes: 1 addition & 1 deletion grafana/resource_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/hashicorp/terraform/helper/schema"

gapi "github.com/nytm/go-grafana-api"
gapi "github.com/kalinon/go-grafana-api"
)

func ResourceDashboard() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion grafana/resource_dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"testing"

gapi "github.com/nytm/go-grafana-api"
gapi "github.com/kalinon/go-grafana-api"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
Expand Down
20 changes: 17 additions & 3 deletions grafana/resource_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/hashicorp/terraform/helper/schema"

gapi "github.com/nytm/go-grafana-api"
gapi "github.com/kalinon/go-grafana-api"
)

func ResourceDataSource() *schema.Resource {
Expand Down Expand Up @@ -78,11 +78,11 @@ func ResourceDataSource() *schema.Resource {
Schema: map[string]*schema.Schema{
"auth_type": {
Type: schema.TypeString,
Required: true,
Optional: true,
},
"default_region": {
Type: schema.TypeString,
Required: true,
Optional: true,
},
"custom_metrics_namespaces": {
Type: schema.TypeString,
Expand All @@ -92,6 +92,18 @@ func ResourceDataSource() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"http_method": {
Type: schema.TypeString,
Optional: true,
},
"query_timeout": {
Type: schema.TypeString,
Optional: true,
},
"time_interval": {
Type: schema.TypeString,
Optional: true,
},
},
},
},
Expand Down Expand Up @@ -241,6 +253,8 @@ func makeJSONData(d *schema.ResourceData) gapi.JSONData {
DefaultRegion: d.Get("json_data.0.default_region").(string),
CustomMetricsNamespaces: d.Get("json_data.0.custom_metrics_namespaces").(string),
AssumeRoleArn: d.Get("json_data.0.assume_role_arn").(string),
HttpMethod: d.Get("json_data.0.http_method").(string),
TimeInterval: d.Get("json_data.0.time_interval").(string),
}
}

Expand Down
46 changes: 45 additions & 1 deletion grafana/resource_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strconv"
"testing"

gapi "github.com/nytm/go-grafana-api"
gapi "github.com/kalinon/go-grafana-api"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
Expand Down Expand Up @@ -78,6 +78,36 @@ func TestAccDataSource_basicCloudwatch(t *testing.T) {
})
}

func TestAccDataSource_basicPrometheus(t *testing.T) {
var dataSource gapi.DataSource

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccDataSourceCheckDestroy(&dataSource),
Steps: []resource.TestStep{
{
Config: testAccDataSourceConfig_basicPrometheus,
Check: resource.ComposeTestCheckFunc(
testAccDataSourceCheckExists("grafana_data_source.test_prometheus", &dataSource),
resource.TestCheckResourceAttr(
"grafana_data_source.test_prometheus", "type", "prometheus",
),
resource.TestCheckResourceAttr(
"grafana_data_source.test_prometheus", "json_data.0.http_method", "POST",
),
resource.TestCheckResourceAttr(
"grafana_data_source.test_prometheus", "json_data.0.query_timeout", "30s",
),
resource.TestCheckResourceAttr(
"grafana_data_source.test_prometheus", "json_data.0.time_interval", "1m",
),
),
},
},
})
}

func testAccDataSourceCheckExists(rn string, dataSource *gapi.DataSource) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[rn]
Expand Down Expand Up @@ -128,6 +158,7 @@ resource "grafana_data_source" "test_influxdb" {
basic_auth_password = "basic_password"
}
`

const testAccDataSourceConfig_basicCloudwatch = `
resource "grafana_data_source" "test_cloudwatch" {
type = "cloudwatch"
Expand All @@ -146,3 +177,16 @@ resource "grafana_data_source" "test_cloudwatch" {
}
}
`

const testAccDataSourceConfig_basicPrometheus = `
resource "grafana_data_source" "test_prometheus" {
type = "prometheus"
name = "terraform-acc-test-prometheus"

json_data {
http_method = "POST"
query_timeout = "30s"
time_interval = "1m"
}
}
`
2 changes: 1 addition & 1 deletion grafana/resource_folder.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/hashicorp/terraform/helper/schema"

gapi "github.com/nytm/go-grafana-api"
gapi "github.com/kalinon/go-grafana-api"
)

func ResourceFolder() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion grafana/resource_folder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strconv"
"testing"

gapi "github.com/nytm/go-grafana-api"
gapi "github.com/kalinon/go-grafana-api"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
Expand Down
2 changes: 1 addition & 1 deletion grafana/resource_organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"

"github.com/hashicorp/terraform/helper/schema"
gapi "github.com/nytm/go-grafana-api"
gapi "github.com/kalinon/go-grafana-api"
)

type OrgUser struct {
Expand Down
2 changes: 1 addition & 1 deletion grafana/resource_organization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
gapi "github.com/nytm/go-grafana-api"
gapi "github.com/kalinon/go-grafana-api"
)

func TestAccOrganization_basic(t *testing.T) {
Expand Down
23 changes: 21 additions & 2 deletions vendor/github.com/aws/aws-sdk-go/aws/awserr/error.go

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

29 changes: 28 additions & 1 deletion vendor/github.com/aws/aws-sdk-go/aws/awserr/types.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.

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.

2 changes: 1 addition & 1 deletion vendor/github.com/aws/aws-sdk-go/aws/csm/reporter.go

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

Loading