Skip to content

Commit

Permalink
Replace and update grafana-api-library with upstream, remove @pb82 fo…
Browse files Browse the repository at this point in the history
…rk (#994)
  • Loading branch information
HVBE committed Apr 16, 2023
1 parent 240412e commit 334f8da
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ spec:
type: array
folder:
type: string
gzipJson:
format: byte
type: string
instanceSelector:
properties:
matchExpressions:
Expand Down
14 changes: 7 additions & 7 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
resources:
- manager.yaml
- manager.yaml

generatorOptions:
disableNameSuffixHash: true

configMapGenerator:
- files:
- controller_manager_config.yaml
name: manager-config
- files:
- controller_manager_config.yaml
name: manager-config
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: ghcr.io/grafana-operator/grafana-operator
newTag: v5.0.0
- name: controller
newName: ghcr.io/grafana-operator/grafana-operator
newTag: v5.0.0
4 changes: 2 additions & 2 deletions controllers/dashboard_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func (r *GrafanaDashboardReconciler) onDashboardDeleted(ctx context.Context, nam
}

if dash != nil && dash.Meta.Folder > 0 {
resp, err := r.DeleteFolderIfEmpty(grafanaClient, dash.Folder)
resp, err := r.DeleteFolderIfEmpty(grafanaClient, dash.FolderID)
if err != nil {
return err
}
Expand Down Expand Up @@ -339,7 +339,7 @@ func (r *GrafanaDashboardReconciler) onDashboardCreated(ctx context.Context, gra
Folder: folderID,
},
Model: dashboardFromJson,
Folder: folderID,
FolderID: folderID,
Overwrite: true,
Message: "",
})
Expand Down
14 changes: 11 additions & 3 deletions controllers/datasource_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controllers

import (
"context"
"encoding/json"
"fmt"
"strings"
"time"
Expand Down Expand Up @@ -289,19 +290,26 @@ func (r *GrafanaDatasourceReconciler) onDatasourceCreated(ctx context.Context, g

// always use the same uid for CR and datasource
cr.Spec.Datasource.UID = string(cr.UID)
datasourceBytes, err := cr.ExpandVariables(variables)
rawDatasourceBytes, err := cr.ExpandVariables(variables)
if err != nil {
return err
}

var unmarshalledDatasource gapi.DataSource

err = json.Unmarshal(rawDatasourceBytes, &unmarshalledDatasource)
if err != nil {
return err
}

switch {
case id == nil:
_, err = grafanaClient.NewDataSourceFromRawData(datasourceBytes)
_, err = grafanaClient.NewDataSource(&unmarshalledDatasource)
if err != nil && !strings.Contains(err.Error(), "status: 409") {
return err
}
case !cr.Unchanged():
err := grafanaClient.UpdateDataSourceFromRawData(*id, datasourceBytes)
err := grafanaClient.UpdateDataSource(&unmarshalledDatasource)
if err != nil {
return err
}
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/blang/semver v3.5.1+incompatible
github.com/go-logr/logr v1.2.4
github.com/google/go-jsonnet v0.19.1
github.com/grafana/grafana-api-golang-client v0.9.2
github.com/grafana/grafana-api-golang-client v0.18.4
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.27.6
github.com/openshift/api v3.9.0+incompatible
Expand Down Expand Up @@ -88,5 +88,3 @@ require (
)

replace github.com/openshift/api => github.com/openshift/api v0.0.0-20190924102528-32369d4db2ad

replace github.com/grafana/grafana-api-golang-client => github.com/pb82/grafana-api-golang-client v0.9.4
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0=
github.com/grafana/grafana-api-golang-client v0.18.4 h1:YpxmbG1OWssE1ko80Ixd/XioSrIqY/ZpwQ4h1D0xJ2E=
github.com/grafana/grafana-api-golang-client v0.18.4/go.mod h1:24W29gPe9yl0/3A9X624TPkAOR8DpHno490cPwnkv8E=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
Expand Down Expand Up @@ -304,8 +306,6 @@ github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg=
github.com/openshift/api v0.0.0-20190924102528-32369d4db2ad h1:MiZEukiPd7ll8BQDwBfc3LKBxbqyeXIx+wl4CzVj5EQ=
github.com/openshift/api v0.0.0-20190924102528-32369d4db2ad/go.mod h1:dh9o4Fs58gpFXGSYfnVxGR9PnV53I8TW84pQaJDdGiY=
github.com/pb82/grafana-api-golang-client v0.9.4 h1:W0NTTgebYC5I7wCH35s28Nwc0XxbOkn19cWjhm1n1pE=
github.com/pb82/grafana-api-golang-client v0.9.4/go.mod h1:M3Ow9DiK5nfHfERJUZjKy3dDlLyeIjwiDp00lKhSfyY=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down

0 comments on commit 334f8da

Please sign in to comment.