From 4e7acb2b33b87854a3210eeef569c674759c68bd Mon Sep 17 00:00:00 2001 From: Arnab Ghosh Date: Tue, 28 Sep 2021 14:22:35 +0530 Subject: [PATCH 1/3] Add table azure_spring_cloud_service --- .../dependencies.txt | 0 .../test-get-expected.json | 13 + .../test-get-query.sql | 3 + .../test-list-expected.json | 13 + .../test-list-query.sql | 3 + .../test-not-found-expected.json | 1 + .../test-not-found-query.sql | 3 + .../test-turbot-expected.json | 13 + .../test-turbot-query.sql | 3 + .../azure_spring_cloud_service/variables.json | 1 + .../azure_spring_cloud_service/variables.tf | 92 ++++++ azure/plugin.go | 1 + azure/table_azure_spring_cloud_service.go | 299 ++++++++++++++++++ docs/tables/azure_spring_cloud_service.md | 39 +++ 14 files changed, 484 insertions(+) create mode 100644 azure-test/tests/azure_spring_cloud_service/dependencies.txt create mode 100644 azure-test/tests/azure_spring_cloud_service/test-get-expected.json create mode 100644 azure-test/tests/azure_spring_cloud_service/test-get-query.sql create mode 100644 azure-test/tests/azure_spring_cloud_service/test-list-expected.json create mode 100644 azure-test/tests/azure_spring_cloud_service/test-list-query.sql create mode 100644 azure-test/tests/azure_spring_cloud_service/test-not-found-expected.json create mode 100644 azure-test/tests/azure_spring_cloud_service/test-not-found-query.sql create mode 100644 azure-test/tests/azure_spring_cloud_service/test-turbot-expected.json create mode 100644 azure-test/tests/azure_spring_cloud_service/test-turbot-query.sql create mode 100644 azure-test/tests/azure_spring_cloud_service/variables.json create mode 100644 azure-test/tests/azure_spring_cloud_service/variables.tf create mode 100644 azure/table_azure_spring_cloud_service.go create mode 100644 docs/tables/azure_spring_cloud_service.md diff --git a/azure-test/tests/azure_spring_cloud_service/dependencies.txt b/azure-test/tests/azure_spring_cloud_service/dependencies.txt new file mode 100644 index 00000000..e69de29b diff --git a/azure-test/tests/azure_spring_cloud_service/test-get-expected.json b/azure-test/tests/azure_spring_cloud_service/test-get-expected.json new file mode 100644 index 00000000..52c2ef8d --- /dev/null +++ b/azure-test/tests/azure_spring_cloud_service/test-get-expected.json @@ -0,0 +1,13 @@ +[ + { + "id": "{{ output.resource_id.value }}", + "name": "{{ resourceName }}", + "region": "{{ output.region.value }}", + "resource_group": "{{ resourceName }}", + "subscription_id": "{{ output.subscription_id.value }}", + "tags": { + "name": "{{ resourceName }}" + }, + "type": "Microsoft.AppPlatform/Spring" + } +] diff --git a/azure-test/tests/azure_spring_cloud_service/test-get-query.sql b/azure-test/tests/azure_spring_cloud_service/test-get-query.sql new file mode 100644 index 00000000..0a1102b6 --- /dev/null +++ b/azure-test/tests/azure_spring_cloud_service/test-get-query.sql @@ -0,0 +1,3 @@ +select name, id, type, region, resource_group, subscription_id, tags +from azure.azure_spring_cloud_service +where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}'; diff --git a/azure-test/tests/azure_spring_cloud_service/test-list-expected.json b/azure-test/tests/azure_spring_cloud_service/test-list-expected.json new file mode 100644 index 00000000..52c2ef8d --- /dev/null +++ b/azure-test/tests/azure_spring_cloud_service/test-list-expected.json @@ -0,0 +1,13 @@ +[ + { + "id": "{{ output.resource_id.value }}", + "name": "{{ resourceName }}", + "region": "{{ output.region.value }}", + "resource_group": "{{ resourceName }}", + "subscription_id": "{{ output.subscription_id.value }}", + "tags": { + "name": "{{ resourceName }}" + }, + "type": "Microsoft.AppPlatform/Spring" + } +] diff --git a/azure-test/tests/azure_spring_cloud_service/test-list-query.sql b/azure-test/tests/azure_spring_cloud_service/test-list-query.sql new file mode 100644 index 00000000..6a1df714 --- /dev/null +++ b/azure-test/tests/azure_spring_cloud_service/test-list-query.sql @@ -0,0 +1,3 @@ +select name, id, type, region, resource_group, subscription_id, tags +from azure.azure_spring_cloud_service +where resource_group = '{{ resourceName }}'; diff --git a/azure-test/tests/azure_spring_cloud_service/test-not-found-expected.json b/azure-test/tests/azure_spring_cloud_service/test-not-found-expected.json new file mode 100644 index 00000000..19765bd5 --- /dev/null +++ b/azure-test/tests/azure_spring_cloud_service/test-not-found-expected.json @@ -0,0 +1 @@ +null diff --git a/azure-test/tests/azure_spring_cloud_service/test-not-found-query.sql b/azure-test/tests/azure_spring_cloud_service/test-not-found-query.sql new file mode 100644 index 00000000..aa865b5c --- /dev/null +++ b/azure-test/tests/azure_spring_cloud_service/test-not-found-query.sql @@ -0,0 +1,3 @@ +select name, id, type, region +from azure.azure_spring_cloud_service +where name = 'dummy-test{{ resourceName }}' and resource_group = '{{ resourceName }}'; diff --git a/azure-test/tests/azure_spring_cloud_service/test-turbot-expected.json b/azure-test/tests/azure_spring_cloud_service/test-turbot-expected.json new file mode 100644 index 00000000..43ffbc2c --- /dev/null +++ b/azure-test/tests/azure_spring_cloud_service/test-turbot-expected.json @@ -0,0 +1,13 @@ +[ + { + "akas": [ + "{{ output.resource_aka.value }}", + "{{ output.resource_aka_lower.value }}" + ], + "name": "{{ resourceName }}", + "tags": { + "name": "{{ resourceName }}" + }, + "title": "{{ resourceName }}" + } +] diff --git a/azure-test/tests/azure_spring_cloud_service/test-turbot-query.sql b/azure-test/tests/azure_spring_cloud_service/test-turbot-query.sql new file mode 100644 index 00000000..d4f374f7 --- /dev/null +++ b/azure-test/tests/azure_spring_cloud_service/test-turbot-query.sql @@ -0,0 +1,3 @@ +select name, akas, title, tags +from azure.azure_spring_cloud_service +where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}'; diff --git a/azure-test/tests/azure_spring_cloud_service/variables.json b/azure-test/tests/azure_spring_cloud_service/variables.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/azure-test/tests/azure_spring_cloud_service/variables.json @@ -0,0 +1 @@ +{} diff --git a/azure-test/tests/azure_spring_cloud_service/variables.tf b/azure-test/tests/azure_spring_cloud_service/variables.tf new file mode 100644 index 00000000..00195c3e --- /dev/null +++ b/azure-test/tests/azure_spring_cloud_service/variables.tf @@ -0,0 +1,92 @@ +variable "resource_name" { + type = string + default = "turbot-test-20200928-create-update" + description = "Name of the resource used throughout the test." +} + +variable "azure_environment" { + type = string + default = "public" + description = "Azure environment used for the test." +} + +variable "azure_subscription" { + type = string + default = "3510ae4d-530b-497d-8f30-53b9616fc6c1" + description = "Azure environment used for the test." +} + +terraform { + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "=2.78.0" + } + } +} + +provider "azurerm" { + # Cannot be passed as a variable + features {} + environment = var.azure_environment + subscription_id = var.azure_subscription +} + +resource "azurerm_resource_group" "named_test_resource" { + name = var.resource_name + location = "West Europe" +} + +resource "azurerm_application_insights" "named_test_resource" { + name = var.resource_name + location = azurerm_resource_group.named_test_resource.location + resource_group_name = azurerm_resource_group.named_test_resource.name + application_type = "web" +} + +resource "azurerm_spring_cloud_service" "named_test_resource" { + name = var.resource_name + resource_group_name = azurerm_resource_group.named_test_resource.name + location = azurerm_resource_group.named_test_resource.location + sku_name = "S0" + + config_server_git_setting { + uri = "https://github.com/Azure-Samples/piggymetrics" + label = "config" + search_paths = ["dir1", "dir2"] + } + + trace { + connection_string = azurerm_application_insights.named_test_resource.connection_string + sample_rate = 10.0 + } + + tags = { + name = var.resource_name + } +} + +output "region" { + value = azurerm_resource_group.named_test_resource.location +} + +output "resource_aka" { + depends_on = [azurerm_spring_cloud_service.named_test_resource] + value = "azure://${azurerm_spring_cloud_service.named_test_resource.id}" +} + +output "resource_aka_lower" { + value = "azure://${lower(azurerm_spring_cloud_service.named_test_resource.id)}" +} + +output "resource_name" { + value = var.resource_name +} + +output "resource_id" { + value = azurerm_spring_cloud_service.named_test_resource.id +} + +output "subscription_id" { + value = var.azure_subscription +} diff --git a/azure/plugin.go b/azure/plugin.go index 02abcfd2..dd08c98b 100644 --- a/azure/plugin.go +++ b/azure/plugin.go @@ -114,6 +114,7 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_security_center_subscription_pricing": tableAzureSecurityCenterPricing(ctx), "azure_service_fabric_cluster": tableAzureServiceFabricCluster(ctx), "azure_servicebus_namespace": tableAzureServiceBusNamespace(ctx), + "azure_spring_cloud_service": tableAzureSpringCloudService(ctx), "azure_sql_database": tableAzureSqlDatabase(ctx), "azure_sql_server": tableAzureSQLServer(ctx), "azure_storage_account": tableAzureStorageAccount(ctx), diff --git a/azure/table_azure_spring_cloud_service.go b/azure/table_azure_spring_cloud_service.go new file mode 100644 index 00000000..583fa035 --- /dev/null +++ b/azure/table_azure_spring_cloud_service.go @@ -0,0 +1,299 @@ +package azure + +import ( + "context" + + "github.com/Azure/azure-sdk-for-go/profiles/2020-09-01/monitor/mgmt/insights" + "github.com/Azure/azure-sdk-for-go/services/appplatform/mgmt/2020-07-01/appplatform" + "github.com/turbot/steampipe-plugin-sdk/grpc/proto" + "github.com/turbot/steampipe-plugin-sdk/plugin/transform" + + "github.com/turbot/steampipe-plugin-sdk/plugin" +) + +//// TABLE DEFINITION + +func tableAzureSpringCloudService(_ context.Context) *plugin.Table { + return &plugin.Table{ + Name: "azure_spring_cloud_service", + Description: "Azure Spring Cloud Service", + Get: &plugin.GetConfig{ + KeyColumns: plugin.AllColumns([]string{"name", "resource_group"}), + Hydrate: getSpringCloudService, + ShouldIgnoreError: isNotFoundError([]string{"ResourceNotFound", "ResourceGroupNotFound", "404"}), + }, + List: &plugin.ListConfig{ + KeyColumns: plugin.SingleColumn("resource_group"), + Hydrate: listSpringCloudServices, + }, + Columns: []*plugin.Column{ + { + Name: "name", + Description: "The name of the resource.", + Type: proto.ColumnType_STRING, + }, + { + Name: "id", + Description: "Fully qualified resource Id for the resource.", + Type: proto.ColumnType_STRING, + Transform: transform.FromGo(), + }, + { + Name: "provisioning_state", + Description: "Provisioning state of the Service. Possible values include: 'Creating', 'Updating', 'Deleting', 'Deleted', 'Succeeded', 'Failed', 'Moving', 'Moved', 'MoveFailed'.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Properties.ProvisioningState"), + }, + { + Name: "type", + Description: "The type of the resource.", + Type: proto.ColumnType_STRING, + }, + { + Name: "service_id", + Description: "Service instance entity GUID which uniquely identifies a created resource.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Properties.ServiceID"), + }, + { + Name: "sku_name", + Description: "Name of the Sku.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Sku.Name"), + }, + { + Name: "sku_tier", + Description: "Tier of the Sku.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Sku.Tier"), + }, + { + Name: "sku_capacity", + Description: "Current capacity of the target resource.", + Type: proto.ColumnType_INT, + Transform: transform.FromField("Sku.Capacity"), + }, + { + Name: "version", + Description: "Version of the service.", + Type: proto.ColumnType_INT, + Transform: transform.FromField("Properties.Version"), + }, + { + Name: "diagnostic_settings", + Description: "A list of active diagnostic settings for the resource.", + Type: proto.ColumnType_JSON, + Hydrate: listSpringCloudServiceDiagnosticSettings, + Transform: transform.FromValue(), + }, + { + Name: "network_profile", + Description: "Network profile of the service.", + Type: proto.ColumnType_JSON, + Transform: transform.From(extractSpringCloudServiceNetworkProfile), + }, + + // Steampipe standard columns + { + Name: "title", + Description: ColumnDescriptionTitle, + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Name"), + }, + { + Name: "tags", + Description: ColumnDescriptionTags, + Type: proto.ColumnType_JSON, + Transform: transform.FromField("Tags"), + }, + { + Name: "akas", + Description: ColumnDescriptionAkas, + Type: proto.ColumnType_JSON, + Transform: transform.FromField("ID").Transform(idToAkas), + }, + + // Azure standard columns + { + Name: "region", + Description: ColumnDescriptionRegion, + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Location").Transform(toLower), + }, + { + Name: "resource_group", + Description: ColumnDescriptionResourceGroup, + Type: proto.ColumnType_STRING, + Transform: transform.FromField("ID").Transform(extractResourceGroupFromID), + }, + { + Name: "subscription_id", + Description: ColumnDescriptionSubscription, + Type: proto.ColumnType_STRING, + Transform: transform.FromField("ID").Transform(idToSubscriptionID), + }, + }, + } +} + +type SpringCloudServiceNetworkProfile struct { + ServiceRuntimeSubnetID *string + AppSubnetID *string + ServiceCidr *string + ServiceRuntimeNetworkResourceGroup *string + AppNetworkResourceGroup *string + OutboundPublicIPs *[]string +} + +//// LIST FUNCTION + +func listSpringCloudServices(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { + session, err := GetNewSession(ctx, d, "MANAGEMENT") + if err != nil { + return nil, err + } + subscriptionID := session.SubscriptionID + resourceGroup := d.KeyColumnQuals["resource_group"].GetStringValue() + + if resourceGroup == "" { + return nil, nil + } + + client := appplatform.NewServicesClient(subscriptionID) + client.Authorizer = session.Authorizer + + result, err := client.List(ctx, resourceGroup) + if err != nil { + plugin.Logger(ctx).Error("listSpringCloudServices", "list", err) + return nil, err + } + + for _, service := range result.Values() { + d.StreamListItem(ctx, service) + } + + for result.NotDone() { + err = result.NextWithContext(ctx) + if err != nil { + plugin.Logger(ctx).Error("listSpringCloudServices", "list_paging", err) + return nil, err + } + for _, service := range result.Values() { + d.StreamListItem(ctx, service) + } + } + + return nil, err +} + +//// HYDRATE FUNCTIONS + +func getSpringCloudService(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + plugin.Logger(ctx).Trace("getSpringCloudService") + + name := d.KeyColumnQuals["name"].GetStringValue() + resourceGroup := d.KeyColumnQuals["resource_group"].GetStringValue() + + // Handle empty name or resourceGroup + if name == "" || resourceGroup == "" { + return nil, nil + } + + session, err := GetNewSession(ctx, d, "MANAGEMENT") + if err != nil { + return nil, err + } + subscriptionID := session.SubscriptionID + + client := appplatform.NewServicesClient(subscriptionID) + client.Authorizer = session.Authorizer + + service, err := client.Get(ctx, resourceGroup, name) + if err != nil { + plugin.Logger(ctx).Error("getSpringCloudService", "get", err) + return nil, err + } + + // In some cases resource does not give any notFound error + // instead of notFound error, it returns empty data + if service.ID != nil { + return service, nil + } + + return nil, nil +} + +func listSpringCloudServiceDiagnosticSettings(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + plugin.Logger(ctx).Trace("listSpringCloudServiceDiagnosticSettings") + id := *h.Item.(appplatform.ServiceResource).ID + + // Create session + session, err := GetNewSession(ctx, d, "MANAGEMENT") + if err != nil { + return nil, err + } + subscriptionID := session.SubscriptionID + + client := insights.NewDiagnosticSettingsClient(subscriptionID) + client.Authorizer = session.Authorizer + + op, err := client.List(ctx, id) + if err != nil { + plugin.Logger(ctx).Error("listSpringCloudServiceDiagnosticSettings", "list", err) + return nil, err + } + + // If we return the API response directly, the output does not provide + // the contents of DiagnosticSettings + var diagnosticSettings []map[string]interface{} + for _, i := range *op.Value { + objectMap := make(map[string]interface{}) + if i.ID != nil { + objectMap["id"] = i.ID + } + if i.Name != nil { + objectMap["name"] = i.Name + } + if i.Type != nil { + objectMap["type"] = i.Type + } + if i.DiagnosticSettings != nil { + objectMap["properties"] = i.DiagnosticSettings + } + diagnosticSettings = append(diagnosticSettings, objectMap) + } + return diagnosticSettings, nil +} + +//// TRANSFORM FUNCTION + +// If we return the API response directly, the output will not provide the properties of NetworkProfile +func extractSpringCloudServiceNetworkProfile(ctx context.Context, d *transform.TransformData) (interface{}, error) { + workspace := d.HydrateItem.(appplatform.ServiceResource) + var properties SpringCloudServiceNetworkProfile + + if workspace.Properties.NetworkProfile != nil { + if workspace.Properties.NetworkProfile.ServiceRuntimeSubnetID != nil { + properties.ServiceRuntimeSubnetID = workspace.Properties.NetworkProfile.ServiceRuntimeSubnetID + } + if workspace.Properties.NetworkProfile.AppSubnetID != nil { + properties.AppSubnetID = workspace.Properties.NetworkProfile.AppSubnetID + } + if workspace.Properties.NetworkProfile.ServiceCidr != nil { + properties.ServiceCidr = workspace.Properties.NetworkProfile.ServiceCidr + } + if workspace.Properties.NetworkProfile.ServiceRuntimeNetworkResourceGroup != nil { + properties.ServiceRuntimeNetworkResourceGroup = workspace.Properties.NetworkProfile.ServiceRuntimeNetworkResourceGroup + } + if workspace.Properties.NetworkProfile.AppNetworkResourceGroup != nil { + properties.AppNetworkResourceGroup = workspace.Properties.NetworkProfile.AppNetworkResourceGroup + } + if workspace.Properties.NetworkProfile.OutboundIPs != nil { + if workspace.Properties.NetworkProfile.OutboundIPs.PublicIPs != nil { + properties.OutboundPublicIPs = workspace.Properties.NetworkProfile.OutboundIPs.PublicIPs + } + } + } + + return properties, nil +} diff --git a/docs/tables/azure_spring_cloud_service.md b/docs/tables/azure_spring_cloud_service.md new file mode 100644 index 00000000..e417e398 --- /dev/null +++ b/docs/tables/azure_spring_cloud_service.md @@ -0,0 +1,39 @@ +# Table: azure_spring_cloud_service + +Azure Spring Cloud is a platform as a service (PaaS) for Spring developers. It manages the lifecycle of your Spring Boot applications with comprehensive monitoring and diagnostics, configuration management, service discovery, CI/CD integration, blue-green deployments and more. + +## Examples + +### Basic info + +```sql +select + id, + name, + type, + provisioning_state, + sku_name, + sku_tier, + version +from + azure_spring_cloud_service +where + resource_group = 'arnab-test-resource-group'; +``` + +### List network profile details + +```sql +select + id, + name, + network_profile ->> 'AppNetworkResourceGroup' as network_profile_app_network_resource_group, + network_profile ->> 'AppSubnetID' as network_profile_app_subnet_id, + jsonb_pretty(network_profile -> 'OutboundPublicIPs') as network_profile_outbound_public_ips, + network_profile ->> 'ServiceCidr' as network_profile_service_cidr, + network_profile ->> 'ServiceRuntimeNetworkResourceGroup' as network_profile_service_runtime_network_resource_group, + network_profile ->> 'ServiceRuntimeSubnetID' as network_profile_service_runtime_subnet_id +from + azure_spring_cloud_service +where + resource_group = 'arnab-test-resource-group'; From afb2b30114524c9e04ee2ee88ac2554280c63059 Mon Sep 17 00:00:00 2001 From: Arnab Ghosh Date: Thu, 30 Sep 2021 15:07:03 +0530 Subject: [PATCH 2/3] resolve comments --- .../test-list-query.sql | 2 +- azure/table_azure_spring_cloud_service.go | 17 ++++++++++------- docs/tables/azure_spring_cloud_service.md | 8 ++------ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/azure-test/tests/azure_spring_cloud_service/test-list-query.sql b/azure-test/tests/azure_spring_cloud_service/test-list-query.sql index 6a1df714..9ee60471 100644 --- a/azure-test/tests/azure_spring_cloud_service/test-list-query.sql +++ b/azure-test/tests/azure_spring_cloud_service/test-list-query.sql @@ -1,3 +1,3 @@ select name, id, type, region, resource_group, subscription_id, tags from azure.azure_spring_cloud_service -where resource_group = '{{ resourceName }}'; +where id = '{{ output.resource_id.value }}'; diff --git a/azure/table_azure_spring_cloud_service.go b/azure/table_azure_spring_cloud_service.go index 583fa035..ad51ef00 100644 --- a/azure/table_azure_spring_cloud_service.go +++ b/azure/table_azure_spring_cloud_service.go @@ -5,6 +5,7 @@ import ( "github.com/Azure/azure-sdk-for-go/profiles/2020-09-01/monitor/mgmt/insights" "github.com/Azure/azure-sdk-for-go/services/appplatform/mgmt/2020-07-01/appplatform" + "github.com/Azure/azure-sdk-for-go/profiles/latest/resources/mgmt/resources" "github.com/turbot/steampipe-plugin-sdk/grpc/proto" "github.com/turbot/steampipe-plugin-sdk/plugin/transform" @@ -23,7 +24,7 @@ func tableAzureSpringCloudService(_ context.Context) *plugin.Table { ShouldIgnoreError: isNotFoundError([]string{"ResourceNotFound", "ResourceGroupNotFound", "404"}), }, List: &plugin.ListConfig{ - KeyColumns: plugin.SingleColumn("resource_group"), + ParentHydrate: listResourceGroups, Hydrate: listSpringCloudServices, }, Columns: []*plugin.Column{ @@ -147,22 +148,23 @@ type SpringCloudServiceNetworkProfile struct { //// LIST FUNCTION -func listSpringCloudServices(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { +func listSpringCloudServices(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { session, err := GetNewSession(ctx, d, "MANAGEMENT") if err != nil { return nil, err } subscriptionID := session.SubscriptionID - resourceGroup := d.KeyColumnQuals["resource_group"].GetStringValue() - if resourceGroup == "" { + // Get the details of the resource group + resourceGroup := h.Item.(resources.Group) + if *resourceGroup.Name == "" { return nil, nil } client := appplatform.NewServicesClient(subscriptionID) client.Authorizer = session.Authorizer - result, err := client.List(ctx, resourceGroup) + result, err := client.List(ctx, *resourceGroup.Name) if err != nil { plugin.Logger(ctx).Error("listSpringCloudServices", "list", err) return nil, err @@ -244,7 +246,7 @@ func listSpringCloudServiceDiagnosticSettings(ctx context.Context, d *plugin.Que } // If we return the API response directly, the output does not provide - // the contents of DiagnosticSettings + // all the contents of DiagnosticSettings var diagnosticSettings []map[string]interface{} for _, i := range *op.Value { objectMap := make(map[string]interface{}) @@ -267,7 +269,8 @@ func listSpringCloudServiceDiagnosticSettings(ctx context.Context, d *plugin.Que //// TRANSFORM FUNCTION -// If we return the API response directly, the output will not provide the properties of NetworkProfile +// If we return the API response directly, the output does not provide +// all the properties of NetworkProfile func extractSpringCloudServiceNetworkProfile(ctx context.Context, d *transform.TransformData) (interface{}, error) { workspace := d.HydrateItem.(appplatform.ServiceResource) var properties SpringCloudServiceNetworkProfile diff --git a/docs/tables/azure_spring_cloud_service.md b/docs/tables/azure_spring_cloud_service.md index e417e398..e1a9b960 100644 --- a/docs/tables/azure_spring_cloud_service.md +++ b/docs/tables/azure_spring_cloud_service.md @@ -16,9 +16,7 @@ select sku_tier, version from - azure_spring_cloud_service -where - resource_group = 'arnab-test-resource-group'; + azure_spring_cloud_service; ``` ### List network profile details @@ -34,6 +32,4 @@ select network_profile ->> 'ServiceRuntimeNetworkResourceGroup' as network_profile_service_runtime_network_resource_group, network_profile ->> 'ServiceRuntimeSubnetID' as network_profile_service_runtime_subnet_id from - azure_spring_cloud_service -where - resource_group = 'arnab-test-resource-group'; + azure_spring_cloud_service; From 00ed058d42cc78696ac9d3f6b2a194db3c0d0ff4 Mon Sep 17 00:00:00 2001 From: bigdatasourav Date: Thu, 30 Sep 2021 16:37:30 +0530 Subject: [PATCH 3/3] minor change --- azure/table_azure_spring_cloud_service.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/azure/table_azure_spring_cloud_service.go b/azure/table_azure_spring_cloud_service.go index ad51ef00..0f89974d 100644 --- a/azure/table_azure_spring_cloud_service.go +++ b/azure/table_azure_spring_cloud_service.go @@ -4,8 +4,8 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/profiles/2020-09-01/monitor/mgmt/insights" - "github.com/Azure/azure-sdk-for-go/services/appplatform/mgmt/2020-07-01/appplatform" "github.com/Azure/azure-sdk-for-go/profiles/latest/resources/mgmt/resources" + "github.com/Azure/azure-sdk-for-go/services/appplatform/mgmt/2020-07-01/appplatform" "github.com/turbot/steampipe-plugin-sdk/grpc/proto" "github.com/turbot/steampipe-plugin-sdk/plugin/transform" @@ -25,7 +25,7 @@ func tableAzureSpringCloudService(_ context.Context) *plugin.Table { }, List: &plugin.ListConfig{ ParentHydrate: listResourceGroups, - Hydrate: listSpringCloudServices, + Hydrate: listSpringCloudServices, }, Columns: []*plugin.Column{ { @@ -157,7 +157,7 @@ func listSpringCloudServices(ctx context.Context, d *plugin.QueryData, h *plugin // Get the details of the resource group resourceGroup := h.Item.(resources.Group) - if *resourceGroup.Name == "" { + if resourceGroup.Name == nil { return nil, nil } @@ -184,7 +184,7 @@ func listSpringCloudServices(ctx context.Context, d *plugin.QueryData, h *plugin d.StreamListItem(ctx, service) } } - + return nil, err }