Skip to content

Commit

Permalink
fix: update resource names to snake_case (#2151)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Peabody <[email protected]>
  • Loading branch information
wyardley and apeabody authored Oct 24, 2024
1 parent bbc47f8 commit 375d27c
Show file tree
Hide file tree
Showing 40 changed files with 710 additions and 150 deletions.
12 changes: 3 additions & 9 deletions autogen/main/dns.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Manage kube-dns configmaps
*****************************************/

resource "kubernetes_config_map_v1_data" "kube-dns" {
resource "kubernetes_config_map_v1_data" "kube_dns" {
count = local.custom_kube_dns_config && !local.upstream_nameservers_config ? 1 : 0

metadata {
Expand All @@ -44,7 +44,7 @@ EOF
]
}

resource "kubernetes_config_map_v1_data" "kube-dns-upstream-nameservers" {
resource "kubernetes_config_map_v1_data" "kube_dns_upstream_nameservers" {
count = !local.custom_kube_dns_config && local.upstream_nameservers_config ? 1 : 0

metadata {
Expand All @@ -68,13 +68,7 @@ EOF
]
}

# Fix the name typo in the previous ConfigMap creation call
moved {
from = kubernetes_config_map_v1_data.kube-dns-upstream-namservers
to = kubernetes_config_map_v1_data.kube-dns-upstream-nameservers
}

resource "kubernetes_config_map_v1_data" "kube-dns-upstream-nameservers-and-stub-domains" {
resource "kubernetes_config_map_v1_data" "kube_dns_upstream_nameservers_and_stub_domains" {
count = local.custom_kube_dns_config && local.upstream_nameservers_config ? 1 : 0

metadata {
Expand Down
2 changes: 1 addition & 1 deletion autogen/main/masq.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/******************************************
Create ip-masq-agent confimap
*****************************************/
resource "kubernetes_config_map" "ip-masq-agent" {
resource "kubernetes_config_map" "ip_masq_agent" {
count = var.configure_ip_masq ? 1 : 0

metadata {
Expand Down
62 changes: 62 additions & 0 deletions autogen/main/moved.tf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

# Updates for kebab to snake case, to match best practices and Google style.
moved {
from = kubernetes_config_map_v1_data.kube-dns
to = kubernetes_config_map_v1_data.kube_dns
}

# Typo fix and snake case at the same time
moved {
from = kubernetes_config_map_v1_data.kube-dns-upstream-namservers
to = kubernetes_config_map_v1_data.kube_dns_upstream_nameservers
}

moved {
from = kubernetes_config_map_v1_data.kube-dns-upstream-nameservers-and-stub-domains
to = kubernetes_config_map_v1_data.kube_dns_upstream_nameservers_and_stub_domains
}

moved {
from = kubernetes_config_map.ip-masq-agent
to = kubernetes_config_map.ip_masq_agent
}

moved {
from = google_project_iam_member.cluster_service_account-nodeService_account
to = google_project_iam_member.cluster_service_account_node_service_account
}

moved {
from = google_project_iam_member.cluster_service_account-metric_writer
to = google_project_iam_member.cluster_service_account_metric_writer
}

moved {
from = google_project_iam_member.cluster_service_account-resourceMetadata-writer
to = google_project_iam_member.cluster_service_account_resource_metadata_writer
}

moved {
from = google_project_iam_member.cluster_service_account-gcr
to = google_project_iam_member.cluster_service_account_gcr
}

moved {
from = google_project_iam_member.cluster_service_account-artifact-registry
to = google_project_iam_member.cluster_service_account_artifact_registry
}
10 changes: 5 additions & 5 deletions autogen/main/sa.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,35 @@ resource "google_service_account" "cluster_service_account" {
display_name = "Terraform-managed service account for cluster ${var.name}"
}

resource "google_project_iam_member" "cluster_service_account-nodeService_account" {
resource "google_project_iam_member" "cluster_service_account_node_service_account" {
count = var.create_service_account ? 1 : 0
project = google_service_account.cluster_service_account[0].project
role = "roles/container.defaultNodeServiceAccount"
member = google_service_account.cluster_service_account[0].member
}

resource "google_project_iam_member" "cluster_service_account-metric_writer" {
resource "google_project_iam_member" "cluster_service_account_metric_writer" {
count = var.create_service_account ? 1 : 0
project = google_service_account.cluster_service_account[0].project
role = "roles/monitoring.metricWriter"
member = google_service_account.cluster_service_account[0].member
}

resource "google_project_iam_member" "cluster_service_account-resourceMetadata-writer" {
resource "google_project_iam_member" "cluster_service_account_resource_metadata_writer" {
count = var.create_service_account ? 1 : 0
project = google_service_account.cluster_service_account[0].project
role = "roles/stackdriver.resourceMetadata.writer"
member = google_service_account.cluster_service_account[0].member
}

resource "google_project_iam_member" "cluster_service_account-gcr" {
resource "google_project_iam_member" "cluster_service_account_gcr" {
for_each = var.create_service_account && var.grant_registry_access ? toset(local.registry_projects_list) : []
project = each.key
role = "roles/storage.objectViewer"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_iam_member" "cluster_service_account-artifact-registry" {
resource "google_project_iam_member" "cluster_service_account_artifact_registry" {
for_each = var.create_service_account && var.grant_registry_access ? toset(local.registry_projects_list) : []
project = each.key
role = "roles/artifactregistry.reader"
Expand Down
12 changes: 3 additions & 9 deletions dns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Manage kube-dns configmaps
*****************************************/

resource "kubernetes_config_map_v1_data" "kube-dns" {
resource "kubernetes_config_map_v1_data" "kube_dns" {
count = local.custom_kube_dns_config && !local.upstream_nameservers_config ? 1 : 0

metadata {
Expand All @@ -42,7 +42,7 @@ EOF
]
}

resource "kubernetes_config_map_v1_data" "kube-dns-upstream-nameservers" {
resource "kubernetes_config_map_v1_data" "kube_dns_upstream_nameservers" {
count = !local.custom_kube_dns_config && local.upstream_nameservers_config ? 1 : 0

metadata {
Expand All @@ -64,13 +64,7 @@ EOF
]
}

# Fix the name typo in the previous ConfigMap creation call
moved {
from = kubernetes_config_map_v1_data.kube-dns-upstream-namservers
to = kubernetes_config_map_v1_data.kube-dns-upstream-nameservers
}

resource "kubernetes_config_map_v1_data" "kube-dns-upstream-nameservers-and-stub-domains" {
resource "kubernetes_config_map_v1_data" "kube_dns_upstream_nameservers_and_stub_domains" {
count = local.custom_kube_dns_config && local.upstream_nameservers_config ? 1 : 0

metadata {
Expand Down
2 changes: 1 addition & 1 deletion masq.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/******************************************
Create ip-masq-agent confimap
*****************************************/
resource "kubernetes_config_map" "ip-masq-agent" {
resource "kubernetes_config_map" "ip_masq_agent" {
count = var.configure_ip_masq ? 1 : 0

metadata {
Expand Down
12 changes: 3 additions & 9 deletions modules/beta-autopilot-private-cluster/dns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Manage kube-dns configmaps
*****************************************/

resource "kubernetes_config_map_v1_data" "kube-dns" {
resource "kubernetes_config_map_v1_data" "kube_dns" {
count = local.custom_kube_dns_config && !local.upstream_nameservers_config ? 1 : 0

metadata {
Expand All @@ -41,7 +41,7 @@ EOF
]
}

resource "kubernetes_config_map_v1_data" "kube-dns-upstream-nameservers" {
resource "kubernetes_config_map_v1_data" "kube_dns_upstream_nameservers" {
count = !local.custom_kube_dns_config && local.upstream_nameservers_config ? 1 : 0

metadata {
Expand All @@ -62,13 +62,7 @@ EOF
]
}

# Fix the name typo in the previous ConfigMap creation call
moved {
from = kubernetes_config_map_v1_data.kube-dns-upstream-namservers
to = kubernetes_config_map_v1_data.kube-dns-upstream-nameservers
}

resource "kubernetes_config_map_v1_data" "kube-dns-upstream-nameservers-and-stub-domains" {
resource "kubernetes_config_map_v1_data" "kube_dns_upstream_nameservers_and_stub_domains" {
count = local.custom_kube_dns_config && local.upstream_nameservers_config ? 1 : 0

metadata {
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-autopilot-private-cluster/masq.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/******************************************
Create ip-masq-agent confimap
*****************************************/
resource "kubernetes_config_map" "ip-masq-agent" {
resource "kubernetes_config_map" "ip_masq_agent" {
count = var.configure_ip_masq ? 1 : 0

metadata {
Expand Down
62 changes: 62 additions & 0 deletions modules/beta-autopilot-private-cluster/moved.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

# Updates for kebab to snake case, to match best practices and Google style.
moved {
from = kubernetes_config_map_v1_data.kube-dns
to = kubernetes_config_map_v1_data.kube_dns
}

# Typo fix and snake case at the same time
moved {
from = kubernetes_config_map_v1_data.kube-dns-upstream-namservers
to = kubernetes_config_map_v1_data.kube_dns_upstream_nameservers
}

moved {
from = kubernetes_config_map_v1_data.kube-dns-upstream-nameservers-and-stub-domains
to = kubernetes_config_map_v1_data.kube_dns_upstream_nameservers_and_stub_domains
}

moved {
from = kubernetes_config_map.ip-masq-agent
to = kubernetes_config_map.ip_masq_agent
}

moved {
from = google_project_iam_member.cluster_service_account-nodeService_account
to = google_project_iam_member.cluster_service_account_node_service_account
}

moved {
from = google_project_iam_member.cluster_service_account-metric_writer
to = google_project_iam_member.cluster_service_account_metric_writer
}

moved {
from = google_project_iam_member.cluster_service_account-resourceMetadata-writer
to = google_project_iam_member.cluster_service_account_resource_metadata_writer
}

moved {
from = google_project_iam_member.cluster_service_account-gcr
to = google_project_iam_member.cluster_service_account_gcr
}

moved {
from = google_project_iam_member.cluster_service_account-artifact-registry
to = google_project_iam_member.cluster_service_account_artifact_registry
}
10 changes: 5 additions & 5 deletions modules/beta-autopilot-private-cluster/sa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,35 @@ resource "google_service_account" "cluster_service_account" {
display_name = "Terraform-managed service account for cluster ${var.name}"
}

resource "google_project_iam_member" "cluster_service_account-nodeService_account" {
resource "google_project_iam_member" "cluster_service_account_node_service_account" {
count = var.create_service_account ? 1 : 0
project = google_service_account.cluster_service_account[0].project
role = "roles/container.defaultNodeServiceAccount"
member = google_service_account.cluster_service_account[0].member
}

resource "google_project_iam_member" "cluster_service_account-metric_writer" {
resource "google_project_iam_member" "cluster_service_account_metric_writer" {
count = var.create_service_account ? 1 : 0
project = google_service_account.cluster_service_account[0].project
role = "roles/monitoring.metricWriter"
member = google_service_account.cluster_service_account[0].member
}

resource "google_project_iam_member" "cluster_service_account-resourceMetadata-writer" {
resource "google_project_iam_member" "cluster_service_account_resource_metadata_writer" {
count = var.create_service_account ? 1 : 0
project = google_service_account.cluster_service_account[0].project
role = "roles/stackdriver.resourceMetadata.writer"
member = google_service_account.cluster_service_account[0].member
}

resource "google_project_iam_member" "cluster_service_account-gcr" {
resource "google_project_iam_member" "cluster_service_account_gcr" {
for_each = var.create_service_account && var.grant_registry_access ? toset(local.registry_projects_list) : []
project = each.key
role = "roles/storage.objectViewer"
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
}

resource "google_project_iam_member" "cluster_service_account-artifact-registry" {
resource "google_project_iam_member" "cluster_service_account_artifact_registry" {
for_each = var.create_service_account && var.grant_registry_access ? toset(local.registry_projects_list) : []
project = each.key
role = "roles/artifactregistry.reader"
Expand Down
12 changes: 3 additions & 9 deletions modules/beta-autopilot-public-cluster/dns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Manage kube-dns configmaps
*****************************************/

resource "kubernetes_config_map_v1_data" "kube-dns" {
resource "kubernetes_config_map_v1_data" "kube_dns" {
count = local.custom_kube_dns_config && !local.upstream_nameservers_config ? 1 : 0

metadata {
Expand All @@ -41,7 +41,7 @@ EOF
]
}

resource "kubernetes_config_map_v1_data" "kube-dns-upstream-nameservers" {
resource "kubernetes_config_map_v1_data" "kube_dns_upstream_nameservers" {
count = !local.custom_kube_dns_config && local.upstream_nameservers_config ? 1 : 0

metadata {
Expand All @@ -62,13 +62,7 @@ EOF
]
}

# Fix the name typo in the previous ConfigMap creation call
moved {
from = kubernetes_config_map_v1_data.kube-dns-upstream-namservers
to = kubernetes_config_map_v1_data.kube-dns-upstream-nameservers
}

resource "kubernetes_config_map_v1_data" "kube-dns-upstream-nameservers-and-stub-domains" {
resource "kubernetes_config_map_v1_data" "kube_dns_upstream_nameservers_and_stub_domains" {
count = local.custom_kube_dns_config && local.upstream_nameservers_config ? 1 : 0

metadata {
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-autopilot-public-cluster/masq.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/******************************************
Create ip-masq-agent confimap
*****************************************/
resource "kubernetes_config_map" "ip-masq-agent" {
resource "kubernetes_config_map" "ip_masq_agent" {
count = var.configure_ip_masq ? 1 : 0

metadata {
Expand Down
Loading

0 comments on commit 375d27c

Please sign in to comment.