Skip to content

Commit 0b92d27

Browse files
authored
fix: Correct ACM param defaults (terraform-google-modules#536)
* edits to the some param descriptions to clarify use relative to google_container_cluster * edits to the some param descriptions to clarify use relative to google_container_cluster * terraform fmt fixes * now ignore setting un specified policy dir, uses configmanagement defaults instead of shadowing them * now also use configmanagement defaults for sync branch * ran docs * focused the param descriptions some, as they were a bit verbose and got good feedback to remove unnecessary detail * regenerating docs after the change to make descriptions more concise
1 parent d9f1ea8 commit 0b92d27

File tree

8 files changed

+42
-37
lines changed

8 files changed

+42
-37
lines changed

modules/acm/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ By default, this module will attempt to download the ACM operator from Google di
4545
| Name | Description | Type | Default | Required |
4646
|------|-------------|:----:|:-----:|:-----:|
4747
| cluster\_endpoint | Kubernetes cluster endpoint. | string | n/a | yes |
48-
| cluster\_name | The unique name to identify the cluster in ACM. | string | n/a | yes |
48+
| cluster\_name | GCP cluster Name used to reach cluster and which becomes the cluster name in the Config Sync kubernetes custom resource. | string | n/a | yes |
4949
| create\_ssh\_key | Controls whether a key will be generated for Git authentication | bool | `"true"` | no |
5050
| enable\_policy\_controller | Whether to enable the ACM Policy Controller on the cluster | bool | `"true"` | no |
5151
| install\_template\_library | Whether to install the default Policy Controller template library | bool | `"true"` | no |
52-
| location | The location (zone or region) this cluster has been created in. | string | n/a | yes |
52+
| location | GCP location used to reach cluster. | string | n/a | yes |
5353
| operator\_path | Path to the operator yaml config. If unset, will download from GCS releases. | string | `"null"` | no |
54-
| policy\_dir | Subfolder containing configs in ACM Git repo | string | n/a | yes |
55-
| project\_id | The project in which the resource belongs. | string | n/a | yes |
54+
| policy\_dir | Subfolder containing configs in ACM Git repo. If un-set, uses Config Management default. | string | `""` | no |
55+
| project\_id | GCP project_id used to reach cluster. | string | n/a | yes |
5656
| secret\_type | git authentication secret type, is passed through to ConfigManagement spec.git.secretType. Overriden to value 'ssh' if `create_ssh_key` is true | string | `"ssh"` | no |
5757
| skip\_gcloud\_download | Whether to skip downloading gcloud (assumes gcloud and kubectl already available outside the module) | bool | `"false"` | no |
5858
| ssh\_auth\_key | Key for Git authentication. Overrides 'create_ssh_key' variable. Can be set using 'file(path/to/file)'-function. | string | `"null"` | no |
59-
| sync\_branch | ACM repo Git branch | string | `"master"` | no |
59+
| sync\_branch | ACM repo Git branch. If un-set, uses Config Management default. | string | `""` | no |
6060
| sync\_repo | ACM Git repo address | string | n/a | yes |
6161

6262
## Outputs

modules/acm/templates/acm-config.yml.tpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ metadata:
55
spec:
66
# clusterName is required and must be unique among all managed clusters
77
clusterName: ${cluster_name}
8-
git:
9-
syncRepo: ${sync_repo}
10-
syncBranch: ${sync_branch}
11-
secretType: ${secret_type}
12-
policyDir: ${policy_dir}
138
policyController:
149
enabled: ${enable_policy_controller}
1510
templateLibraryInstalled: ${install_template_library}
11+
git:
12+
syncRepo: ${sync_repo}
13+
secretType: ${secret_type}
14+
${policy_dir_node}
15+
${sync_branch_node}

modules/acm/variables.tf

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

1717
variable "cluster_name" {
18-
description = "The unique name to identify the cluster in ACM."
18+
description = "GCP cluster Name used to reach cluster and which becomes the cluster name in the Config Sync kubernetes custom resource."
1919
type = string
2020
}
2121

2222
variable "project_id" {
23-
description = "The project in which the resource belongs."
23+
description = "GCP project_id used to reach cluster."
2424
type = string
2525
}
2626

2727
variable "location" {
28-
description = "The location (zone or region) this cluster has been created in."
28+
description = "GCP location used to reach cluster."
2929
type = string
3030
}
3131

@@ -41,14 +41,15 @@ variable "sync_repo" {
4141
}
4242

4343
variable "sync_branch" {
44-
description = "ACM repo Git branch"
44+
description = "ACM repo Git branch. If un-set, uses Config Management default."
4545
type = string
46-
default = "master"
46+
default = ""
4747
}
4848

4949
variable "policy_dir" {
50-
description = "Subfolder containing configs in ACM Git repo"
50+
description = "Subfolder containing configs in ACM Git repo. If un-set, uses Config Management default."
5151
type = string
52+
default = ""
5253
}
5354

5455
variable "cluster_endpoint" {

modules/config-sync/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ To deploy this config:
4848
| Name | Description | Type | Default | Required |
4949
|------|-------------|:----:|:-----:|:-----:|
5050
| cluster\_endpoint | Kubernetes cluster endpoint. | string | n/a | yes |
51-
| cluster\_name | The unique name to identify the cluster in ACM. | string | n/a | yes |
51+
| cluster\_name | GCP cluster name used to reach cluster and which becomes the cluster name in the Config Sync kubernetes custom resource. | string | n/a | yes |
5252
| create\_ssh\_key | Controls whether a key will be generated for Git authentication | bool | `"true"` | no |
53-
| location | The location (zone or region) this cluster has been created in. | string | n/a | yes |
53+
| location | GCP location used to reach cluster. | string | n/a | yes |
5454
| operator\_path | Path to the operator yaml config. If unset, will download from GCS releases. | string | `"null"` | no |
55-
| policy\_dir | Subfolder containing configs in ACM Git repo | string | n/a | yes |
56-
| project\_id | The project in which the resource belongs. | string | n/a | yes |
55+
| policy\_dir | Subfolder containing configs in ACM Git repo. If un-set, uses Config Management default. | string | `""` | no |
56+
| project\_id | GCP project_id used to reach cluster. | string | n/a | yes |
5757
| secret\_type | credential secret type, passed through to ConfigManagement spec.git.secretType. Overriden to value 'ssh' if `create_ssh_key` is true | string | n/a | yes |
5858
| skip\_gcloud\_download | Whether to skip downloading gcloud (assumes gcloud and kubectl already available outside the module) | bool | `"false"` | no |
5959
| ssh\_auth\_key | Key for Git authentication. Overrides 'create_ssh_key' variable. Can be set using 'file(path/to/file)'-function. | string | `"null"` | no |
60-
| sync\_branch | ACM repo Git branch | string | `"master"` | no |
60+
| sync\_branch | ACM repo Git branch. If un-set, uses Config Management default. | string | `""` | no |
6161
| sync\_repo | ACM Git repo address | string | n/a | yes |
6262

6363
## Outputs

modules/config-sync/templates/config-sync-config.yml.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ spec:
77
clusterName: ${cluster_name}
88
git:
99
syncRepo: ${sync_repo}
10-
syncBranch: ${sync_branch}
1110
secretType: ${secret_type}
12-
policyDir: ${policy_dir}
11+
${sync_branch_node}
12+
${policy_dir_node}

modules/config-sync/variables.tf

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

1717
variable "cluster_name" {
18-
description = "The unique name to identify the cluster in ACM."
18+
description = "GCP cluster name used to reach cluster and which becomes the cluster name in the Config Sync kubernetes custom resource."
1919
type = string
2020
}
2121

2222
variable "project_id" {
23-
description = "The project in which the resource belongs."
23+
description = "GCP project_id used to reach cluster."
2424
type = string
2525
}
2626

2727
variable "location" {
28-
description = "The location (zone or region) this cluster has been created in."
28+
description = "GCP location used to reach cluster."
2929
type = string
3030
}
3131

@@ -41,14 +41,15 @@ variable "sync_repo" {
4141
}
4242

4343
variable "sync_branch" {
44-
description = "ACM repo Git branch"
44+
description = "ACM repo Git branch. If un-set, uses Config Management default."
4545
type = string
46-
default = "master"
46+
default = ""
4747
}
4848

4949
variable "policy_dir" {
50-
description = "Subfolder containing configs in ACM Git repo"
50+
description = "Subfolder containing configs in ACM Git repo. If un-set, uses Config Management default."
5151
type = string
52+
default = ""
5253
}
5354

5455
variable "cluster_endpoint" {

modules/k8s-operator-crd-support/main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ locals {
2222
k8sop_creds_secret_key = var.secret_type == "cookiefile" ? "cookie_file" : var.secret_type
2323
should_download_manifest = var.operator_path == null ? true : false
2424
manifest_path = local.should_download_manifest ? "${path.root}/.terraform/tmp/config-management-operator.yaml" : var.operator_path
25+
sync_branch_node = var.sync_branch != "" ? format("syncBranch: %s", var.sync_branch) : ""
26+
policy_dir_node = var.policy_dir != "" ? format("policyDir: %s", var.policy_dir) : ""
2527
}
2628

2729

@@ -87,8 +89,8 @@ data "template_file" "k8sop_config" {
8789
vars = {
8890
cluster_name = var.cluster_name
8991
sync_repo = var.sync_repo
90-
sync_branch = var.sync_branch
91-
policy_dir = var.policy_dir
92+
sync_branch_node = local.sync_branch_node
93+
policy_dir_node = local.policy_dir_node
9294
secret_type = var.create_ssh_key ? "ssh" : var.secret_type
9395
enable_policy_controller = var.enable_policy_controller ? "true" : "false"
9496
install_template_library = var.install_template_library ? "true" : "false"

modules/k8s-operator-crd-support/variables.tf

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

1717
variable "cluster_name" {
18-
description = "The unique name to identify the cluster in ACM."
18+
description = "GCP cluster name used to reach cluster and which becomes the cluster name in the Config Sync kubernetes custom resource."
1919
type = string
2020
}
2121

2222
variable "project_id" {
23-
description = "The project in which the resource belongs."
23+
description = "GCP project_id used to reach cluster."
2424
type = string
2525
}
2626

2727
variable "location" {
28-
description = "The location (zone or region) this cluster has been created in."
28+
description = "GCP location used to reach cluster."
2929
type = string
3030
}
3131

@@ -51,14 +51,15 @@ variable "secret_type" {
5151
}
5252

5353
variable "sync_branch" {
54-
description = "ACM repo Git branch"
54+
description = "ACM repo Git branch. If un-set, uses Config Management default."
5555
type = string
56-
default = "master"
56+
default = ""
5757
}
5858

5959
variable "policy_dir" {
60-
description = "Subfolder containing configs in ACM Git repo"
60+
description = "Subfolder containing configs in ACM Git repo. If un-set, uses Config Management default."
6161
type = string
62+
default = ""
6263
}
6364

6465
variable "cluster_endpoint" {

0 commit comments

Comments
 (0)