Skip to content

Commit da87606

Browse files
committed
Fix linter errors
1 parent 11fe1de commit da87606

File tree

35 files changed

+116
-102
lines changed

35 files changed

+116
-102
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99
### Changed
10+
* Add support for private clusters via submodule. #69
1011
* Set `horizontal_pod_autoscaling` to `true` by default. #42
1112
* Add `remove_default_node_pool` set to `false` by default #15
1213
* Allow arbitrary key-value pairs to be set on node pool metadata. #52
13-
* Add `initial_node_count` parameter to node_pool block. #60
14+
* Add `initial_node_count` parameter to node_pool block. #60
1415

1516
## [v0.4.0] - 2018-12-19
1617
### Added

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Terraform Kubernetes Engine Module
22

3-
This module handles opinionated Google Cloud Platform Kubernetes Engine cluster creation and configuration with Node Pools, IP MASQ, Network Policy, etc.
3+
This module handles opinionated Google Cloud Platform Kubernetes Engine cluster creation and configuration with Node Pools, IP MASQ, Network Policy, etc.
44
The resources/services/activations/deletions that this module will create/trigger are:
55
- Create a GKE cluster with the provided addons
66
- Create GKE Node Pool(s) with provided configuration and attach to cluster
@@ -263,7 +263,7 @@ Alternatively, you can simply run `make test_integration_docker` to run all the
263263
#### Test configuration
264264

265265
Each test-kitchen instance is configured with a `variables.tfvars` file in the test fixture directory, e.g. `test/fixtures/node_pool/terraform.tfvars`.
266-
For convenience, since all of the variables are project-specific, these files have been symlinked to `test/fixtures/shared/terraform.tfvars`.
266+
For convenience, since all of the variables are project-specific, these files have been symlinked to `test/fixtures/shared/terraform.tfvars`.
267267
Similarly, each test fixture has a `variables.tf` to define these variables, and an `outputs.tf` to facilitate providing necessary information for `inspec` to locate and query against created resources.
268268

269269
Each test-kitchen instance creates a GCP Network and Subnetwork fixture to house resources, and may create any other necessary fixture data as needed.
@@ -313,4 +313,4 @@ are as follows:
313313
is a compiled language so there is no standard linter.
314314
* Terraform - terraform has a built-in linter in the 'terraform validate'
315315
command.
316-
* Dockerfiles - hadolint. Can be found in homebrew
316+
* Dockerfiles - hadolint. Can be found in homebrew

auth.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ provider "kubernetes" {
3131
host = "https://${local.cluster_endpoint}"
3232
token = "${data.google_client_config.default.access_token}"
3333
cluster_ca_certificate = "${base64decode(local.cluster_ca_certificate)}"
34-
}
34+
}

autogen/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ Alternatively, you can simply run `make test_integration_docker` to run all the
273273
#### Test configuration
274274

275275
Each test-kitchen instance is configured with a `variables.tfvars` file in the test fixture directory, e.g. `test/fixtures/node_pool/terraform.tfvars`.
276-
For convenience, since all of the variables are project-specific, these files have been symlinked to `test/fixtures/shared/terraform.tfvars`.
276+
For convenience, since all of the variables are project-specific, these files have been symlinked to `test/fixtures/shared/terraform.tfvars`.
277277
Similarly, each test fixture has a `variables.tf` to define these variables, and an `outputs.tf` to facilitate providing necessary information for `inspec` to locate and query against created resources.
278278

279279
Each test-kitchen instance creates a GCP Network and Subnetwork fixture to house resources, and may create any other necessary fixture data as needed.

build/docker/kitchen_terraform/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
ARG BASE_IMAGE
1616

17+
# hadolint ignore=DL3006
1718
FROM $BASE_IMAGE
1819

1920
RUN apk add --no-cache \

cluster_regional.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ resource "google_container_cluster" "primary" {
8484
service_account = "${lookup(var.node_pools[0], "service_account", var.service_account)}"
8585
}
8686
}
87+
8788
remove_default_node_pool = "${var.remove_default_node_pool}"
8889
}
8990

@@ -154,4 +155,4 @@ resource "null_resource" "wait_for_regional_cluster" {
154155
}
155156

156157
depends_on = ["google_container_cluster.primary", "google_container_node_pool.pools"]
157-
}
158+
}

cluster_zonal.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ resource "google_container_cluster" "zonal_primary" {
8484
service_account = "${lookup(var.node_pools[0], "service_account", var.service_account)}"
8585
}
8686
}
87+
8788
remove_default_node_pool = "${var.remove_default_node_pool}"
8889
}
8990

@@ -154,4 +155,4 @@ resource "null_resource" "wait_for_zonal_cluster" {
154155
}
155156

156157
depends_on = ["google_container_cluster.zonal_primary", "google_container_node_pool.zonal_pools"]
157-
}
158+
}

dns.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ EOF
5151
}
5252

5353
depends_on = ["null_resource.delete_default_kube_dns_configmap", "data.google_client_config.default", "google_container_cluster.primary", "google_container_node_pool.pools", "google_container_cluster.zonal_primary", "google_container_node_pool.zonal_pools"]
54-
}
54+
}

examples/deploy_service/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ To provision this example, run the following from within this directory:
5050
- `terraform init` to get the plugins
5151
- `terraform plan` to see the infrastructure plan
5252
- `terraform apply` to apply the infrastructure build
53-
- `terraform destroy` to destroy the built infrastructure
53+
- `terraform destroy` to destroy the built infrastructure

examples/node_pool/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ To provision this example, run the following from within this directory:
4444
- `terraform init` to get the plugins
4545
- `terraform plan` to see the infrastructure plan
4646
- `terraform apply` to apply the infrastructure build
47-
- `terraform destroy` to destroy the built infrastructure
47+
- `terraform destroy` to destroy the built infrastructure

examples/shared_vpc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ To provision this example, run the following from within this directory:
4545
- `terraform init` to get the plugins
4646
- `terraform plan` to see the infrastructure plan
4747
- `terraform apply` to apply the infrastructure build
48-
- `terraform destroy` to destroy the built infrastructure
48+
- `terraform destroy` to destroy the built infrastructure

examples/simple_regional/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ To provision this example, run the following from within this directory:
4444
- `terraform init` to get the plugins
4545
- `terraform plan` to see the infrastructure plan
4646
- `terraform apply` to apply the infrastructure build
47-
- `terraform destroy` to destroy the built infrastructure
47+
- `terraform destroy` to destroy the built infrastructure

examples/simple_regional_private/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ To provision this example, run the following from within this directory:
4444
- `terraform init` to get the plugins
4545
- `terraform plan` to see the infrastructure plan
4646
- `terraform apply` to apply the infrastructure build
47-
- `terraform destroy` to destroy the built infrastructure
47+
- `terraform destroy` to destroy the built infrastructure

examples/simple_regional_private/main.tf

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@ provider "google-beta" {
2424
}
2525

2626
data "google_compute_subnetwork" "subnetwork" {
27-
name = "${var.subnetwork}"
28-
project = "${var.project_id}"
29-
region = "${var.region}"
27+
name = "${var.subnetwork}"
28+
project = "${var.project_id}"
29+
region = "${var.region}"
3030
}
3131

3232
module "gke" {
33-
source = "../../modules/private-cluster/"
34-
project_id = "${var.project_id}"
35-
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
36-
regional = true
37-
region = "${var.region}"
38-
network = "${var.network}"
39-
subnetwork = "${var.subnetwork}"
40-
ip_range_pods = "${var.ip_range_pods}"
41-
ip_range_services = "${var.ip_range_services}"
42-
service_account = "${var.compute_engine_service_account}"
43-
enable_private_endpoint = true
44-
enable_private_nodes = true
45-
master_ipv4_cidr_block = "172.16.0.0/28"
33+
source = "../../modules/private-cluster/"
34+
project_id = "${var.project_id}"
35+
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
36+
regional = true
37+
region = "${var.region}"
38+
network = "${var.network}"
39+
subnetwork = "${var.subnetwork}"
40+
ip_range_pods = "${var.ip_range_pods}"
41+
ip_range_services = "${var.ip_range_services}"
42+
service_account = "${var.compute_engine_service_account}"
43+
enable_private_endpoint = true
44+
enable_private_nodes = true
45+
master_ipv4_cidr_block = "172.16.0.0/28"
4646

4747
master_authorized_networks_config = [{
4848
cidr_blocks = [{
@@ -52,4 +52,4 @@ module "gke" {
5252
}]
5353
}
5454

55-
data "google_client_config" "default" { }
55+
data "google_client_config" "default" {}

examples/simple_zonal/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ To provision this example, run the following from within this directory:
4545
- `terraform init` to get the plugins
4646
- `terraform plan` to see the infrastructure plan
4747
- `terraform apply` to apply the infrastructure build
48-
- `terraform destroy` to destroy the built infrastructure
48+
- `terraform destroy` to destroy the built infrastructure

examples/simple_zonal/main.tf

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ provider "google" {
2424
}
2525

2626
module "gke" {
27-
source = "../../"
28-
project_id = "${var.project_id}"
29-
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
30-
regional = false
31-
region = "${var.region}"
32-
zones = "${var.zones}"
33-
network = "${var.network}"
34-
subnetwork = "${var.subnetwork}"
35-
ip_range_pods = "${var.ip_range_pods}"
36-
ip_range_services = "${var.ip_range_services}"
37-
service_account = "${var.compute_engine_service_account}"
27+
source = "../../"
28+
project_id = "${var.project_id}"
29+
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
30+
regional = false
31+
region = "${var.region}"
32+
zones = "${var.zones}"
33+
network = "${var.network}"
34+
subnetwork = "${var.subnetwork}"
35+
ip_range_pods = "${var.ip_range_pods}"
36+
ip_range_services = "${var.ip_range_services}"
37+
service_account = "${var.compute_engine_service_account}"
3838
}
3939

4040
data "google_client_config" "default" {}

examples/simple_zonal_private/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ To provision this example, run the following from within this directory:
4545
- `terraform init` to get the plugins
4646
- `terraform plan` to see the infrastructure plan
4747
- `terraform apply` to apply the infrastructure build
48-
- `terraform destroy` to destroy the built infrastructure
48+
- `terraform destroy` to destroy the built infrastructure

examples/simple_zonal_private/main.tf

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,26 @@ provider "google-beta" {
2424
}
2525

2626
data "google_compute_subnetwork" "subnetwork" {
27-
name = "${var.subnetwork}"
28-
project = "${var.project_id}"
29-
region = "${var.region}"
27+
name = "${var.subnetwork}"
28+
project = "${var.project_id}"
29+
region = "${var.region}"
3030
}
3131

3232
module "gke" {
33-
source = "../../modules/private-cluster/"
34-
project_id = "${var.project_id}"
35-
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
36-
regional = false
37-
region = "${var.region}"
38-
zones = "${var.zones}"
39-
network = "${var.network}"
40-
subnetwork = "${var.subnetwork}"
41-
ip_range_pods = "${var.ip_range_pods}"
42-
ip_range_services = "${var.ip_range_services}"
43-
service_account = "${var.compute_engine_service_account}"
44-
enable_private_endpoint = true
45-
enable_private_nodes = true
46-
master_ipv4_cidr_block = "172.16.0.0/28"
33+
source = "../../modules/private-cluster/"
34+
project_id = "${var.project_id}"
35+
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
36+
regional = false
37+
region = "${var.region}"
38+
zones = "${var.zones}"
39+
network = "${var.network}"
40+
subnetwork = "${var.subnetwork}"
41+
ip_range_pods = "${var.ip_range_pods}"
42+
ip_range_services = "${var.ip_range_services}"
43+
service_account = "${var.compute_engine_service_account}"
44+
enable_private_endpoint = true
45+
enable_private_nodes = true
46+
master_ipv4_cidr_block = "172.16.0.0/28"
4747

4848
master_authorized_networks_config = [{
4949
cidr_blocks = [{
@@ -53,4 +53,4 @@ module "gke" {
5353
}]
5454
}
5555

56-
data "google_client_config" "default" { }
56+
data "google_client_config" "default" {}

examples/stub_domains/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ To provision this example, run the following from within this directory:
4949
- `terraform init` to get the plugins
5050
- `terraform plan` to see the infrastructure plan
5151
- `terraform apply` to apply the infrastructure build
52-
- `terraform destroy` to destroy the built infrastructure
52+
- `terraform destroy` to destroy the built infrastructure

helpers/combine_docfiles.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import re
3030
import sys
3131

32-
insert_separator_regex = '(.*?\[\^\]\:\ \(autogen_docs_start\))(.*?)(\n\[\^\]\:\ \(autogen_docs_end\).*?$)' # noqa: E501
33-
exclude_separator_regex = '(.*?)Copyright 20\d\d Google LLC.*?limitations under the License.(.*?)$' # noqa: E501
32+
insert_separator_regex = r'(.*?\[\^\]\:\ \(autogen_docs_start\))(.*?)(\n\[\^\]\:\ \(autogen_docs_end\).*?$)' # noqa: E501
33+
exclude_separator_regex = r'(.*?)Copyright 20\d\d Google LLC.*?limitations under the License.(.*?)$' # noqa: E501
3434

3535
if len(sys.argv) != 3:
3636
sys.exit(1)
@@ -42,14 +42,17 @@
4242
replace_content = open(sys.argv[2], "r").read()
4343

4444
# Exclude the specified content from the replacement content
45-
groups = re.match(
45+
matched = re.match(
4646
exclude_separator_regex,
4747
replace_content,
4848
re.DOTALL
49-
).groups(0)
50-
replace_content = groups[0] + groups[1]
49+
)
5150

52-
# Find where to put the replacement content, overwrite the input file
53-
groups = re.match(insert_separator_regex, input, re.DOTALL).groups(0)
54-
output = groups[0] + replace_content + groups[2]
55-
open(sys.argv[1], "w").write(output)
51+
if matched:
52+
groups = matched.groups(0)
53+
replace_content = groups[0] + groups[1]
54+
55+
# Find where to put the replacement content, overwrite the input file
56+
groups = re.match(insert_separator_regex, input, re.DOTALL).groups(0)
57+
output = groups[0] + replace_content + groups[2] + "\n"
58+
open(sys.argv[1], "w").write(output)

helpers/generate_modules/generate_modules.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,18 @@ def main(argv):
6666
module.template_options(BASE_TEMPLATE_OPTIONS)
6767
)
6868
with open(os.path.join(module.path, template_file), "w") as f:
69-
f.write(rendered)
70-
subprocess.call(
71-
[
72-
"terraform",
73-
"fmt",
74-
os.path.join(module.path, template_file)
75-
],
76-
stdout=DEVNULL_FILE,
77-
stderr=subprocess.STDOUT
78-
)
69+
f.write(rendered.rstrip())
70+
if template_file.endswith(".tf"):
71+
subprocess.call(
72+
[
73+
"terraform",
74+
"fmt",
75+
"-write=true",
76+
os.path.join(module.path, template_file)
77+
],
78+
stdout=DEVNULL_FILE,
79+
stderr=subprocess.STDOUT
80+
)
7981
if template_file.endswith(".sh"):
8082
os.chmod(os.path.join(module.path, template_file), 0o755)
8183
DEVNULL_FILE.close()

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,4 @@ data "google_container_engine_versions" "region" {
152152
provider = "google"
153153
zone = "${data.google_compute_zones.available.names[0]}"
154154
project = "${var.project_id}"
155-
}
155+
}

masq.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ EOF
4141
}
4242

4343
depends_on = ["data.google_client_config.default", "google_container_cluster.primary", "google_container_node_pool.pools", "google_container_cluster.zonal_primary", "google_container_node_pool.zonal_pools"]
44-
}
44+
}

modules/private-cluster/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ Alternatively, you can simply run `make test_integration_docker` to run all the
269269
#### Test configuration
270270

271271
Each test-kitchen instance is configured with a `variables.tfvars` file in the test fixture directory, e.g. `test/fixtures/node_pool/terraform.tfvars`.
272-
For convenience, since all of the variables are project-specific, these files have been symlinked to `test/fixtures/shared/terraform.tfvars`.
272+
For convenience, since all of the variables are project-specific, these files have been symlinked to `test/fixtures/shared/terraform.tfvars`.
273273
Similarly, each test fixture has a `variables.tf` to define these variables, and an `outputs.tf` to facilitate providing necessary information for `inspec` to locate and query against created resources.
274274

275275
Each test-kitchen instance creates a GCP Network and Subnetwork fixture to house resources, and may create any other necessary fixture data as needed.
@@ -319,4 +319,4 @@ are as follows:
319319
is a compiled language so there is no standard linter.
320320
* Terraform - terraform has a built-in linter in the 'terraform validate'
321321
command.
322-
* Dockerfiles - hadolint. Can be found in homebrew
322+
* Dockerfiles - hadolint. Can be found in homebrew

modules/private-cluster/auth.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ provider "kubernetes" {
3131
host = "https://${local.cluster_endpoint}"
3232
token = "${data.google_client_config.default.access_token}"
3333
cluster_ca_certificate = "${base64decode(local.cluster_ca_certificate)}"
34-
}
34+
}

0 commit comments

Comments
 (0)