From 53b76171bf672164e3683f70f556e4f105822e7f Mon Sep 17 00:00:00 2001 From: Andrew Peabody Date: Wed, 21 Jun 2023 17:46:12 +0000 Subject: [PATCH] fix: updates for tflint and dev-tools v1.13 --- Makefile | 2 +- README.md | 2 +- build/int.cloudbuild.yaml | 2 +- build/lint.cloudbuild.yaml | 2 +- examples/kubectl_wrapper_example/main.tf | 17 ++++++++--------- modules/kubectl-wrapper/README.md | 2 +- modules/kubectl-wrapper/variables.tf | 6 +++++- variables.tf | 12 +++++++++++- versions.tf | 8 ++++++++ 9 files changed, 37 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 1078ab2d..c853816f 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ # Make will use bash instead of sh SHELL := /usr/bin/env bash -O extglob -DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.0 +DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.13 DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools REGISTRY_URL := gcr.io/cloud-foundation-cicd diff --git a/README.md b/README.md index 0e055bcc..bade4a7f 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Setting it to `never` will *never* gcloud download and setting it to `always` wi | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| additional\_components | Additional gcloud CLI components to install. Defaults to none. Valid value are components listed in `gcloud components list` | `list` | `[]` | no | +| additional\_components | Additional gcloud CLI components to install. Defaults to none. Valid value are components listed in `gcloud components list` | `list(string)` | `[]` | no | | create\_cmd\_body | On create, the command body you'd like to run with your entrypoint. | `string` | `"info"` | no | | create\_cmd\_entrypoint | On create, the command entrypoint you'd like to use. Can also be set to a custom script. Module's bin directory will be prepended to path. | `string` | `"gcloud"` | no | | create\_cmd\_triggers | List of any additional triggers to re-run the create command execution when either of values in the maps change. Some keys are reserved and will be overwritten if specified in this option. (eg. `md5`, `arguments`, `download_gcloud_command`, `download_jq_command`, etc. See details in [the source](https://github.com/terraform-google-modules/terraform-google-gcloud/blob/master/main.tf).) | `map(any)` | `{}` | no | diff --git a/build/int.cloudbuild.yaml b/build/int.cloudbuild.yaml index 4294a66c..d69136bc 100644 --- a/build/int.cloudbuild.yaml +++ b/build/int.cloudbuild.yaml @@ -58,4 +58,4 @@ tags: - 'integration' substitutions: _DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools' - _DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.0' + _DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.13' diff --git a/build/lint.cloudbuild.yaml b/build/lint.cloudbuild.yaml index e92ad0f4..f6d1ad00 100644 --- a/build/lint.cloudbuild.yaml +++ b/build/lint.cloudbuild.yaml @@ -23,4 +23,4 @@ tags: - 'lint' substitutions: _DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools' - _DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.0' + _DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.13' diff --git a/examples/kubectl_wrapper_example/main.tf b/examples/kubectl_wrapper_example/main.tf index 0fc06246..52788f05 100644 --- a/examples/kubectl_wrapper_example/main.tf +++ b/examples/kubectl_wrapper_example/main.tf @@ -35,7 +35,7 @@ module "enabled_google_apis" { module "gcp-network" { source = "terraform-google-modules/network/google" - version = "~> 6.0" + version = "~> 7.0" project_id = module.enabled_google_apis.project_id network_name = var.network @@ -48,7 +48,7 @@ module "gcp-network" { ] secondary_ranges = { - "${var.subnetwork}" = [ + (var.subnetwork) = [ { range_name = var.ip_range_pods_name ip_cidr_range = "192.168.0.0/18" @@ -63,7 +63,7 @@ module "gcp-network" { module "gke" { source = "terraform-google-modules/kubernetes-engine/google" - version = "~> 24.0" + version = "~> 26.0" project_id = module.enabled_google_apis.project_id name = var.cluster_name regional = true @@ -81,12 +81,11 @@ data "google_client_config" "default" { module "kubectl-imperative" { source = "../../modules/kubectl-wrapper" - project_id = var.project_id - cluster_name = module.gke.name - cluster_location = module.gke.location - module_depends_on = [module.gke.endpoint] - # using --generator for cross compat between 1.18 and lower - kubectl_create_command = "kubectl run --generator=run-pod/v1 nginx-imperative --image=nginx" + project_id = var.project_id + cluster_name = module.gke.name + cluster_location = module.gke.location + module_depends_on = [module.gke.endpoint] + kubectl_create_command = "kubectl run nginx-imperative --image=nginx" kubectl_destroy_command = "kubectl delete pod nginx-imperative" skip_download = true } diff --git a/modules/kubectl-wrapper/README.md b/modules/kubectl-wrapper/README.md index 00b2c19a..0a9cb2ff 100644 --- a/modules/kubectl-wrapper/README.md +++ b/modules/kubectl-wrapper/README.md @@ -25,7 +25,7 @@ module "kubectl" { | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| additional\_components | Additional gcloud CLI components to install. Defaults to installing kubectl. Valid value are components listed in `gcloud components list` | `list` |
[
"kubectl"
]
| no | +| additional\_components | Additional gcloud CLI components to install. Defaults to installing kubectl. Valid value are components listed in `gcloud components list` | `list(string)` |
[
"kubectl"
]
| no | | cluster\_location | Cluster location (Zone/Region). Optional if use\_existing\_context is true. | `string` | `""` | no | | cluster\_name | Cluster name. Optional if use\_existing\_context is true. | `string` | `""` | no | | create\_cmd\_triggers | List of any additional triggers for the create command execution. | `map(any)` | `{}` | no | diff --git a/modules/kubectl-wrapper/variables.tf b/modules/kubectl-wrapper/variables.tf index 1a626e7b..5111ac82 100644 --- a/modules/kubectl-wrapper/variables.tf +++ b/modules/kubectl-wrapper/variables.tf @@ -1,5 +1,5 @@ /** - * Copyright 2020 Google LLC + * Copyright 2020-2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,6 +62,7 @@ variable "create_cmd_triggers" { variable "additional_components" { description = "Additional gcloud CLI components to install. Defaults to installing kubectl. Valid value are components listed in `gcloud components list`" + type = list(string) default = ["kubectl"] } @@ -73,6 +74,7 @@ variable "skip_download" { variable "gcloud_sdk_version" { description = "The gcloud sdk version to download." + type = string default = "281.0.0" } @@ -96,11 +98,13 @@ variable "internal_ip" { variable "service_account_key_file" { description = "Path to service account key file to auth as for running `gcloud container clusters get-credentials`." + type = string default = "" } variable "use_tf_google_credentials_env_var" { description = "Use `GOOGLE_CREDENTIALS` environment variable to run `gcloud auth activate-service-account` with. Optional." + type = bool default = false } diff --git a/variables.tf b/variables.tf index fbaf0aa1..5b477a0f 100644 --- a/variables.tf +++ b/variables.tf @@ -1,5 +1,5 @@ /** - * Copyright 2018 Google LLC + * Copyright 2018-2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,11 +40,13 @@ variable "module_depends_on" { variable "create_cmd_entrypoint" { description = "On create, the command entrypoint you'd like to use. Can also be set to a custom script. Module's bin directory will be prepended to path." + type = string default = "gcloud" } variable "create_cmd_body" { description = "On create, the command body you'd like to run with your entrypoint." + type = string default = "info" } @@ -56,41 +58,49 @@ variable "create_cmd_triggers" { variable "destroy_cmd_entrypoint" { description = "On destroy, the command entrypoint you'd like to use. Can also be set to a custom script. Module's bin directory will be prepended to path." + type = string default = "gcloud" } variable "destroy_cmd_body" { description = "On destroy, the command body you'd like to run with your entrypoint." + type = string default = "info" } variable "additional_components" { description = "Additional gcloud CLI components to install. Defaults to none. Valid value are components listed in `gcloud components list`" + type = list(string) default = [] } variable "platform" { description = "Platform CLI will run on. Defaults to linux. Valid values: linux, darwin" + type = string default = "linux" } variable "service_account_key_file" { description = "Path to service account key file to run `gcloud auth activate-service-account` with. Optional." + type = string default = "" } variable "use_tf_google_credentials_env_var" { description = "Use `GOOGLE_CREDENTIALS` environment variable to run `gcloud auth activate-service-account` with. Optional." + type = bool default = false } variable "jq_version" { description = "The jq version to download." + type = string default = "1.6" } variable "gcloud_sdk_version" { description = "The gcloud sdk version to download." + type = string default = "281.0.0" } diff --git a/versions.tf b/versions.tf index fad988f2..c528955a 100644 --- a/versions.tf +++ b/versions.tf @@ -26,6 +26,14 @@ terraform { source = "hashicorp/external" version = ">= 2.2.2" } + random = { + source = "hashicorp/random" + version = ">= 2.1.0" + } + null = { + source = "hashicorp/null" + version = ">= 2.1.0" + } } provider_meta "google" {