Skip to content

Commit

Permalink
Fix up provider-specific references in service generator, regenerate
Browse files Browse the repository at this point in the history
  • Loading branch information
manicminer committed Jan 29, 2024
1 parent 445183c commit a46ae69
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 12 deletions.
43 changes: 42 additions & 1 deletion .github/labeler-issue-triage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,45 @@
bug:
- 'panic:'
crash:
- 'panic:'
- 'panic:'
feature/administrative-units:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azuread_administrative_unit((.|\n)*)###'

feature/app-role-assignments:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azuread_app_role_assignment((.|\n)*)###'

feature/applications:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azuread_application((.|\n)*)###'

feature/conditional-access:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azuread_(conditional_access_policy|named_location)((.|\n)*)###'

feature/directory-objects:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azuread_directory_object((.|\n)*)###'

feature/directory-roles:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azuread_(custom_directory_role|directory_role)((.|\n)*)###'

feature/domains:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azuread_domains((.|\n)*)###'

feature/groups:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azuread_group((.|\n)*)###'

feature/identity-governance:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azuread_access_package((.|\n)*)###'

feature/invitations:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azuread_invitation((.|\n)*)###'

feature/policies:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azuread_(authentication_strength_policy|claims_mapping_policy)((.|\n)*)###'

feature/service-principals:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azuread_(client_config|service_principal|synchronization_)((.|\n)*)###'

feature/user-flows:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azuread_user_flow_attribute((.|\n)*)###'

feature/users:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azuread_(user\W+|users\W+)((.|\n)*)###'
72 changes: 71 additions & 1 deletion .github/labeler-pull-request-triage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,74 @@ tooling:
state-migration:
- changed-files:
- any-glob-to-any-file:
- internal/services/**/migration/**/*
- internal/services/**/migration/**/*
feature/administrative-units:
- changed-files:
- any-glob-to-any-file:
- internal/services/administrativeunits/**/*

feature/app-role-assignments:
- changed-files:
- any-glob-to-any-file:
- internal/services/approleassignments/**/*

feature/applications:
- changed-files:
- any-glob-to-any-file:
- internal/services/applications/**/*

feature/conditional-access:
- changed-files:
- any-glob-to-any-file:
- internal/services/conditionalaccess/**/*

feature/directory-objects:
- changed-files:
- any-glob-to-any-file:
- internal/services/directoryobjects/**/*

feature/directory-roles:
- changed-files:
- any-glob-to-any-file:
- internal/services/directoryroles/**/*

feature/domains:
- changed-files:
- any-glob-to-any-file:
- internal/services/domains/**/*

feature/groups:
- changed-files:
- any-glob-to-any-file:
- internal/services/groups/**/*

feature/identity-governance:
- changed-files:
- any-glob-to-any-file:
- internal/services/identitygovernance/**/*

feature/invitations:
- changed-files:
- any-glob-to-any-file:
- internal/services/invitations/**/*

feature/policies:
- changed-files:
- any-glob-to-any-file:
- internal/services/policies/**/*

feature/service-principals:
- changed-files:
- any-glob-to-any-file:
- internal/services/serviceprincipals/**/*
- internal/services/synchronization/**/*

feature/user-flows:
- changed-files:
- any-glob-to-any-file:
- internal/services/userflows/**/*

feature/users:
- changed-files:
- any-glob-to-any-file:
- internal/services/users/**/*
20 changes: 10 additions & 10 deletions internal/tools/generator-services/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ crash:
- 'panic:'
`

const azurerm = "azurerm_"
const providerPrefix = "azuread_"

type githubIssueLabelsGenerator struct{}

Expand Down Expand Up @@ -310,12 +310,12 @@ func (githubIssueLabelsGenerator) run(outputFileName string, _ map[string]struct

longestPrefix := longestCommonPrefix(labelToNames[labelName])
var prefixGroups []Prefix
// If there is no common prefix for a service, separate it into groups using the next segment of the name (azurerm_xxx) and add multiple possible prefixes for the label
// For example, under "service/signalr" we separate names into groups of 2 prefixes.
// If there is no common prefix for a service, separate it into groups using the next segment of the name (azuread_xxx) and add multiple possible prefixes for the label
// For example in AzureRM, under "service/signalr" we separate names into groups of 2 prefixes.
// The prefix azurerm_signalr matches resources `azurerm_signalr_shared_private_link_resource`, `azurerm_signalr_service`, `azurerm_signalr_service_custom_domain` etc.
// And web_pubsub matches `azurerm_web_pubsub_hub`, `azurerm_web_pubsub_network_acl` etc.
// But both share the "service/signalr" label.
if longestPrefix == azurerm {
if longestPrefix == providerPrefix {
prefixGroups = getPrefixesForNames(labelToNames[labelName])
} else {
prefixGroups = []Prefix{
Expand Down Expand Up @@ -346,18 +346,18 @@ func (githubIssueLabelsGenerator) run(outputFileName string, _ map[string]struct
if prefixHasMatch(labelName, prefix, labelToPrefixes) {

for _, name := range prefix.Names {
prefixes = append(prefixes, strings.TrimPrefix(name+"\\W+", azurerm))
prefixes = append(prefixes, strings.TrimPrefix(name+"\\W+", providerPrefix))
}
} else {
prefixes = append(prefixes, strings.TrimPrefix(prefix.CommonPrefix, azurerm))
prefixes = append(prefixes, strings.TrimPrefix(prefix.CommonPrefix, providerPrefix))
}
}

if len(prefixes) > 1 {
out = append(out, fmt.Sprintf(" - '### (|New or )Affected Resource\\(s\\)\\/Data Source\\(s\\)((.|\\n)*)azurerm_(%s)((.|\\n)*)###'", strings.Join(prefixes, "|")))
out = append(out, fmt.Sprintf(" - '### (|New or )Affected Resource\\(s\\)\\/Data Source\\(s\\)((.|\\n)*)%s(%s)((.|\\n)*)###'", providerPrefix, strings.Join(prefixes, "|")))
}
if len(prefixes) == 1 {
out = append(out, fmt.Sprintf(" - '### (|New or )Affected Resource\\(s\\)\\/Data Source\\(s\\)((.|\\n)*)azurerm_%s((.|\\n)*)###'", prefixes[0]))
out = append(out, fmt.Sprintf(" - '### (|New or )Affected Resource\\(s\\)\\/Data Source\\(s\\)((.|\\n)*)%s%s((.|\\n)*)###'", providerPrefix, prefixes[0]))
}
// NOTE: it's possible for a Service to contain 0 Data Sources/Resources (during initial generation)

Expand Down Expand Up @@ -430,8 +430,8 @@ func commonPrefixGroups(names []string) [][]string {
if len(names) > 0 {
sort.Strings(names)

// get the prefix of the first name in the list matching azurerm_xxxx or azurerm_xxx_* and add it to the first group
re := regexp.MustCompile("azurerm_[a-zA-Z0-9]+($|_)")
// get the prefix of the first name in the list matching azuread_xxxx or azuread_xxx_* and add it to the first group
re := regexp.MustCompile(fmt.Sprintf("%s[a-zA-Z0-9]+($|_)", providerPrefix))
prefix := ""
if match := re.FindStringSubmatch(names[0]); match != nil {
prefix = strings.TrimSuffix(match[0], "_")
Expand Down

0 comments on commit a46ae69

Please sign in to comment.