Skip to content

Commit 0f780cc

Browse files
committed
Add note to generated files pointing to ./autogen
1 parent 1ab6df0 commit 0f780cc

20 files changed

+62
-14
lines changed

auth.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
// This file was automatically generated from a template in ./autogen
18+
1719
/******************************************
1820
Retrieve authentication token
1921
*****************************************/
@@ -27,4 +29,4 @@ provider "kubernetes" {
2729
host = "https://${local.cluster_endpoint}"
2830
token = "${data.google_client_config.default.access_token}"
2931
cluster_ca_certificate = "${base64decode(local.cluster_ca_certificate)}"
30-
}
32+
}

autogen/auth.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
{{ autogeneration_note }}
18+
1719
/******************************************
1820
Retrieve authentication token
1921
*****************************************/

autogen/cluster_regional.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
{{ autogeneration_note }}
18+
1719
/******************************************
1820
Create regional cluster
1921
*****************************************/

autogen/cluster_zonal.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
{{ autogeneration_note }}
18+
1719
/******************************************
1820
Create zonal cluster
1921
*****************************************/

autogen/dns.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
{{ autogeneration_note }}
18+
1719
/******************************************
1820
Delete default kube-dns configmap
1921
*****************************************/

autogen/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
{{ autogeneration_note }}
18+
1719
/******************************************
1820
Get available zones in region
1921
*****************************************/

autogen/masq.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
{{ autogeneration_note }}
18+
1719
/******************************************
1820
Create ip-masq-agent confimap
1921
*****************************************/

autogen/networks.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
{{ autogeneration_note }}
18+
1719
data "google_compute_network" "gke_network" {
1820
name = "${var.network}"
1921
project = "${local.network_project_id}"

autogen/outputs.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
{{ autogeneration_note }}
18+
1719
output "name" {
1820
description = "Cluster name"
1921
value = "${local.cluster_name}"

autogen/variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
{{ autogeneration_note }}
18+
1719
variable "project_id" {
1820
description = "The project ID to host the cluster in (required)"
1921
}

cluster_regional.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
// This file was automatically generated from a template in ./autogen
18+
1719
/******************************************
1820
Create regional cluster
1921
*****************************************/
@@ -151,4 +153,4 @@ resource "null_resource" "wait_for_regional_cluster" {
151153
}
152154

153155
depends_on = ["google_container_cluster.primary", "google_container_node_pool.pools"]
154-
}
156+
}

cluster_zonal.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
// This file was automatically generated from a template in ./autogen
18+
1719
/******************************************
1820
Create zonal cluster
1921
*****************************************/
@@ -151,4 +153,4 @@ resource "null_resource" "wait_for_zonal_cluster" {
151153
}
152154

153155
depends_on = ["google_container_cluster.zonal_primary", "google_container_node_pool.zonal_pools"]
154-
}
156+
}

dns.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
// This file was automatically generated from a template in ./autogen
18+
1719
/******************************************
1820
Delete default kube-dns configmap
1921
*****************************************/
@@ -49,4 +51,4 @@ EOF
4951
}
5052

5153
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"]
52-
}
54+
}

helpers/generate_modules/generate_modules.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,31 @@
2020

2121
from jinja2 import Environment, FileSystemLoader
2222

23+
TEMPLATE_FOLDER = "./autogen"
24+
2325

2426
def main(argv):
2527
env = Environment(
26-
loader=FileSystemLoader('./autogen'),
28+
loader=FileSystemLoader(TEMPLATE_FOLDER),
2729
)
28-
template_options = {}
30+
template_options = {
31+
'autogeneration_note': '// This file was automatically generated ' +
32+
'from a template in {folder}'.format(
33+
folder=TEMPLATE_FOLDER
34+
),
35+
}
2936
templates = env.list_templates()
3037
for template_file in templates:
3138
template = env.get_template(template_file)
3239
rendered = template.render(template_options)
3340
with open(os.path.join("./", template_file), "w") as f:
3441
f.write(rendered)
42+
subprocess.call([
43+
"terraform",
44+
"fmt",
45+
os.path.join("./", template_file)
46+
])
3547

36-
subprocess.call(["terraform", "fmt"])
3748

3849
if __name__ == "__main__":
3950
main(sys.argv)

main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
// This file was automatically generated from a template in ./autogen
18+
1719
/******************************************
1820
Get available zones in region
1921
*****************************************/
@@ -148,4 +150,4 @@ locals {
148150
data "google_container_engine_versions" "region" {
149151
zone = "${data.google_compute_zones.available.names[0]}"
150152
project = "${var.project_id}"
151-
}
153+
}

masq.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
// This file was automatically generated from a template in ./autogen
18+
1719
/******************************************
1820
Create ip-masq-agent confimap
1921
*****************************************/
@@ -39,4 +41,4 @@ EOF
3941
}
4042

4143
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"]
42-
}
44+
}

networks.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
// This file was automatically generated from a template in ./autogen
18+
1719
data "google_compute_network" "gke_network" {
1820
name = "${var.network}"
1921
project = "${local.network_project_id}"
@@ -23,4 +25,4 @@ data "google_compute_subnetwork" "gke_subnetwork" {
2325
name = "${var.subnetwork}"
2426
region = "${var.region}"
2527
project = "${local.network_project_id}"
26-
}
28+
}

outputs.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
// This file was automatically generated from a template in ./autogen
18+
1719
output "name" {
1820
description = "Cluster name"
1921
value = "${local.cluster_name}"
@@ -104,4 +106,4 @@ output "node_pools_names" {
104106
output "node_pools_versions" {
105107
description = "List of node pools versions"
106108
value = "${local.cluster_node_pools_versions}"
107-
}
109+
}

test/make.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ function docker() {
4848
function check_terraform() {
4949
echo "Running terraform validate"
5050
#shellcheck disable=SC2156
51-
find . -name "*.tf" -not -path "./test/fixtures/shared/*" -not -path "./test/fixtures/all_examples/*" -exec bash -c 'terraform validate --check-variables=false $(dirname "{}")' \;
51+
find . -name "*.tf" -not -path "./autogen/*" -not -path "./test/fixtures/shared/*" -not -path "./test/fixtures/all_examples/*" -exec bash -c 'terraform validate --check-variables=false $(dirname "{}")' \;
5252
echo "Running terraform fmt"
53-
terraform fmt -check=true -write=false
53+
#shellcheck disable=SC2156
54+
find . -name "*.tf" -not -path "./autogen/*" -not -path "./test/fixtures/shared/*" -not -path "./test/fixtures/all_examples/*" -exec bash -c 'terraform fmt -check=true -write=false "{}"' \;
5455
}
5556

5657
# This function runs 'go fmt' and 'go vet' on every file

variables.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
// This file was automatically generated from a template in ./autogen
18+
1719
variable "project_id" {
1820
description = "The project ID to host the cluster in (required)"
1921
}
@@ -208,4 +210,4 @@ variable "monitoring_service" {
208210
variable "service_account" {
209211
description = "The service account to default running nodes as if not overridden in `node_pools`. Defaults to the compute engine default service account"
210212
default = ""
211-
}
213+
}

0 commit comments

Comments
 (0)