Skip to content

Commit

Permalink
Tests and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredfholgate committed Oct 28, 2023
1 parent 37683ca commit 5a5e8b8
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 24 deletions.
12 changes: 6 additions & 6 deletions bootstrap/azuredevops/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ module "resource_names" {

locals {
managed_identities = {
"${local.plan_key}" = local.resource_names.user_assigned_managed_identity_plan
"${local.apply_key}" = local.resource_names.user_assigned_managed_identity_apply
(local.plan_key) = local.resource_names.user_assigned_managed_identity_plan
(local.apply_key) = local.resource_names.user_assigned_managed_identity_apply
}

federated_credentials = {
"${local.plan_key}" = {
(local.plan_key) = {
federated_credential_subject = module.azure_devops.subjects[local.plan_key]
federated_credential_issuer = module.azure_devops.issuers[local.plan_key]
federated_credential_name = local.resource_names.user_assigned_managed_identity_federated_credentials_plan
}
"${local.apply_key}" = {
(local.apply_key) = {
federated_credential_subject = module.azure_devops.subjects[local.apply_key]
federated_credential_issuer = module.azure_devops.issuers[local.apply_key]
federated_credential_name = local.resource_names.user_assigned_managed_identity_federated_credentials_apply
Expand Down Expand Up @@ -108,12 +108,12 @@ locals {

locals {
environments = {
"${local.plan_key}" = {
(local.plan_key) = {
environment_name = local.resource_names.version_control_system_environment_plan
service_connection_name = local.resource_names.version_control_system_service_connection_plan
agent_pool_name = local.resource_names.version_control_system_agent_pool_plan
}
"${local.apply_key}" = {
(local.apply_key) = {
environment_name = local.resource_names.version_control_system_environment_apply
service_connection_name = local.resource_names.version_control_system_service_connection_apply
agent_pool_name = local.resource_names.version_control_system_agent_pool_apply
Expand Down
12 changes: 6 additions & 6 deletions bootstrap/github/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ module "resource_names" {

locals {
managed_identities = {
"${local.plan_key}" = local.resource_names.user_assigned_managed_identity_plan
"${local.apply_key}" = local.resource_names.user_assigned_managed_identity_apply
(local.plan_key) = local.resource_names.user_assigned_managed_identity_plan
(local.apply_key) = local.resource_names.user_assigned_managed_identity_apply
}

federated_credentials = {
"${local.plan_key}" = {
(local.plan_key) = {
federated_credential_subject = module.github.subjects[local.plan_key]
federated_credential_issuer = module.github.issuer
federated_credential_name = local.resource_names.user_assigned_managed_identity_federated_credentials_plan
}
"${local.apply_key}" = {
(local.apply_key) = {
federated_credential_subject = module.github.subjects[local.apply_key]
federated_credential_issuer = module.github.issuer
federated_credential_name = local.resource_names.user_assigned_managed_identity_federated_credentials_apply
Expand Down Expand Up @@ -72,8 +72,8 @@ locals {

locals {
environments = {
"${local.plan_key}" = local.resource_names.version_control_system_environment_plan
"${local.apply_key}" = local.resource_names.version_control_system_environment_apply
(local.plan_key) = local.resource_names.version_control_system_environment_plan
(local.apply_key) = local.resource_names.version_control_system_environment_apply
}
}

Expand Down
1 change: 1 addition & 0 deletions bootstrap/modules/azure_devops/repository.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ resource "azuredevops_git_repository_file" "alz" {
file = each.key
content = each.value.content
branch = local.default_branch
commit_message = "Add ${each.key} [skip ci]"
overwrite_on_create = true
}

Expand Down
4 changes: 2 additions & 2 deletions bootstrap/modules/github/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ output "organization_url" {

output "subjects" {
value = {
"${local.plan_key}" = "repo:${var.organization_name}/${var.repository_name}:environment:${var.environments[local.plan_key]}"
"${local.apply_key}" = "repo:${var.organization_name}/${var.repository_name}:environment:${var.environments[local.apply_key]}"
(local.plan_key) = "repo:${var.organization_name}/${var.repository_name}:environment:${var.environments[local.plan_key]}"
(local.apply_key) = "repo:${var.organization_name}/${var.repository_name}:environment:${var.environments[local.apply_key]}"
}
}

Expand Down
13 changes: 10 additions & 3 deletions templates/.test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ data "azurerm_management_group" "example_parent" {
display_name = var.parent_management_group_display_name
}

resource "random_string" "example" {
length = 10
special = false
numeric = false
upper = false
}

resource "azurerm_management_group" "example_child" {
name = var.child_management_group_name
display_name = var.child_management_group_display_name
name = "e2e-test-${random_string.example.result}"
display_name = "${var.child_management_group_display_name} ${random_string.example.result}"
parent_management_group_id = data.azurerm_management_group.example_parent.id
}

resource "azurerm_resource_group" "example" {
name = var.resource_group_name
name = "e2e-test-${random_string.example.result}"
location = var.resource_group_location
}
4 changes: 4 additions & 0 deletions templates/.test/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ output "parent_management_group_display_name" {
value = data.azurerm_management_group.example_parent.display_name
}

output "child_management_group_name" {
value = azurerm_management_group.example_child.name
}

output "child_management_group_display_name" {
value = azurerm_management_group.example_child.display_name
}
Expand Down
8 changes: 1 addition & 7 deletions templates/.test/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,10 @@ variable "parent_management_group_display_name" {
default = "Tenant Root Group"
}

variable "child_management_group_name" {
description = "The child management group name for testing|5"
type = string
default = "testing123"
}

variable "child_management_group_display_name" {
description = "The child management group for testing display name|6"
type = string
default = "Testing 123"
default = "E2E Test"
}

variable "resource_group_location" {
Expand Down

0 comments on commit 5a5e8b8

Please sign in to comment.