Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ Function Get-AvmCsvData {
foreach ($item in $filterCsvAvailableBicepModule) {
# Remove '@Azure/' from the ModuleOwnersGHTeam property
$item.ModuleOwnersGHTeam = $item.ModuleOwnersGHTeam -replace '@Azure/', ''
# Remove '@Azure/' from the ModuleContributorsGHTeam property
$item.ModuleContributorsGHTeam = $item.ModuleContributorsGHTeam -replace '@Azure/', ''
}

# Return the filtered and modified data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,5 @@ Function Get-AvmGitHubTeamRepoConfiguration {
$findings = "Success"
}
}
elseif ($teamName -like "*contributors*") {
$expectedPermission = "write"
if ($filteredJson.role_name -ne $expectedPermission) {
$findings = "Team: $TeamName is not configured with the expected permission: $expectedPermission on Repo: $repoName"
}
else {
Write-Output "Good News! Repo: $repoName is configured with the expected permission: $expectedPermission"
$findings = "Success"
}
}
return $findings

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,46 +29,34 @@ Function Get-AvmGitHubTeamsData {
$filterAvmBicepResGhTeams = $filterAvmBicepGhTeams | Where-Object { $_.name -like '*res-*' }
# Filter AVM Module Teams for Bicep Resource Modules Owners
$filterAvmBicepResGhTeamsOwners = $filterAvmBicepResGhTeams | Where-Object { $_.name -like '*owners-*' }
# Filter AVM Module Teams for Bicep Resource Modules Contributors
$filterAvmBicepResGhTeamsContributors = $filterAvmBicepResGhTeams | Where-Object { $_.name -like '*contributors-*' }
# Filter AVM Module Teams for Bicep Pattern Modules
$filterAvmBicepPtnGhTeams = $filterAvmBicepGhTeams | Where-Object { $_.name -like '*ptn-*' }
# Filter AVM Module Teams for Bicep Pattern Modules Owners
$filterAvmBicepPtnGhTeamsOwners = $filterAvmBicepPtnGhTeams | Where-Object { $_.name -like '*owners-*' }
# Filter AVM Module Teams for Bicep Pattern Modules Contributors
$filterAvmBicepPtnGhTeamsContributors = $filterAvmBicepPtnGhTeams | Where-Object { $_.name -like '*contributors-*' }
# Filter AVM Module Teams for Terraform
$filterAvmTfGhTeams = $filterAvmGhTeams | Where-Object { $_.name -like '*tf' }
# Filter AVM Module Teams for Terraform Resource Modules
$filterAvmTfResGhTeams = $filterAvmTfGhTeams | Where-Object { $_.name -like '*res-*' }
# Filter AVM Module Teams for Terraform Resource Modules Owners
$filterAvmTfResGhTeamsOwners = $filterAvmTfResGhTeams | Where-Object { $_.name -like '*owners-*' }
# Filter AVM Module Teams for Terraform Resource Modules Contributors
$filterAvmTfResGhTeamsContributors = $filterAvmTfResGhTeams | Where-Object { $_.name -like '*contributors-*' }
# Filter AVM Module Teams for Terraform Pattern Modules
# Filter AVM Module Teams for Terraform Pattern Modules
$filterAvmTfPtnGhTeams = $filterAvmTfGhTeams | Where-Object { $_.name -like '*ptn-*' }
# Filter AVM Module Teams for Terraform Pattern Modules Owners
$filterAvmTfPtnGhTeamsOwners = $filterAvmTfPtnGhTeams | Where-Object { $_.name -like '*owners-*' }
# Filter AVM Module Teams for Terraform Pattern Modules Contributors
$filterAvmTfPtnGhTeamsContributors = $filterAvmTfPtnGhTeams | Where-Object { $_.name -like '*contributors-*' }

switch ($TeamFilter) {
'AllTeams' { return $filterAvmGhTeams }
'AllResource' { return $filterAvmResGhTeams }
'AllPattern' { return $filterAvmPtnGhTeams }
'AllBicep' { return $filterAvmBicepGhTeams }
'BicepResourceOwners' { return $filterAvmBicepResGhTeamsOwners }
'BicepResourceContributors' { return $filterAvmBicepResGhTeamsContributors }
'AllBicepResource' { return $filterAvmBicepResGhTeams }
'AllBicepPattern' { return $filterAvmBicepPtnGhTeams }
'BicepPatternOwners' { return $filterAvmBicepPtnGhTeamsOwners }
'BicepPatternContributors' { return $filterAvmBicepPtnGhTeamsContributors }
'AllTerraform' { return $filterAvmTfGhTeams }
'AllTerraformResource' { return $filterAvmTfResGhTeams }
'TerraformResourceOwners' { return $filterAvmTfResGhTeamsOwners }
'TerraformResourceContributors' { return $filterAvmTfResGhTeamsContributors }
'AllTerraformPattern' { return $filterAvmTfPtnGhTeams }
'TerraformPatternOwners' { return $filterAvmTfPtnGhTeamsOwners }
'TerraformPatternContributors' { return $filterAvmTfPtnGhTeamsContributors }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ Function Invoke-AvmGitHubTeamLinter {
if ($TeamFilter -like '*Owners*') {
$validateOwnerTeams = $true
}
if ($TeamFilter -like '*Contributors*') {
$validateContributorTeams = $true
}

# Retrieve the CSV file
$sourceData = Get-AvmCsvData -ModuleIndex $ModuleIndex
$gitHubTeamsData = Get-AvmGitHubTeamsData -TeamFilter $TeamFilter
Expand Down Expand Up @@ -116,7 +112,7 @@ Function Invoke-AvmGitHubTeamLinter {
Write-Verbose "Uh-oh no incorrect owner configured for [$($ghTeam.name)]"
# Create a custom object for the unmatched team
$unmatchedTeam = [PSCustomObject]@{
TeamName = $module.ModuleContributorsGHTeam
TeamName = $module.ModuleOwnersGHTeam
Validation = "Owner Not Assigned in Team."
Owner = "$($module.PrimaryModuleOwnerGHHandle) ($($module.PrimaryModuleOwnerDisplayName))"
GitHubTeamName = $ghTeam.name
Expand All @@ -142,7 +138,7 @@ Function Invoke-AvmGitHubTeamLinter {
Validation = "No parent team assigned."
Owner = "$($module.PrimaryModuleOwnerGHHandle) ($($module.PrimaryModuleOwnerDisplayName))"
GitHubTeamName = $ghTeam.name
Resolution = "Assign the correct parent team to the team: $($module.ModuleOwnersGHTeam) [here](https://github.com/orgs/Azure/teams/$($module.ModuleContributorsGHTeam)). Parent information can be found in [SNFR20](https://azure.github.io/Azure-Verified-Modules/spec/SNFR20)."
Resolution = "Assign the correct parent team to the team: $($module.ModuleOwnersGHTeam). Parent information can be found in [SNFR20](https://azure.github.io/Azure-Verified-Modules/spec/SNFR20)."
}
# Add the custom object to the array
$unmatchedTeams += $unmatchedTeam
Expand Down Expand Up @@ -223,110 +219,6 @@ Function Invoke-AvmGitHubTeamLinter {
}
}

if ($validateContributorTeams -Or $validateAll) {
# Check each object in $ghTeam for a match
foreach ($ghTeam in $gitHubTeamsData) {
if ($module.ModuleContributorsGHTeam -eq $ghTeam.name) {
# If a match is found, set flag to true and break out of the loop
$matchFound = $true

# Validate if Parent Team is configured for Contributors Team
if ($ValidateBicepParentConfiguration -and $matchFound) {
# Check if Parent Team is configured for Contributors Team
if (-not $null -eq $ghTeam.parent -and $ValidateBicepParentConfiguration) {
Write-Verbose "Found team: $($module.ModuleContributorsGHTeam) with parent: $($ghTeam.parent.name) owned by $($module.PrimaryModuleOwnerDisplayName)"
break
}
else {
Write-Verbose "Uh-oh no parent team configured for $($module.ModuleContributorsGHTeam) ($($module.PrimaryModuleOwnerDisplayName))"
# Create a custom object for the unmatched team
$unmatchedTeam = [PSCustomObject]@{
TeamName = $module.ModuleContributorsGHTeam
Validation = "No parent team assigned."
Owner = "$($module.PrimaryModuleOwnerGHHandle) ($($module.PrimaryModuleOwnerDisplayName))"
GitHubTeamName = $ghTeam.name
Resolution = "Assign the correct parent team to the team: $($module.ModuleContributorsGHTeam) [here](https://github.com/orgs/Azure/teams/$($module.ModuleContributorsGHTeam)). Parent information can be found in [SNFR20](https://azure.github.io/Azure-Verified-Modules/spec/SNFR20)."
}
# Add the custom object to the array
$unmatchedTeams += $unmatchedTeam
}
}
elseif ($ValidateTerraformTeamsPermissons -and $matchFound) {
Write-Verbose "Found team: $($module.ModuleContributorsGHTeam) Checking Permissions configuration"
if ($module.ModuleContributorsGHTeam -like "*-tf") {
$repoName = "terraform-azurerm-$($module.ModuleName)"
$repoConfiguration = Test-AvmGitHubTeamPermission -Organization Azure -TeamName $module.ModuleContributorsGHTeam -RepoName $repoName -ExpectedPermission "Write"
if ($repoConfiguration -match "Success") {
Write-Verbose "Good News! Team: [$($module.ModuleOwnersGHTeam)] is configured with the expected permission: [write] on Repo: [$repoName] "
Write-Verbose "Checking if an issue exists for the team: [$($ghTeam.name)]..."
Close-ResolvedGithubIssue -title "[GitHub Team Issue] ``$($ghTeam.name)``"
}
else {
Write-Verbose "Uh-oh no correct permissions configured for $($module.ModuleContributorsGHTeam) ($($module.PrimaryModuleOwnerDisplayName))"
# Create a custom object for the unmatched team
$unmatchedTeam = [PSCustomObject]@{
TeamName = $module.ModuleContributorsGHTeam
Validation = "No correct permissions assigned."
Owner = "$($module.PrimaryModuleOwnerGHHandle) ($($module.PrimaryModuleOwnerDisplayName))"
GitHubTeamName = $ghTeam.name
Resolution = "Please assign the correct permissions to the team: $($module.ModuleContributorsGHTeam). This can be found in [SNFR20](https://azure.github.io/Azure-Verified-Modules/spec/SNFR20)."
}
# Add the custom object to the array
$unmatchedTeams += $unmatchedTeam
break
}
}
else {
Write-Verbose "Skipping non Terraform module: $($module.ModuleContributorsGHTeam)"
break
}
}
elseif ($matchFound) {
Write-Verbose "Found team: $($module.ModuleContributorsGHTeam) ($($module.PrimaryModuleOwnerDisplayName))"
break
}

}

# Check for match with "@Azure/" prefix
# Construct the prefixed team name
$prefixedTeamName = "@azure/" + $module.ModuleContributorsGHTeam

# Check for match with "@Azure/" prefix
if ($prefixedTeamName -eq $ghTeam.name) {
$matchFound = $true
Write-Verbose "Uh-oh team found with '@azure/' prefix for: $($ghTeam.name), Current Owner is $($module.PrimaryModuleOwnerGHHandle) ($($module.PrimaryModuleOwnerDisplayName))"
$unmatchedTeam = [PSCustomObject]@{
TeamName = $module.ModuleContributorsGHTeam
Validation = "@azure/ prefix found."
Owner = "$($module.PrimaryModuleOwnerGHHandle) ($($module.PrimaryModuleOwnerDisplayName))"
GitHubTeamName = $ghTeam.name
Resolution = "Remove the '@azure/' prefix from the team name."
}
# Add the custom object to the array
$unmatchedTeams += $unmatchedTeam
break
}
}

# If no match was found, output the item from $csv
if (-not $matchFound) {
Write-Verbose "No team found for: $($module.ModuleContributorsGHTeam), Current Owner is $($module.PrimaryModuleOwnerGHHandle) ($($module.PrimaryModuleOwnerDisplayName))"
if (-not $matchFound) {
Write-Verbose "No team found for: $($module.ModuleContributorsGHTeam), Current Owner is $($module.PrimaryModuleOwnerGHHandle) ($($module.PrimaryModuleOwnerDisplayName))"
$unmatchedTeam = [PSCustomObject]@{
TeamName = $module.ModuleContributorsGHTeam
Validation = "GitHub team not found. "
Owner = "$($module.PrimaryModuleOwnerGHHandle) ($($module.PrimaryModuleOwnerDisplayName))"
GitHubTeamName = "N/A"
Resolution = "Create a new team with the name $($module.ModuleContributorsGHTeam) [here](https://github.com/orgs/Azure/new-team)."
}
# Add the custom object to the array
$unmatchedTeams += $unmatchedTeam
}
}
}

if ($validateTerraformAdminPermissions -Or $validateAll) {
foreach ($tfAdminteam in $TerraformAdminTeamList) {
if ($module.ModuleOwnersGHTeam -like "*-tf") {
Expand All @@ -342,7 +234,7 @@ Function Invoke-AvmGitHubTeamLinter {
Write-Verbose "Uh-oh no correct permissions configured for [$tfAdminteam]"
# Create a custom object for the unmatched team
$unmatchedTeam = [PSCustomObject]@{
TeamName = $module.ModuleContributorsGHTeam
TeamName = $module.ModuleOwnersGHTeam
Validation = "No correct permissions assigned."
Owner = "$($module.PrimaryModuleOwnerGHHandle) ($($module.PrimaryModuleOwnerDisplayName))"
GitHubTeamName = $tfAdminteam
Expand Down