mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Route fixes for Azure Resource Graph (#34410)
This commit is contained in:
parent
b9f4ec2030
commit
e9e80bb4cb
@ -209,33 +209,37 @@ func (e *AzureResourceGraphDatasource) createRequest(ctx context.Context, dsInfo
|
|||||||
if plugin == nil {
|
if plugin == nil {
|
||||||
return nil, errors.New("unable to find datasource plugin Azure Monitor")
|
return nil, errors.New("unable to find datasource plugin Azure Monitor")
|
||||||
}
|
}
|
||||||
cloudName := dsInfo.JsonData.Get("cloudName").MustString("azuremonitor")
|
|
||||||
|
|
||||||
argRoute, proxypass, err := e.getPluginRoute(plugin, cloudName)
|
argRoute, routeName, err := e.getPluginRoute(plugin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
pluginproxy.ApplyRoute(ctx, req, proxypass, argRoute, dsInfo, e.cfg)
|
|
||||||
|
pluginproxy.ApplyRoute(ctx, req, routeName, argRoute, dsInfo, e.cfg)
|
||||||
|
|
||||||
return req, nil
|
return req, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *AzureResourceGraphDatasource) getPluginRoute(plugin *plugins.DataSourcePlugin, cloudName string) (
|
func (e *AzureResourceGraphDatasource) getPluginRoute(plugin *plugins.DataSourcePlugin) (*plugins.AppPluginRoute, string, error) {
|
||||||
*plugins.AppPluginRoute, string, error) {
|
cloud, err := getAzureCloud(e.cfg, e.dsInfo.JsonData)
|
||||||
pluginRouteName, err := getResourceGraphApiRoute(cloudName)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
var argRoute *plugins.AppPluginRoute
|
routeName, err := getResourceGraphApiRoute(cloud)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
var pluginRoute *plugins.AppPluginRoute
|
||||||
for _, route := range plugin.Routes {
|
for _, route := range plugin.Routes {
|
||||||
if route.Path == pluginRouteName {
|
if route.Path == routeName {
|
||||||
argRoute = route
|
pluginRoute = route
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return argRoute, pluginRouteName, nil
|
return pluginRoute, routeName, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *AzureResourceGraphDatasource) unmarshalResponse(res *http.Response) (AzureResourceGraphResponse, error) {
|
func (e *AzureResourceGraphDatasource) unmarshalResponse(res *http.Response) (AzureResourceGraphResponse, error) {
|
||||||
|
@ -52,6 +52,8 @@ func getResourceGraphApiRoute(azureCloud string) (string, error) {
|
|||||||
return "chinaazureresourcegraph", nil
|
return "chinaazureresourcegraph", nil
|
||||||
case azureMonitorUSGovernment:
|
case azureMonitorUSGovernment:
|
||||||
return "govazureresourcegraph", nil
|
return "govazureresourcegraph", nil
|
||||||
|
case azureMonitorGermany:
|
||||||
|
return "germanyazureresourcegraph", nil
|
||||||
default:
|
default:
|
||||||
err := fmt.Errorf("the cloud '%s' not supported", azureCloud)
|
err := fmt.Errorf("the cloud '%s' not supported", azureCloud)
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -105,11 +105,11 @@
|
|||||||
"tokenAuth": {
|
"tokenAuth": {
|
||||||
"scopes": ["https://management.azure.com/.default"],
|
"scopes": ["https://management.azure.com/.default"],
|
||||||
"params": {
|
"params": {
|
||||||
"azure_auth_type": "{{.JsonData.azureAuthType}}",
|
"azure_auth_type": "{{.JsonData.azureAuthType | orEmpty}}",
|
||||||
"azure_cloud": "AzureCloud",
|
"azure_cloud": "AzureCloud",
|
||||||
"tenant_id": "{{.JsonData.tenantId}}",
|
"tenant_id": "{{.JsonData.tenantId | orEmpty}}",
|
||||||
"client_id": "{{.JsonData.clientId}}",
|
"client_id": "{{.JsonData.clientId | orEmpty}}",
|
||||||
"client_secret": "{{.SecureJsonData.clientSecret}}"
|
"client_secret": "{{.SecureJsonData.clientSecret | orEmpty}}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"headers": [{ "name": "x-ms-app", "content": "Grafana" }]
|
"headers": [{ "name": "x-ms-app", "content": "Grafana" }]
|
||||||
@ -122,11 +122,11 @@
|
|||||||
"tokenAuth": {
|
"tokenAuth": {
|
||||||
"scopes": ["https://management.chinacloudapi.cn/.default"],
|
"scopes": ["https://management.chinacloudapi.cn/.default"],
|
||||||
"params": {
|
"params": {
|
||||||
"azure_auth_type": "{{.JsonData.azureAuthType}}",
|
"azure_auth_type": "{{.JsonData.azureAuthType | orEmpty}}",
|
||||||
"azure_cloud": "AzureChinaCloud",
|
"azure_cloud": "AzureChinaCloud",
|
||||||
"tenant_id": "{{.JsonData.tenantId}}",
|
"tenant_id": "{{.JsonData.tenantId | orEmpty}}",
|
||||||
"client_id": "{{.JsonData.clientId}}",
|
"client_id": "{{.JsonData.clientId | orEmpty}}",
|
||||||
"client_secret": "{{.SecureJsonData.clientSecret}}"
|
"client_secret": "{{.SecureJsonData.clientSecret | orEmpty}}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"headers": [{ "name": "x-ms-app", "content": "Grafana" }]
|
"headers": [{ "name": "x-ms-app", "content": "Grafana" }]
|
||||||
@ -139,11 +139,11 @@
|
|||||||
"tokenAuth": {
|
"tokenAuth": {
|
||||||
"scopes": ["https://management.usgovcloudapi.net/.default"],
|
"scopes": ["https://management.usgovcloudapi.net/.default"],
|
||||||
"params": {
|
"params": {
|
||||||
"azure_auth_type": "{{.JsonData.azureAuthType}}",
|
"azure_auth_type": "{{.JsonData.azureAuthType | orEmpty}}",
|
||||||
"azure_cloud": "AzureUSGovernment",
|
"azure_cloud": "AzureUSGovernment",
|
||||||
"tenant_id": "{{.JsonData.tenantId}}",
|
"tenant_id": "{{.JsonData.tenantId | orEmpty}}",
|
||||||
"client_id": "{{.JsonData.clientId}}",
|
"client_id": "{{.JsonData.clientId | orEmpty}}",
|
||||||
"client_secret": "{{.SecureJsonData.clientSecret}}"
|
"client_secret": "{{.SecureJsonData.clientSecret | orEmpty}}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"headers": [{ "name": "x-ms-app", "content": "Grafana" }]
|
"headers": [{ "name": "x-ms-app", "content": "Grafana" }]
|
||||||
@ -156,11 +156,11 @@
|
|||||||
"tokenAuth": {
|
"tokenAuth": {
|
||||||
"scopes": ["https://management.microsoftazure.de/.default"],
|
"scopes": ["https://management.microsoftazure.de/.default"],
|
||||||
"params": {
|
"params": {
|
||||||
"azure_auth_type": "{{.JsonData.azureAuthType}}",
|
"azure_auth_type": "{{.JsonData.azureAuthType | orEmpty}}",
|
||||||
"azure_cloud": "AzureGermanCloud",
|
"azure_cloud": "AzureGermanCloud",
|
||||||
"tenant_id": "{{.JsonData.tenantId}}",
|
"tenant_id": "{{.JsonData.tenantId | orEmpty}}",
|
||||||
"client_id": "{{.JsonData.clientId}}",
|
"client_id": "{{.JsonData.clientId | orEmpty}}",
|
||||||
"client_secret": "{{.SecureJsonData.clientSecret}}"
|
"client_secret": "{{.SecureJsonData.clientSecret | orEmpty}}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"headers": [{ "name": "x-ms-app", "content": "Grafana" }]
|
"headers": [{ "name": "x-ms-app", "content": "Grafana" }]
|
||||||
|
Loading…
Reference in New Issue
Block a user