Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_app_configuration_key, azurerm_app_configuration_feature - change resource ID to Data Plane URL format #20082

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ func (k FeatureResource) Arguments() map[string]*pluginsdk.Schema {
Optional: true,
},
"label": {
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validate.AppConfigurationLabel,
},
"locked": {
Type: pluginsdk.TypeBool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ func (k KeyResource) Arguments() map[string]*pluginsdk.Schema {
Optional: true,
},
"label": {
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validate.AppConfigurationLabel,
},
"value": {
Type: pluginsdk.TypeString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ func TestAccAppConfigurationKey_basicNoLabel(t *testing.T) {
})
}

func TestAccAppConfigurationKey_complicatedKeyLabel(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_app_configuration_key", "test")
r := AppConfigurationKeyResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.complicatedKeyLabel(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("etag").IsSet(),
),
},
data.ImportStep(),
})
}

func TestAccAppConfigurationKey_basicNoLabel_afterLabel(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_app_configuration_key", "test")
r := AppConfigurationKeyResource{}
Expand Down Expand Up @@ -212,6 +227,20 @@ resource "azurerm_app_configuration_key" "test" {
`, t.base(data), data.RandomInteger, data.RandomInteger)
}

func (t AppConfigurationKeyResource) complicatedKeyLabel(data acceptance.TestData) string {
return fmt.Sprintf(`
%s

resource "azurerm_app_configuration_key" "test" {
configuration_store_id = azurerm_app_configuration.test.id
key = "acctest-ackey-%d/Label/AppConfigurationKey/Label/"
content_type = "test"
label = "/AppConfigurationKey/acctest-ackeylabel-%d"
value = "a test"
}
`, t.base(data), data.RandomInteger, data.RandomInteger)
}

func (t AppConfigurationKeyResource) slash(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func FeatureId(input string) (*AppConfigurationFeatureId, error) {

// a workaround to support "/" in id
func handleSlashInIdForFeature(input string) string {
oldNames := regexp.MustCompile(`AppConfigurationFeature\/(.+)\/Label`).FindStringSubmatch(input)
oldNames := regexp.MustCompile(`AppConfigurationFeature\/(.+)\/Label\/`).FindStringSubmatch(input)
if len(oldNames) == 2 {
input = strings.Replace(input, oldNames[1], url.QueryEscape(oldNames[1]), 1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func KeyId(input string) (*AppConfigurationKeyId, error) {

// a workaround to support "/" in id
func handleSlashInIdForKey(input string) string {
oldNames := regexp.MustCompile(`AppConfigurationKey\/(.+)\/Label`).FindStringSubmatch(input)
oldNames := regexp.MustCompile(`AppConfigurationKey\/(.+)\/Label\/`).FindStringSubmatch(input)
if len(oldNames) == 2 {
input = strings.Replace(input, oldNames[1], url.QueryEscape(oldNames[1]), 1)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package validate

import (
"fmt"
"strings"
)

func AppConfigurationLabel(input interface{}, key string) (warnings []string, errors []error) {
v, ok := input.(string)
if !ok {
return nil, []error{fmt.Errorf("expected type of %q to be string", key)}
}

if idx := strings.Index(v, "/Label/"); idx != -1 {
return nil, []error{fmt.Errorf(`'/Label/' is not allowed in %q`, key)}
}

return nil, nil
}
2 changes: 2 additions & 0 deletions website/docs/r/app_configuration_feature.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ The following arguments are supported:

* `label` - (Optional) The label of the App Configuration Feature. Changing this forces a new resource to be created.

~> **NOTE:** `label` property should not contain `/Label/` literal to avoid conflict in ID parsing.

* `locked` - (Optional) Should this App Configuration Feature be Locked to prevent changes?

* `name` - (Required) The name of the App Configuration Feature. Changing this forces a new resource to be created.
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/app_configuration_key.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ The following arguments are supported:

* `label` - (Optional) The label of the App Configuration Key. Changing this forces a new resource to be created.

~> **NOTE:** `label` property should not contain `/Label/` literal to avoid conflict in ID parsing.
teowa marked this conversation as resolved.
Show resolved Hide resolved

* `value` - (Optional) The value of the App Configuration Key. This should only be set when type is set to `kv`.

* `locked` - (Optional) Should this App Configuration Key be Locked to prevent changes?
Expand Down