Skip to content

Commit

Permalink
Update provider to 1.32.0
Browse files Browse the repository at this point in the history
Fix dashboard reference for reports and dashboard permissions
  • Loading branch information
julienduchesne committed Dec 12, 2022
1 parent 88c037b commit b5a0ed9
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 62 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
PROJECT_NAME := provider-grafana
PROJECT_REPO := github.com/grafana/crossplane-provider-grafana

export TERRAFORM_VERSION := 1.3.5
export TERRAFORM_VERSION := 1.3.6

export TERRAFORM_PROVIDER_SOURCE := grafana/grafana
export TERRAFORM_PROVIDER_REPO := https://github.com/grafana/terraform-provider-grafana
export TERRAFORM_PROVIDER_VERSION := 1.31.1
export TERRAFORM_PROVIDER_VERSION := 1.32.0
export TERRAFORM_PROVIDER_DOWNLOAD_NAME := terraform-provider-grafana
export TERRAFORM_NATIVE_PROVIDER_BINARY := terraform-provider-grafana_v1.31.1
export TERRAFORM_NATIVE_PROVIDER_BINARY := terraform-provider-grafana_v1.32.0
export TERRAFORM_DOCS_PATH := docs/resources

PLATFORMS ?= linux_amd64 linux_arm64
Expand Down
7 changes: 6 additions & 1 deletion apis/enterprise/v1alpha1/zz_generated.deepcopy.go

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

8 changes: 4 additions & 4 deletions apis/enterprise/v1alpha1/zz_generated.resolvers.go

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

20 changes: 12 additions & 8 deletions apis/enterprise/v1alpha1/zz_report_types.go

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

20 changes: 12 additions & 8 deletions apis/oss/v1alpha1/zz_dashboardpermission_types.go

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

7 changes: 6 additions & 1 deletion apis/oss/v1alpha1/zz_generated.deepcopy.go

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

8 changes: 4 additions & 4 deletions apis/oss/v1alpha1/zz_generated.resolvers.go

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

2 changes: 1 addition & 1 deletion build
11 changes: 4 additions & 7 deletions config/grafana/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"encoding/json"
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ujconfig "github.com/upbound/upjet/pkg/config"
)

Expand Down Expand Up @@ -53,12 +52,11 @@ func Configure(p *ujconfig.Provider) {
}
})
p.AddResourceConfigurator("grafana_dashboard_permission", func(r *ujconfig.Resource) {
r.TerraformResource.Schema["dashboard_id"].Type = schema.TypeString // hack because it seems like upjet doesn't support number references
r.References["dashboard_id"] = ujconfig.Reference{
r.References["dashboard_uid"] = ujconfig.Reference{
TerraformName: "grafana_dashboard",
RefFieldName: "DashboardRef",
SelectorFieldName: "DashboardSelector",
Extractor: SelfPackagePath + ".DashboardIDExtractor()",
Extractor: SelfPackagePath + ".UIDExtractor()",
}
})
p.AddResourceConfigurator("grafana_data_source", func(r *ujconfig.Resource) {
Expand All @@ -84,12 +82,11 @@ func Configure(p *ujconfig.Provider) {
}
})
p.AddResourceConfigurator("grafana_report", func(r *ujconfig.Resource) {
r.TerraformResource.Schema["dashboard_id"].Type = schema.TypeString // hack because it seems like upjet doesn't support number references
r.References["dashboard_id"] = ujconfig.Reference{
r.References["dashboard_uid"] = ujconfig.Reference{
TerraformName: "grafana_dashboard",
RefFieldName: "DashboardRef",
SelectorFieldName: "DashboardSelector",
Extractor: SelfPackagePath + ".DashboardIDExtractor()",
Extractor: SelfPackagePath + ".UIDExtractor()",
}
})
p.AddResourceConfigurator("grafana_rule_group", func(r *ujconfig.Resource) {
Expand Down
15 changes: 0 additions & 15 deletions config/grafana/extractors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,6 @@ func CloudStackSlugExtractor() reference.ExtractValueFn {
}
}

// nolint: golint
func DashboardIDExtractor() reference.ExtractValueFn {
return func(mg xpresource.Managed) string {
paved, err := fieldpath.PaveObject(mg)
if err != nil {
return ""
}
r, err := paved.GetString("status.atProvider.dashboard_id")
if err != nil {
return ""
}
return r
}
}

// nolint: golint
func NameExtractor() reference.ExtractValueFn {
return func(mg xpresource.Managed) string {
Expand Down
2 changes: 1 addition & 1 deletion config/schema.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.19
require (
github.com/crossplane/crossplane-runtime v0.19.0-rc.0.0.20221012013934-bce61005a175
github.com/crossplane/crossplane-tools v0.0.0-20220310165030-1f43fc12793e
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.0
github.com/pkg/errors v0.9.1
github.com/upbound/upjet v0.8.0-rc.0.0.20221125163125-2bd418a5521b
gopkg.in/alecthomas/kingpin.v2 v2.2.6
Expand Down Expand Up @@ -73,6 +72,7 @@ require (
github.com/hashicorp/terraform-json v0.14.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.14.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.7.0 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.0 // indirect
github.com/hashicorp/vault/api v1.3.1 // indirect
github.com/hashicorp/vault/sdk v0.3.0 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
Expand Down
12 changes: 8 additions & 4 deletions package/crds/enterprise.grafana.crossplane.io_reports.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ spec:
forProvider:
properties:
dashboardId:
description: Dashboard to be sent in the report.
type: string
description: Dashboard to be sent in the report. This field is
deprecated, use `dashboard_uid` instead.
type: number
dashboardRef:
description: Reference to a Dashboard in oss to populate dashboardId.
description: Reference to a Dashboard in oss to populate dashboardUid.
properties:
name:
description: Name of the referenced object.
Expand Down Expand Up @@ -101,7 +102,7 @@ spec:
- name
type: object
dashboardSelector:
description: Selector for a Dashboard in oss to populate dashboardId.
description: Selector for a Dashboard in oss to populate dashboardUid.
properties:
matchControllerRef:
description: MatchControllerRef ensures an object with the
Expand Down Expand Up @@ -139,6 +140,9 @@ spec:
type: string
type: object
type: object
dashboardUid:
description: Dashboard to be sent in the report.
type: string
includeDashboardLink:
description: Whether to include a link to the dashboard in the
report. Defaults to `true`.
Expand Down
12 changes: 8 additions & 4 deletions package/crds/oss.grafana.crossplane.io_dashboardpermissions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ spec:
forProvider:
properties:
dashboardId:
description: ID of the dashboard to apply permissions to.
type: string
description: 'ID of the dashboard to apply permissions to. Deprecated:
use `dashboard_uid` instead.'
type: number
dashboardRef:
description: Reference to a Dashboard in oss to populate dashboardId.
description: Reference to a Dashboard in oss to populate dashboardUid.
properties:
name:
description: Name of the referenced object.
Expand Down Expand Up @@ -102,7 +103,7 @@ spec:
- name
type: object
dashboardSelector:
description: Selector for a Dashboard in oss to populate dashboardId.
description: Selector for a Dashboard in oss to populate dashboardUid.
properties:
matchControllerRef:
description: MatchControllerRef ensures an object with the
Expand Down Expand Up @@ -140,6 +141,9 @@ spec:
type: string
type: object
type: object
dashboardUid:
description: UID of the dashboard to apply permissions to.
type: string
permissions:
description: The permission items to add/update. Items that are
omitted from the list will be removed.
Expand Down

0 comments on commit b5a0ed9

Please sign in to comment.