From 68deae1047cab63ba80e3bb1702cd5dea81842b0 Mon Sep 17 00:00:00 2001 From: Dana Hoffman Date: Wed, 18 Sep 2019 15:54:51 -0700 Subject: [PATCH] image_version and python_version are ga in composer (#2323) Merged PR #2323. --- build/terraform | 2 +- build/terraform-beta | 2 +- .../resources/resource_composer_environment.go.erb | 12 ------------ .../tests/resource_composer_environment_test.go.erb | 12 ++---------- .../docs/r/composer_environment.html.markdown | 7 +++---- 5 files changed, 7 insertions(+), 28 deletions(-) diff --git a/build/terraform b/build/terraform index 00aedc481c9f..bc7726aae5c6 160000 --- a/build/terraform +++ b/build/terraform @@ -1 +1 @@ -Subproject commit 00aedc481c9f288f5699723084e0b9c9374916b1 +Subproject commit bc7726aae5c699ed0f432ccd65440b38a26b927e diff --git a/build/terraform-beta b/build/terraform-beta index b3c1a4d4257f..aaaf7650a691 160000 --- a/build/terraform-beta +++ b/build/terraform-beta @@ -1 +1 @@ -Subproject commit b3c1a4d4257f751c9d22a43361a5b591acd8defa +Subproject commit aaaf7650a691171203040501aee2f09073fbc3bc diff --git a/third_party/terraform/resources/resource_composer_environment.go.erb b/third_party/terraform/resources/resource_composer_environment.go.erb index e3c53929be71..30e4e765a84c 100644 --- a/third_party/terraform/resources/resource_composer_environment.go.erb +++ b/third_party/terraform/resources/resource_composer_environment.go.erb @@ -17,9 +17,7 @@ import ( const ( composerEnvironmentEnvVariablesRegexp = "[a-zA-Z_][a-zA-Z0-9_]*." composerEnvironmentReservedAirflowEnvVarRegexp = "AIRFLOW__[A-Z0-9_]+__[A-Z0-9_]+" -<% unless version == 'ga' -%> composerEnvironmentVersionRegexp = `composer-([0-9]+\.[0-9]+\.[0-9]+|latest)-airflow-([0-9]+\.[0-9]+(\.[0-9]+.*)?)` -<% end -%> ) var composerEnvironmentReservedEnvVar = map[string]struct{}{ @@ -227,7 +225,6 @@ func resourceComposerEnvironment() *schema.Resource { "image_version": { Type: schema.TypeString, Computed: true, -<% unless version == 'ga' -%> Optional: true, ValidateFunc: validateRegexp(composerEnvironmentVersionRegexp), DiffSuppressFunc: composerImageVersionDiffSuppress, @@ -237,7 +234,6 @@ func resourceComposerEnvironment() *schema.Resource { Optional: true, Computed: true, ForceNew: true, -<% end -%> }, }, }, @@ -399,7 +395,6 @@ func resourceComposerEnvironmentUpdate(d *schema.ResourceData, meta interface{}) return err } -<% unless version == 'ga' -%> if d.HasChange("config.0.software_config.0.image_version") { patchObj := &composer.Environment{ Config: &composer.EnvironmentConfig{ @@ -415,7 +410,6 @@ func resourceComposerEnvironmentUpdate(d *schema.ResourceData, meta interface{}) } d.SetPartial("config") } -<% end -%> if d.HasChange("config.0.software_config.0.airflow_config_overrides") { patchObj := &composer.Environment{ @@ -669,9 +663,7 @@ func flattenComposerEnvironmentConfigSoftwareConfig(softwareCfg *composer.Softwa } transformed := make(map[string]interface{}) transformed["image_version"] = softwareCfg.ImageVersion -<% unless version == 'ga' -%> transformed["python_version"] = softwareCfg.PythonVersion -<% end -%> transformed["airflow_config_overrides"] = softwareCfg.AirflowConfigOverrides transformed["pypi_packages"] = softwareCfg.PypiPackages transformed["env_variables"] = softwareCfg.EnvVariables @@ -945,9 +937,7 @@ func expandComposerEnvironmentConfigSoftwareConfig(v interface{}, d *schema.Reso transformed := &composer.SoftwareConfig{} transformed.ImageVersion = original["image_version"].(string) -<% unless version == 'ga' -%> transformed.PythonVersion = original["python_version"].(string) -<% end -%> transformed.AirflowConfigOverrides = expandComposerEnvironmentConfigSoftwareConfigStringMap(original, "airflow_config_overrides") transformed.PypiPackages = expandComposerEnvironmentConfigSoftwareConfigStringMap(original, "pypi_packages") transformed.EnvVariables = expandComposerEnvironmentConfigSoftwareConfigStringMap(original, "env_variables") @@ -1113,7 +1103,6 @@ func validateServiceAccountRelativeNameOrEmail(v interface{}, k string) (ws []st return } -<% unless version == 'ga' -%> func composerImageVersionDiffSuppress(_, old, new string, _ *schema.ResourceData) bool { versionRe := regexp.MustCompile(composerEnvironmentVersionRegexp) oldVersions := versionRe.FindStringSubmatch(old) @@ -1169,4 +1158,3 @@ func versionsEqual(old, new string) (bool, error) { } return o.Equal(n), nil } -<% end -%> diff --git a/third_party/terraform/tests/resource_composer_environment_test.go.erb b/third_party/terraform/tests/resource_composer_environment_test.go.erb index b8f9d5989c5f..522f771d8268 100644 --- a/third_party/terraform/tests/resource_composer_environment_test.go.erb +++ b/third_party/terraform/tests/resource_composer_environment_test.go.erb @@ -27,7 +27,6 @@ func init() { }) } -<% unless version == 'ga' -%> func TestComposerImageVersionDiffSuppress(t *testing.T) { t.Parallel() @@ -51,7 +50,6 @@ func TestComposerImageVersionDiffSuppress(t *testing.T) { } } } -<% end -%> // Checks environment creation with minimum required information. func TestAccComposerEnvironment_basic(t *testing.T) { @@ -191,7 +189,6 @@ func TestAccComposerEnvironment_withNodeConfig(t *testing.T) { }) } -<% unless version == 'ga' -%> func TestAccComposerEnvironment_withSoftwareConfig(t *testing.T) { t.Parallel() envName := acctest.RandomWithPrefix(testComposerEnvironmentPrefix) @@ -213,7 +210,6 @@ func TestAccComposerEnvironment_withSoftwareConfig(t *testing.T) { }, }) } -<% end -%> // Checks behavior of config for creation for attributes that must // be updated during create. @@ -352,9 +348,7 @@ resource "google_composer_environment" "test" { node_count = 4 software_config { -<% unless version == 'ga' -%> image_version = "${data.google_composer_image_versions.all.image_versions.0.image_version_id}" -<% end -%> airflow_config_overrides = { core-load_example = "True" @@ -420,15 +414,14 @@ resource "google_project_iam_member" "composer-worker" { `, environment, network, subnetwork, serviceAccount) } -<% unless version == 'ga' -%> func testAccComposerEnvironment_softwareCfg(name string) string { return fmt.Sprintf(` data "google_composer_image_versions" "all" { } resource "google_composer_environment" "test" { - name = "%s" - region = "us-central1" + name = "%s" + region = "us-central1" config { software_config { image_version = "${data.google_composer_image_versions.all.image_versions.0.image_version_id}" @@ -438,7 +431,6 @@ resource "google_composer_environment" "test" { } `, name) } -<% end -%> func testAccComposerEnvironment_updateOnlyFields(name string) string { return fmt.Sprintf(` diff --git a/third_party/terraform/website/docs/r/composer_environment.html.markdown b/third_party/terraform/website/docs/r/composer_environment.html.markdown index 55446e5d7e83..cd1f46624e5c 100644 --- a/third_party/terraform/website/docs/r/composer_environment.html.markdown +++ b/third_party/terraform/website/docs/r/composer_environment.html.markdown @@ -275,17 +275,16 @@ The `software_config` block supports: SQL_USER ``` -* `image_version` (Optional, [Beta](https://terraform.io/docs/providers/google/provider_versions.html)) - +* `image_version` (Optional) - The version of the software running in the environment. This encapsulates both the version of Cloud Composer functionality and the version of Apache Airflow. It must match the regular expression `composer-[0-9]+\.[0-9]+(\.[0-9]+)?-airflow-[0-9]+\.[0-9]+(\.[0-9]+.*)?`. The Cloud Composer portion of the version is a semantic version. The portion of the image version following 'airflow-' is an official Apache Airflow repository release name. See [documentation](https://cloud.google.com/composer/docs/reference/rest/v1beta1/projects.locations.environments#softwareconfig) - for allowed release names. This field can only be set in the [Beta](https://terraform.io/docs/providers/google/provider_versions.html)) - provider, but is an output-only attribute in the GA provider. + for allowed release names. -* `python_version` (Optional, [Beta](https://terraform.io/docs/providers/google/provider_versions.html)) - +* `python_version` (Optional) - The major version of Python used to run the Apache Airflow scheduler, worker, and webserver processes. Can be set to '2' or '3'. If not specified, the default is '2'. Cannot be updated.