Skip to content

Commit 2728d13

Browse files
authored
Merge pull request #200 from hisume/fix-stanza-validation
Update stanza validation in resource_splunk_configs_conf.go
2 parents e59e9b4 + bc0bf9a commit 2728d13

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

splunk/resource_splunk_configs_conf.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func configsConf() *schema.Resource {
3232
Type: schema.TypeString,
3333
Required: true,
3434
ForceNew: true,
35-
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9_\-.]+/[a-zA-Z0-9_\-.]+`), "A '/' separated string consisting of {conf_file_name}/{stanza_name} ex. props/custom_stanza"),
35+
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9_\-.]+/[a-zA-Z0-9_\-.:/]+`), "A '/' separated string consisting of {conf_file_name}/{stanza_name} ex. props/custom_stanza"),
3636
Description: `A '/' separated string consisting of {conf_file_name}/{stanza_name} ex. props/custom_stanza`,
3737
},
3838
"acl": aclSchema(),

splunk/resource_splunk_configs_conf_test.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,59 @@ func TestAccCreateSplunkConfigsConf(t *testing.T) {
6060
})
6161
}
6262

63+
const newConfigsConfSpecialChars = `
64+
resource "splunk_configs_conf" "tftest-stanza-special-chars" {
65+
name = "tf_test/sqs://tftest_stanza_special_chars"
66+
variables = {
67+
"disabled": "false"
68+
"key": "value"
69+
}
70+
}
71+
`
72+
73+
const updateConfigsConfSpecialChars = `
74+
resource "splunk_configs_conf" "tftest-stanza-special-chars" {
75+
name = "tf_test/sqs://tftest_stanza_special_chars"
76+
variables = {
77+
"disabled": "false"
78+
"key": "new-value"
79+
}
80+
}
81+
`
82+
83+
func TestAccCreateSplunkConfigsConfSpecialChars(t *testing.T) {
84+
resourceName := "splunk_configs_conf.tftest-stanza-special-chars"
85+
resource.Test(t, resource.TestCase{
86+
PreCheck: func() {
87+
testAccPreCheck(t)
88+
},
89+
Providers: testAccProviders,
90+
CheckDestroy: testAccSplunkConfigsConfDestroyResources,
91+
Steps: []resource.TestStep{
92+
{
93+
Config: newConfigsConfSpecialChars,
94+
Check: resource.ComposeTestCheckFunc(
95+
resource.TestCheckResourceAttr(resourceName, "variables.%", "2"),
96+
resource.TestCheckResourceAttr(resourceName, "variables.key", "value"),
97+
),
98+
},
99+
{
100+
Config: updateConfigsConfSpecialChars,
101+
Check: resource.ComposeTestCheckFunc(
102+
resource.TestCheckResourceAttr(resourceName, "variables.%", "2"),
103+
resource.TestCheckResourceAttr(resourceName, "variables.key", "new-value"),
104+
),
105+
},
106+
{
107+
ResourceName: resourceName,
108+
ImportState: true,
109+
ImportStateVerify: true,
110+
},
111+
},
112+
})
113+
}
114+
115+
63116
func testAccSplunkConfigsConfDestroyResources(s *terraform.State) error {
64117
client, err := newTestClient()
65118
if err != nil {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy