Skip to content

Commit a4d7560

Browse files
author
Sam Naser
committed
Lint
1 parent c61787a commit a4d7560

File tree

7 files changed

+55
-46
lines changed

7 files changed

+55
-46
lines changed

examples/simple_zonal_with_asm/hub.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
*/
1616

1717
resource "google_gke_hub_membership" "cluster_membership" {
18-
provider = google-beta
19-
project = var.project_id
18+
provider = google-beta
19+
project = var.project_id
2020
membership_id = "${module.gke.name}-membership"
21-
endpoint{
21+
endpoint {
2222
gke_cluster {
2323
resource_link = "//container.googleapis.com/${module.gke.cluster_id}"
2424
}

examples/simple_zonal_with_asm/main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ module "gke" {
5757
}
5858

5959
module "asm" {
60-
source = "../../modules/asm"
61-
cluster_name = module.gke.name
62-
cluster_location = module.gke.location
63-
project_id = var.project_id
64-
location = module.gke.location
60+
source = "../../modules/asm"
61+
cluster_name = module.gke.name
62+
cluster_location = module.gke.location
63+
project_id = var.project_id
64+
location = module.gke.location
6565
}

modules/asm/main.tf

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616

1717
locals {
1818
// GKE release channel is a list with max length 1 https://github.com/hashicorp/terraform-provider-google/blob/9d5f69f9f0f74f1a8245f1a52dd6cffb572bbce4/google/resource_container_cluster.go#L954
19-
gke_release_channel = length(data.google_container_cluster.asm_cluster.release_channel) > 0 ? data.google_container_cluster.asm_cluster.release_channel[0].channel : ""
19+
gke_release_channel = length(data.google_container_cluster.asm_cluster.release_channel) > 0 ? data.google_container_cluster.asm_cluster.release_channel[0].channel : ""
2020
gke_release_channel_fixed = local.gke_release_channel == "UNSPECIFIED" ? "" : local.gke_release_channel
2121
// In order or precedence, use (1) user specified channel, (2) GKE release channel, and (3) regular channel
22-
channel = lower(coalesce(var.channel, local.gke_release_channel_fixed, "regular"))
23-
revision_name = "asm-managed${local.channel == "regular" ? "" : "-${local.channel}"}"
22+
channel = lower(coalesce(var.channel, local.gke_release_channel_fixed, "regular"))
23+
revision_name = "asm-managed${local.channel == "regular" ? "" : "-${local.channel}"}"
2424
mesh_config_name = "istio-${local.revision_name}"
2525
// CNI should be enabled if either enable_cni or enable_mdp are set
2626
enable_cni = var.enable_cni || var.enable_mdp
2727
}
2828

2929
data "google_container_cluster" "asm_cluster" {
30-
project = var.project_id
31-
name = var.cluster_name
30+
project = var.project_id
31+
name = var.cluster_name
3232
location = var.cluster_location
3333

3434
// This evaluates during planning phase unless we explicitly require a dependency on
@@ -44,21 +44,21 @@ resource "kubernetes_namespace" "system_namespace" {
4444
}
4545

4646
resource "kubernetes_config_map" "mesh_config" {
47-
metadata {
48-
name = local.mesh_config_name
49-
namespace = kubernetes_namespace.system_namespace.metadata[0].name
50-
labels = {
51-
"istio.io/rev" = local.revision_name
52-
}
53-
}
54-
data = {
55-
mesh = yamlencode(var.mesh_config)
47+
metadata {
48+
name = local.mesh_config_name
49+
namespace = kubernetes_namespace.system_namespace.metadata[0].name
50+
labels = {
51+
"istio.io/rev" = local.revision_name
5652
}
53+
}
54+
data = {
55+
mesh = yamlencode(var.mesh_config)
56+
}
5757
}
5858

5959
resource "kubernetes_config_map" "asm_options" {
6060
metadata {
61-
name = "asm-options"
61+
name = "asm-options"
6262
namespace = kubernetes_namespace.system_namespace.metadata[0].name
6363
}
6464

@@ -68,18 +68,18 @@ resource "kubernetes_config_map" "asm_options" {
6868
}
6969

7070
resource "google_gke_hub_feature" "mesh_feature" {
71-
name = "servicemesh"
72-
project = var.project_id
71+
name = "servicemesh"
72+
project = var.project_id
7373
location = "global"
7474
provider = google-beta
7575
}
7676

7777
module "cpr" {
78-
source = "terraform-google-modules/gcloud/google//modules/kubectl-wrapper"
78+
source = "terraform-google-modules/gcloud/google//modules/kubectl-wrapper"
7979

80-
project_id = var.project_id
81-
cluster_name = var.cluster_name
82-
cluster_location = var.cluster_location
80+
project_id = var.project_id
81+
cluster_name = var.cluster_name
82+
cluster_location = var.cluster_location
8383

8484
kubectl_create_command = "${path.module}/scripts/create_cpr.sh ${local.revision_name} ${local.channel} ${local.enable_cni}"
8585
kubectl_destroy_command = "${path.module}/scripts/destroy_cpr.sh ${local.revision_name}"

modules/asm/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
*/
1616

1717
output "revision_name" {
18-
value = local.revision_name
18+
value = local.revision_name
1919
description = "The name of the installed managed ASM revision."
2020
}

modules/asm/scripts/create_cpr.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,17 @@ fi
2323

2424
# Wait for the CRD to get created before creating the CPR.
2525
readonly CPR_RESOURCE=controlplanerevisions.mesh.cloud.google.com
26-
for i in {1..6}; do kubectl get crd ${CPR_RESOURCE} && break || sleep 10; done
27-
kubectl wait --for condition=established --timeout=60s crd/${CPR_RESOURCE}
26+
for _i in {1..6}; do
27+
echo "Ensuring ControlPlaneRevision exists in cluster... attempt ${_i}"
28+
if kubectl get crd "${CPR_RESOURCE}"
29+
then
30+
break
31+
else
32+
sleep 10
33+
fi
34+
done
35+
36+
kubectl wait --for condition=established --timeout=60s crd/"${CPR_RESOURCE}"
2837

2938
REVISION_NAME=$1; shift
3039
CHANNEL=$1; shift
@@ -43,4 +52,4 @@ spec:
4352
channel: "${CHANNEL}"
4453
EOF
4554

46-
kubectl wait -n istio-system --for=condition=Reconciled controlplanerevision/${REVISION_NAME} --timeout 5m
55+
kubectl wait -n istio-system --for=condition=Reconciled controlplanerevision/"${REVISION_NAME}" --timeout 5m

modules/asm/scripts/destroy_cpr.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ fi
2323

2424
REVISION_NAME=$1; shift
2525

26-
if !kubectl delete controlplanerevision -n istio-system ${REVISION_NAME} ; then
26+
if ! kubectl delete controlplanerevision -n istio-system "${REVISION_NAME}" ; then
2727
echo "ControlPlaneRevision ${REVISION_NAME} not found"
2828
fi

modules/asm/variables.tf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@
1616

1717
variable "project_id" {
1818
description = "The project in which the resource belongs."
19-
type = string
19+
type = string
2020
}
2121

2222
variable "cluster_name" {
2323
description = "The unique name to identify the cluster in ASM."
24-
type = string
24+
type = string
2525
}
2626

2727
variable "cluster_location" {
2828
description = "The cluster location for this ASM installation."
29-
type = string
29+
type = string
3030
}
3131

3232
variable "channel" {
3333
description = "The channel to use for this ASM installation."
34-
type = string
34+
type = string
3535
validation {
3636
condition = anytrue([
3737
var.channel == "rapid",
@@ -46,26 +46,26 @@ variable "channel" {
4646

4747
variable "enable_cni" {
4848
description = "Determines whether to enable CNI for this ASM installation."
49-
type = bool
50-
default = true
49+
type = bool
50+
default = true
5151
}
5252

5353
// This should be validated so that it cannot be enabled while CNI is disabled
5454
// but validating based on other variables is not possible today (https://github.com/hashicorp/terraform/issues/25609)
5555
variable "enable_mdp" {
5656
description = "Determines whether to enable Managed Data Plane (MDP) for this ASM installation."
57-
type = bool
58-
default = true
57+
type = bool
58+
default = true
5959
}
6060

6161
variable "enable_cross_cluster_service_discovery" {
6262
description = "Determines whether to enable cross-cluster service discovery between this cluster and other clusters in the fleet."
63-
type = bool
64-
default = false
63+
type = bool
64+
default = false
6565
}
6666

6767
variable "mesh_config" {
6868
description = "MeshConfig specifies configuration available to the control plane. The full list of options can be found at https://istio.io/latest/docs/reference/config/istio.mesh.v1alpha1/#MeshConfig"
69-
type = map
70-
default = {}
69+
type = map(any)
70+
default = {}
7171
}

0 commit comments

Comments
 (0)