Skip to content

Commit

Permalink
azurerm_fluid_relay_server - add primary_key and secondary_key
Browse files Browse the repository at this point in the history
…properties (#18765)

* add keys attributes for fluid relay server

* code formate and sensitive

Co-authored-by: xuwu1 <xuwu1@microsoft.com>
  • Loading branch information
wuxu92 and wuxu92 authored Oct 17, 2022
1 parent fdf25d6 commit 63784fd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
25 changes: 25 additions & 0 deletions internal/services/fluidrelay/fluid_relay_servers_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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,
},
}
}

Expand Down Expand Up @@ -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)
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
),
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/fluid_relay_servers.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 63784fd

Please sign in to comment.