Skip to content

Commit

Permalink
Add note to generated files pointing to ./autogen
Browse files Browse the repository at this point in the history
  • Loading branch information
Jberlinsky committed Jan 10, 2019
1 parent 1ab6df0 commit 0f780cc
Show file tree
Hide file tree
Showing 20 changed files with 62 additions and 14 deletions.
4 changes: 3 additions & 1 deletion auth.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

// This file was automatically generated from a template in ./autogen

/******************************************
Retrieve authentication token
*****************************************/
Expand All @@ -27,4 +29,4 @@ provider "kubernetes" {
host = "https://${local.cluster_endpoint}"
token = "${data.google_client_config.default.access_token}"
cluster_ca_certificate = "${base64decode(local.cluster_ca_certificate)}"
}
}
2 changes: 2 additions & 0 deletions autogen/auth.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

{{ autogeneration_note }}

/******************************************
Retrieve authentication token
*****************************************/
Expand Down
2 changes: 2 additions & 0 deletions autogen/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

{{ autogeneration_note }}

/******************************************
Create regional cluster
*****************************************/
Expand Down
2 changes: 2 additions & 0 deletions autogen/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

{{ autogeneration_note }}

/******************************************
Create zonal cluster
*****************************************/
Expand Down
2 changes: 2 additions & 0 deletions autogen/dns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

{{ autogeneration_note }}

/******************************************
Delete default kube-dns configmap
*****************************************/
Expand Down
2 changes: 2 additions & 0 deletions autogen/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

{{ autogeneration_note }}

/******************************************
Get available zones in region
*****************************************/
Expand Down
2 changes: 2 additions & 0 deletions autogen/masq.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

{{ autogeneration_note }}

/******************************************
Create ip-masq-agent confimap
*****************************************/
Expand Down
2 changes: 2 additions & 0 deletions autogen/networks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

{{ autogeneration_note }}

data "google_compute_network" "gke_network" {
name = "${var.network}"
project = "${local.network_project_id}"
Expand Down
2 changes: 2 additions & 0 deletions autogen/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

{{ autogeneration_note }}

output "name" {
description = "Cluster name"
value = "${local.cluster_name}"
Expand Down
2 changes: 2 additions & 0 deletions autogen/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

{{ autogeneration_note }}

variable "project_id" {
description = "The project ID to host the cluster in (required)"
}
Expand Down
4 changes: 3 additions & 1 deletion cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

// This file was automatically generated from a template in ./autogen

/******************************************
Create regional cluster
*****************************************/
Expand Down Expand Up @@ -151,4 +153,4 @@ resource "null_resource" "wait_for_regional_cluster" {
}

depends_on = ["google_container_cluster.primary", "google_container_node_pool.pools"]
}
}
4 changes: 3 additions & 1 deletion cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

// This file was automatically generated from a template in ./autogen

/******************************************
Create zonal cluster
*****************************************/
Expand Down Expand Up @@ -151,4 +153,4 @@ resource "null_resource" "wait_for_zonal_cluster" {
}

depends_on = ["google_container_cluster.zonal_primary", "google_container_node_pool.zonal_pools"]
}
}
4 changes: 3 additions & 1 deletion dns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

// This file was automatically generated from a template in ./autogen

/******************************************
Delete default kube-dns configmap
*****************************************/
Expand Down Expand Up @@ -49,4 +51,4 @@ EOF
}

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"]
}
}
17 changes: 14 additions & 3 deletions helpers/generate_modules/generate_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,31 @@

from jinja2 import Environment, FileSystemLoader

TEMPLATE_FOLDER = "./autogen"


def main(argv):
env = Environment(
loader=FileSystemLoader('./autogen'),
loader=FileSystemLoader(TEMPLATE_FOLDER),
)
template_options = {}
template_options = {
'autogeneration_note': '// This file was automatically generated ' +
'from a template in {folder}'.format(
folder=TEMPLATE_FOLDER
),
}
templates = env.list_templates()
for template_file in templates:
template = env.get_template(template_file)
rendered = template.render(template_options)
with open(os.path.join("./", template_file), "w") as f:
f.write(rendered)
subprocess.call([
"terraform",
"fmt",
os.path.join("./", template_file)
])

subprocess.call(["terraform", "fmt"])

if __name__ == "__main__":
main(sys.argv)
4 changes: 3 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

// This file was automatically generated from a template in ./autogen

/******************************************
Get available zones in region
*****************************************/
Expand Down Expand Up @@ -148,4 +150,4 @@ locals {
data "google_container_engine_versions" "region" {
zone = "${data.google_compute_zones.available.names[0]}"
project = "${var.project_id}"
}
}
4 changes: 3 additions & 1 deletion masq.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

// This file was automatically generated from a template in ./autogen

/******************************************
Create ip-masq-agent confimap
*****************************************/
Expand All @@ -39,4 +41,4 @@ EOF
}

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"]
}
}
4 changes: 3 additions & 1 deletion networks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

// This file was automatically generated from a template in ./autogen

data "google_compute_network" "gke_network" {
name = "${var.network}"
project = "${local.network_project_id}"
Expand All @@ -23,4 +25,4 @@ data "google_compute_subnetwork" "gke_subnetwork" {
name = "${var.subnetwork}"
region = "${var.region}"
project = "${local.network_project_id}"
}
}
4 changes: 3 additions & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

// This file was automatically generated from a template in ./autogen

output "name" {
description = "Cluster name"
value = "${local.cluster_name}"
Expand Down Expand Up @@ -104,4 +106,4 @@ output "node_pools_names" {
output "node_pools_versions" {
description = "List of node pools versions"
value = "${local.cluster_node_pools_versions}"
}
}
5 changes: 3 additions & 2 deletions test/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ function docker() {
function check_terraform() {
echo "Running terraform validate"
#shellcheck disable=SC2156
find . -name "*.tf" -not -path "./test/fixtures/shared/*" -not -path "./test/fixtures/all_examples/*" -exec bash -c 'terraform validate --check-variables=false $(dirname "{}")' \;
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 "{}")' \;
echo "Running terraform fmt"
terraform fmt -check=true -write=false
#shellcheck disable=SC2156
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 "{}"' \;
}

# This function runs 'go fmt' and 'go vet' on every file
Expand Down
4 changes: 3 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

// This file was automatically generated from a template in ./autogen

variable "project_id" {
description = "The project ID to host the cluster in (required)"
}
Expand Down Expand Up @@ -208,4 +210,4 @@ variable "monitoring_service" {
variable "service_account" {
description = "The service account to default running nodes as if not overridden in `node_pools`. Defaults to the compute engine default service account"
default = ""
}
}

0 comments on commit 0f780cc

Please sign in to comment.