-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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_redhat_openshift_cluster
- support for custom managed_resource_group_name
#25529
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
57c3079
aro custom target rg
teowa c9fc1c8
ban uppercase char
teowa c2b5406
rename to custom_resource_group_name
teowa 23298b8
rename to cluster_resource_group_name
teowa 1f5ba6c
rename to managed_resource_group_name
teowa 34ac6d7
Merge branch 'main' of github.com:hashicorp/terraform-provider-azurer…
teowa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
29 changes: 29 additions & 0 deletions
29
internal/services/redhatopenshift/validate/cluster_resource_group_name.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,29 @@ | ||
package validate | ||
|
||
import ( | ||
"fmt" | ||
"regexp" | ||
"strings" | ||
) | ||
|
||
func ClusterResourceGroupName(v interface{}, k string) (warnings []string, errors []error) { | ||
value := v.(string) | ||
|
||
if len(value) > 90 { | ||
errors = append(errors, fmt.Errorf("%q may not exceed 90 characters in length", k)) | ||
} | ||
|
||
if strings.HasSuffix(value, ".") { | ||
errors = append(errors, fmt.Errorf("%q may not end with a period", k)) | ||
} | ||
|
||
if len(value) == 0 { | ||
errors = append(errors, fmt.Errorf("%q cannot be blank", k)) | ||
} else if matched := regexp.MustCompile(`^[0-9a-z-._()]+$`).Match([]byte(value)); !matched { | ||
// regex pulled from https://docs.microsoft.com/en-us/rest/api/resources/resourcegroups/createorupdate | ||
// ARO only allow for lower cases https://github.com/Azure/ARO-RP/blob/e5c40654277c77fe78ba669610ac05774e448683/pkg/frontend/openshiftcluster_putorpatch.go#L189 | ||
errors = append(errors, fmt.Errorf("%q may only contain lowercase alpha characters, digit, dash, underscores, parentheses and periods", k)) | ||
} | ||
|
||
return warnings, errors | ||
} |
72 changes: 72 additions & 0 deletions
72
internal/services/redhatopenshift/validate/cluster_resource_group_name_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,72 @@ | ||
package validate | ||
|
||
import "testing" | ||
|
||
func TestClusterResourceGroupName(t *testing.T) { | ||
cases := []struct { | ||
Input string | ||
Valid bool | ||
}{ | ||
{ | ||
Input: "", | ||
Valid: false, | ||
}, | ||
|
||
{ | ||
Input: "2", | ||
Valid: true, | ||
}, | ||
|
||
{ | ||
Input: "a.1", | ||
Valid: true, | ||
}, | ||
|
||
{ | ||
Input: "a-a", | ||
Valid: true, | ||
}, | ||
|
||
{ | ||
Input: "a.", | ||
Valid: false, | ||
}, | ||
|
||
{ | ||
Input: "2a-9", | ||
Valid: true, | ||
}, | ||
|
||
{ | ||
Input: "2a-9_", | ||
Valid: true, | ||
}, | ||
|
||
// upper case | ||
{ | ||
Input: "2A", | ||
Valid: false, | ||
}, | ||
|
||
// 90 chars | ||
{ | ||
Input: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl", | ||
Valid: true, | ||
}, | ||
|
||
// 91 chars | ||
{ | ||
Input: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm", | ||
Valid: false, | ||
}, | ||
} | ||
for _, tc := range cases { | ||
t.Logf("[DEBUG] Testing Value %s", tc.Input) | ||
_, errors := ClusterResourceGroupName(tc.Input, "test") | ||
valid := len(errors) == 0 | ||
|
||
if tc.Valid != valid { | ||
t.Fatalf("Expected %t but got %t", tc.Valid, valid) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of this is quite confusing and clashes with the existing
resource_group_id
. Please give a more descriptive name for this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resource_group_name
is to set the resource group which will be created by Azure RedHat OpenShift RP to deploy dependency resources. I have confirmed with service team they won't support RG in another subscription so I only expose it asresource_group_name
. And before we expose thisresource_group_name
property, the resource group name is default toaro-{domain}
as portal does, wheredomain
is another configurable property.The
resource_group_id
is a computed property to display the above resource group ID.Do we need change this to
target_resource_group_name
ordependency_resource_group_name
? Or can we keep it similar format toresource_group_id
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate question, can ARO only deploy it's resources to a resource group that it creates? Or can it deploy it's resources to an already existing one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From service team, it must be a resource group that it creates. In other word, the resource group name sent in this field must be a non-existing one.