Skip to content

Commit

Permalink
Merge branch 'master' into kt/import-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
katbyte authored May 26, 2021
2 parents 200ea84 + 5ecadcc commit 3c8608c
Show file tree
Hide file tree
Showing 40 changed files with 1,278 additions and 366 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ linters-settings:
ignore-words:
- hdinsight
- exportfs
nakedret:
max-func-lines: 40
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ ENHANCEMENTS:

* dependencies: updating to `v54.3.0` of `github.com/Azure/azure-sdk-for-go` [GH-11813]
* dependencies: updating `mixedreality` to use API Version `2021-01-01` [GH-11824]
* `azurerm_data_factory_linked_service_sftp`: support for hostkey related properties [GH-11825]
* refactor: switching to use an embedded SDK for `appconfiguration` [GH-11959]
* `azurerm_data_factory_linked_service_sftp` - support for hostkey related properties [GH-11825]
* `azurerm_spatial_anchors_account` - support for `account_domain` and `account_id` [GH-11824]
* `azurerm_static_site`: Add support for `tags` attribute [GH-11849]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import (
"fmt"
"time"

"github.com/hashicorp/go-azure-helpers/response"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/location"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/appconfiguration/sdk/configurationstores"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/appconfiguration/parse"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/appconfiguration/validate"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/pluginsdk"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

func dataSourceAppConfiguration() *pluginsdk.Resource {
Expand Down Expand Up @@ -145,49 +148,47 @@ func dataSourceAppConfiguration() *pluginsdk.Resource {
}

func dataSourceAppConfigurationRead(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).AppConfiguration.AppConfigurationsClient
client := meta.(*clients.Client).AppConfiguration.ConfigurationStoresClient
subscriptionId := meta.(*clients.Client).Account.SubscriptionId
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()

name := d.Get("name").(string)
resourceGroup := d.Get("resource_group_name").(string)

resp, err := client.Get(ctx, resourceGroup, name)
id := configurationstores.NewConfigurationStoreID(subscriptionId, resourceGroup, name)
resp, err := client.Get(ctx, id)
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
return fmt.Errorf("App Configuration %q was not found in Resource Group %q", name, resourceGroup)
if response.WasNotFound(resp.HttpResponse) {
return fmt.Errorf("%s was not found", id)
}

return fmt.Errorf("Error retrieving App Configuration %q (Resource Group %q): %+v", name, resourceGroup, err)
return fmt.Errorf("retrieving %s: %+v", id, err)
}

resultPage, err := client.ListKeys(ctx, resourceGroup, name, "")
resultPage, err := client.ListKeysComplete(ctx, id)
if err != nil {
return fmt.Errorf("Failed to receive access keys for App Configuration %q (Resource Group %q): %+v", name, resourceGroup, err)
return fmt.Errorf("retrieving access keys for %s: %+v", id, err)
}

d.SetId(parse.NewConfigurationStoreID(subscriptionId, resourceGroup, name).ID())
d.SetId(id.ID())

if location := resp.Location; location != nil {
d.Set("location", azure.NormalizeLocation(*location))
}
if model := resp.Model; model != nil {
d.Set("location", location.Normalize(model.Location))
d.Set("sku", model.Sku.Name)

skuName := ""
if resp.Sku != nil && resp.Sku.Name != nil {
skuName = *resp.Sku.Name
}
d.Set("sku", skuName)
if props := model.Properties; props != nil {
d.Set("endpoint", props.Endpoint)
}

if props := resp.ConfigurationStoreProperties; props != nil {
d.Set("endpoint", props.Endpoint)
}
accessKeys := flattenAppConfigurationAccessKeys(resultPage.Items)
d.Set("primary_read_key", accessKeys.primaryReadKey)
d.Set("primary_write_key", accessKeys.primaryWriteKey)
d.Set("secondary_read_key", accessKeys.secondaryReadKey)
d.Set("secondary_write_key", accessKeys.secondaryWriteKey)

accessKeys := flattenAppConfigurationAccessKeys(resultPage.Values())
d.Set("primary_read_key", accessKeys.primaryReadKey)
d.Set("primary_write_key", accessKeys.primaryWriteKey)
d.Set("secondary_read_key", accessKeys.secondaryReadKey)
d.Set("secondary_write_key", accessKeys.secondaryWriteKey)
return tags.FlattenAndSet(d, flattenTags(model.Tags))
}

return tags.FlattenAndSet(d, resp.Tags)
return nil
}
Loading

0 comments on commit 3c8608c

Please sign in to comment.