Skip to content

Commit

Permalink
PC-11136 Allow underscores and parenthesis in azure resource id (#162)
Browse files Browse the repository at this point in the history
* Allow underscores and parenthesis in Azure resource id

Co-authored-by: Jakub Mikłasz <jakub.miklasz@nobl9.com>

---------

Co-authored-by: Jakub Mikłasz <jakub.miklasz@nobl9.com>
  • Loading branch information
nikodemrafalski and kuklyy authored Nov 16, 2023
1 parent 426d480 commit c8a7ec3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion manifest/v1alpha/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const (
GCSNonDomainNameBucketMaxLength int = 63
CloudWatchNamespaceRegex string = `^[0-9A-Za-z.\-_/#:]{1,255}$`
HeaderNameRegex string = `^([a-zA-Z0-9]+[_-]?)+$`
AzureResourceIDRegex string = `^\/subscriptions\/[a-zA-Z0-9-]+\/resourceGroups\/[a-zA-Z0-9-]+\/providers\/[a-zA-Z0-9-\._]+\/[a-zA-Z0-9-_]+\/[a-zA-Z0-9-_]+$` //nolint:lll
AzureResourceIDRegex string = `^\/subscriptions\/[a-zA-Z0-9-]+\/resourceGroups\/[a-zA-Z0-9-._()]+\/providers\/[a-zA-Z0-9-.()_]+\/[a-zA-Z0-9-_()]+\/[a-zA-Z0-9-_()]+$` //nolint:lll
)

// Values used to validate time window size
Expand Down
5 changes: 5 additions & 0 deletions manifest/v1alpha/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,11 @@ func TestValidateAzureResourceID(t *testing.T) {
resourceID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Compute/virtualMachines/vm-123_x", //nolint:lll
isValid: true,
},
{
desc: "valid resource id with _ in rg",
resourceID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mc_().rg-xxx-01_ups-aks_eu_west/providers/Microsoft.()Network/loadBalancers1_-()/kubernetes", //nolint:lll
isValid: true,
},
}

val := v.New()
Expand Down

0 comments on commit c8a7ec3

Please sign in to comment.