From 63784fd026e50a7703cc7e0e9ffd9ac8774b2483 Mon Sep 17 00:00:00 2001 From: Xu Wu Date: Mon, 17 Oct 2022 16:16:07 +0800 Subject: [PATCH] `azurerm_fluid_relay_server` - add `primary_key` and `secondary_key` properties (#18765) * add keys attributes for fluid relay server * code formate and sensitive Co-authored-by: xuwu1 --- .../fluid_relay_servers_resource.go | 25 +++++++++++++++++++ .../fluid_relay_servers_resource_test.go | 1 + .../docs/r/fluid_relay_servers.html.markdown | 4 +++ 3 files changed, 30 insertions(+) diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource.go b/internal/services/fluidrelay/fluid_relay_servers_resource.go index a130c5aa70ed..8f79da9fb615 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource.go @@ -24,6 +24,8 @@ type ServerModel struct { Location string `tfschema:"location"` StorageSKU string `tfschema:"storage_sku"` FrsTenantId string `tfschema:"frs_tenant_id"` + PrimaryKey string `tfschema:"primary_key"` + SecondaryKey string `tfschema:"secondary_key"` OrdererEndpoints []string `tfschema:"orderer_endpoints"` StorageEndpoints []string `tfschema:"storage_endpoints"` ServiceEndpoints []string `tfschema:"service_endpoints"` @@ -112,6 +114,18 @@ func (s Server) Attributes() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeString, }, }, + + "primary_key": { + Type: pluginsdk.TypeString, + Computed: true, + Sensitive: true, + }, + + "secondary_key": { + Type: pluginsdk.TypeString, + Computed: true, + Sensitive: true, + }, } } @@ -256,6 +270,17 @@ func (s Server) Read() sdk.ResourceFunc { if val, ok := meta.ResourceData.GetOk("storage_sku"); ok { output.StorageSKU = val.(string) } + + keyRes, err := client.ListKeys(ctx, *id) + if err != nil { + // do not return if only list keys error + meta.Logger.Warnf("retrieving keys for %s: %v", *id, err) + } + if keys := keyRes.Model; model != nil { + output.PrimaryKey = utils.NormalizeNilableString(keys.Key1) + output.SecondaryKey = utils.NormalizeNilableString(keys.Key2) + } + return meta.Encode(output) }, } diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go index b677ba243c32..18bc12717f71 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go @@ -48,6 +48,7 @@ func TestAccFluidRelay_basic(t *testing.T) { Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(f), check.That(data.ResourceName).Key("frs_tenant_id").IsUUID(), + check.That(data.ResourceName).Key("primary_key").Exists(), check.That(data.ResourceName).Key("orderer_endpoints.0").Exists(), check.That(data.ResourceName).Key("service_endpoints.#").Exists(), ), diff --git a/website/docs/r/fluid_relay_servers.html.markdown b/website/docs/r/fluid_relay_servers.html.markdown index a49d77ec3bca..05a73ce8494a 100644 --- a/website/docs/r/fluid_relay_servers.html.markdown +++ b/website/docs/r/fluid_relay_servers.html.markdown @@ -61,6 +61,10 @@ In addition to the Arguments listed above - the following Attributes are exporte * `frs_tenant_id` - The Fluid tenantId for this server. +* `primary_key` - The primary key for this server. + +* `secondary_key` - The secondary key for this server. + * `orderer_endpoints` - An array of the Fluid Relay Orderer endpoints. * `storage_endpoints` - An array of storage endpoints for this Fluid Relay Server.