From 7272e172b91c217c23e8a7a1d25bdf3b89ed6c25 Mon Sep 17 00:00:00 2001 From: Ved misra <47312748+misraved@users.noreply.github.com> Date: Fri, 7 Jan 2022 00:02:13 +0530 Subject: [PATCH] Rename common column `environment_name` to `cloud_environment` #416 (#438) --- azure/common_columns.go | 16 ++++++++-------- azure/monitoring_metric.go | 6 +++--- azure/service.go | 6 +++--- azure/table_azure_subscription.go | 6 +++--- azure/utils.go | 14 +++++++------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/azure/common_columns.go b/azure/common_columns.go index 4399e585..eac02a13 100644 --- a/azure/common_columns.go +++ b/azure/common_columns.go @@ -12,10 +12,10 @@ import ( func commonColumns() []*plugin.Column { return []*plugin.Column{ { - Name: "environment_name", + Name: "cloud_environment", Type: proto.ColumnType_STRING, - Hydrate: getEnvironmentName, - Description: ColumnDescriptionEnvironmentName, + Hydrate: getCloudEnvironment, + Description: ColumnDescriptionCloudEnvironment, Transform: transform.FromValue(), }, { @@ -52,9 +52,9 @@ func getSubscriptionID(ctx context.Context, d *plugin.QueryData, h *plugin.Hydra return session.SubscriptionID, nil } -func getEnvironmentName(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { - plugin.Logger(ctx).Trace("getEnvironmentName") - cacheKey := "getEnvironmentName" +func getCloudEnvironment(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + plugin.Logger(ctx).Trace("getCloudEnvironment") + cacheKey := "getCloudEnvironment" if cachedData, ok := d.ConnectionManager.Cache.Get(cacheKey); ok { return cachedData.(string), nil @@ -66,7 +66,7 @@ func getEnvironmentName(ctx context.Context, d *plugin.QueryData, h *plugin.Hydr } // cache environment name for the session - d.ConnectionManager.Cache.Set(cacheKey, session.EnvironmentName) + d.ConnectionManager.Cache.Set(cacheKey, session.CloudEnvironment) - return session.EnvironmentName, nil + return session.CloudEnvironment, nil } diff --git a/azure/monitoring_metric.go b/azure/monitoring_metric.go index ca3a72c1..e0a139c2 100644 --- a/azure/monitoring_metric.go +++ b/azure/monitoring_metric.go @@ -79,10 +79,10 @@ func commonMonitoringMetricColumns() []*plugin.Column { Type: proto.ColumnType_STRING, }, { - Name: "environment_name", - Description: ColumnDescriptionEnvironmentName, + Name: "cloud_environment", + Description: ColumnDescriptionCloudEnvironment, Type: proto.ColumnType_STRING, - Hydrate: plugin.HydrateFunc(getEnvironmentName).WithCache(), + Hydrate: plugin.HydrateFunc(getCloudEnvironment).WithCache(), Transform: transform.FromValue(), }, { diff --git a/azure/service.go b/azure/service.go index 7fafe126..edd5e5fc 100644 --- a/azure/service.go +++ b/azure/service.go @@ -22,7 +22,7 @@ import ( // Session info type Session struct { Authorizer autorest.Authorizer - EnvironmentName string + CloudEnvironment string Expires *time.Time GraphEndpoint string ResourceManagerEndpoint string @@ -151,7 +151,7 @@ func GetNewSession(ctx context.Context, d *plugin.QueryData, tokenAudience strin return nil, err } - // Get the subscription ID and tenant ID for "GRAPH" token audience + // Get the subscription ID and tenant ID for "GRAPH" token audience case "CLI": authorizer, err = auth.NewAuthorizerFromCLIWithResource(resource) if err != nil { @@ -202,7 +202,7 @@ func GetNewSession(ctx context.Context, d *plugin.QueryData, tokenAudience strin sess := &Session{ Authorizer: authorizer, - EnvironmentName: settings.Environment.Name, + CloudEnvironment: settings.Environment.Name, Expires: &expiresOn, GraphEndpoint: settings.Environment.GraphEndpoint, ResourceManagerEndpoint: settings.Environment.ResourceManagerEndpoint, diff --git a/azure/table_azure_subscription.go b/azure/table_azure_subscription.go index 438256e6..49160838 100644 --- a/azure/table_azure_subscription.go +++ b/azure/table_azure_subscription.go @@ -82,10 +82,10 @@ func tableAzureSubscription(_ context.Context) *plugin.Table { // Azure standard columns { - Name: "environment_name", - Description: ColumnDescriptionEnvironmentName, + Name: "cloud_environment", + Description: ColumnDescriptionCloudEnvironment, Type: proto.ColumnType_STRING, - Hydrate: plugin.HydrateFunc(getEnvironmentName).WithCache(), + Hydrate: plugin.HydrateFunc(getCloudEnvironment).WithCache(), Transform: transform.FromValue(), }, }, diff --git a/azure/utils.go b/azure/utils.go index bc79768f..d02a7e13 100644 --- a/azure/utils.go +++ b/azure/utils.go @@ -89,13 +89,13 @@ func convertDateUnixToTime(ctx context.Context, d *transform.TransformData) (int // Constants for Standard Column Descriptions const ( - ColumnDescriptionAkas = "Array of globally unique identifier strings (also known as) for the resource." - ColumnDescriptionEnvironmentName = "The Azure Environment Name." - ColumnDescriptionRegion = "The Azure region/location in which the resource is located." - ColumnDescriptionResourceGroup = "The resource group which holds this resource." - ColumnDescriptionSubscription = "The Azure Subscription ID in which the resource is located." - ColumnDescriptionTags = "A map of tags for the resource." - ColumnDescriptionTitle = "Title of the resource." + ColumnDescriptionAkas = "Array of globally unique identifier strings (also known as) for the resource." + ColumnDescriptionCloudEnvironment = "The Azure Cloud Environment." + ColumnDescriptionRegion = "The Azure region/location in which the resource is located." + ColumnDescriptionResourceGroup = "The resource group which holds this resource." + ColumnDescriptionSubscription = "The Azure Subscription ID in which the resource is located." + ColumnDescriptionTags = "A map of tags for the resource." + ColumnDescriptionTitle = "Title of the resource." ) // convert string to lower case