-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"azurerm_spring_cloud_app" - supports property
https_only
, `is_publ…
…ic`, `persistent_disk` (#9957) spring cloud app supports more properties: https_only, is_public, persistent_disk https_only and persistent_disk could only be set by update, creat rest api will ignore those values
- Loading branch information
Showing
5 changed files
with
221 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
azurerm/internal/services/springcloud/validate/spring_cloud_app_mount_path.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package validate | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" | ||
) | ||
|
||
func MountPath(i interface{}, k string) (_ []string, errors []error) { | ||
v, ok := i.(string) | ||
if !ok { | ||
return nil, append(errors, fmt.Errorf("expected type of %s to be string", k)) | ||
} | ||
if len(v) < 2 || len(v) > 255 { | ||
errors = append(errors, fmt.Errorf("%s should equal or great than 2 and euqal or less than 255", k)) | ||
} else if m, _ := validate.RegExHelper(i, k, `^(?:\/(?:[a-zA-Z][a-zA-Z0-9]*))+$`); !m { | ||
errors = append(errors, fmt.Errorf("%s is not valid, must match the regular expression ^(?:\\/(?:[a-zA-Z][a-zA-Z0-9]*))+$", k)) | ||
} | ||
return nil, errors | ||
} |
46 changes: 46 additions & 0 deletions
46
azurerm/internal/services/springcloud/validate/spring_cloud_app_mount_path_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package validate | ||
|
||
import "testing" | ||
|
||
func TestMountPath(t *testing.T) { | ||
testData := []struct { | ||
input string | ||
expected bool | ||
}{ | ||
{ | ||
// empty | ||
input: "", | ||
expected: false, | ||
}, | ||
{ | ||
// basic example | ||
input: "/persistent", | ||
expected: true, | ||
}, | ||
{ | ||
// invalid path | ||
input: "//sdf", | ||
expected: false, | ||
}, | ||
{ | ||
// can not short than 2 characters | ||
input: "/", | ||
expected: false, | ||
}, | ||
{ | ||
// 256 characters | ||
input: "/abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu", | ||
expected: false, | ||
}, | ||
} | ||
|
||
for _, v := range testData { | ||
t.Logf("[DEBUG] Testing %q..", v.input) | ||
|
||
_, errors := MountPath(v.input, "name") | ||
actual := len(errors) == 0 | ||
if v.expected != actual { | ||
t.Fatalf("Expected %t but got %t", v.expected, actual) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters