CloudMonitoring: Update sdks to latest (#65252)

* Upgrade grafana-google-sdk-go to v0.1.0

* Upgrade @grafana/google-sdk to 0.1.1

* Update doc with provisioning example

* Remove unused types

* Use config types from the sdk

* Add metrics
This commit is contained in:
Zoltán Bedi
2023-03-29 12:16:28 +02:00
committed by GitHub
parent 3696958632
commit 562d8dba5d
13 changed files with 74 additions and 50 deletions
+16 -13
View File
@@ -131,7 +131,7 @@ type Service struct {
resourceHandler backend.CallResourceHandler
// mocked in tests
gceDefaultProjectGetter func(ctx context.Context) (string, error)
gceDefaultProjectGetter func(ctx context.Context, scope string) (string, error)
}
type datasourceInfo struct {
@@ -143,8 +143,7 @@ type datasourceInfo struct {
clientEmail string
tokenUri string
services map[string]datasourceService
decryptedSecureJSONData map[string]string
privateKey string
}
type datasourceJSONData struct {
@@ -172,15 +171,19 @@ func newInstanceSettings(httpClientProvider httpclient.Provider) datasource.Inst
}
dsInfo := &datasourceInfo{
id: settings.ID,
updated: settings.Updated,
url: settings.URL,
authenticationType: jsonData.AuthenticationType,
defaultProject: jsonData.DefaultProject,
clientEmail: jsonData.ClientEmail,
tokenUri: jsonData.TokenURI,
decryptedSecureJSONData: settings.DecryptedSecureJSONData,
services: map[string]datasourceService{},
id: settings.ID,
updated: settings.Updated,
url: settings.URL,
authenticationType: jsonData.AuthenticationType,
defaultProject: jsonData.DefaultProject,
clientEmail: jsonData.ClientEmail,
tokenUri: jsonData.TokenURI,
services: map[string]datasourceService{},
}
dsInfo.privateKey, err = utils.GetPrivateKey(&settings)
if err != nil {
return nil, err
}
opts, err := settings.HTTPClientOptions()
@@ -571,7 +574,7 @@ func (s *Service) ensureProject(ctx context.Context, dsInfo datasourceInfo, proj
func (s *Service) getDefaultProject(ctx context.Context, dsInfo datasourceInfo) (string, error) {
if dsInfo.authenticationType == gceAuthentication {
return s.gceDefaultProjectGetter(ctx)
return s.gceDefaultProjectGetter(ctx, cloudMonitorScope)
}
return dsInfo.defaultProject, nil
}