Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change ignore_read on deployment to custom_flatten #10058

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/5187.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
appengine: fixed bug where `deployment.container.image` would update to an old version even if in `ignore_changes`
```
59 changes: 59 additions & 0 deletions google/resource_app_engine_flexible_app_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ A duration in seconds with up to nine fractional digits, terminated by 's'. Exam
},
"container": {
Type: schema.TypeList,
Computed: true,
Optional: true,
Description: `The Docker image for the container that runs the version.`,
MaxItems: 1,
Expand Down Expand Up @@ -1163,6 +1164,9 @@ func resourceAppEngineFlexibleAppVersionRead(d *schema.ResourceData, meta interf
if err := d.Set("nobuild_files_regex", flattenAppEngineFlexibleAppVersionNobuildFilesRegex(res["nobuildFilesRegex"], d, config)); err != nil {
return fmt.Errorf("Error reading FlexibleAppVersion: %s", err)
}
if err := d.Set("deployment", flattenAppEngineFlexibleAppVersionDeployment(res["deployment"], d, config)); err != nil {
return fmt.Errorf("Error reading FlexibleAppVersion: %s", err)
}
if err := d.Set("endpoints_api_service", flattenAppEngineFlexibleAppVersionEndpointsApiService(res["endpointsApiService"], d, config)); err != nil {
return fmt.Errorf("Error reading FlexibleAppVersion: %s", err)
}
Expand Down Expand Up @@ -1930,6 +1934,61 @@ func flattenAppEngineFlexibleAppVersionNobuildFilesRegex(v interface{}, d *schem
return v
}

func flattenAppEngineFlexibleAppVersionDeployment(v interface{}, d *schema.ResourceData, config *Config) interface{} {
original := v.(map[string]interface{})
transformed := make(map[string]interface{})
transformed["zip"] = d.Get("deployment.0.zip")
transformed["files"] = d.Get("deployment.0.files")
transformed["container"] =
flattenAppEngineFlexibleAppVersionDeploymentContainer(original["container"], d, config)
transformed["cloud_build_options"] =
flattenAppEngineFlexibleAppVersionDeploymentCloudBuildOptions(original["cloudBuildOptions"], d, config)

return []interface{}{transformed}
}

func flattenAppEngineFlexibleAppVersionDeploymentContainer(v interface{}, d *schema.ResourceData, config *Config) interface{} {
if v == nil {
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["image"] =
flattenAppEngineFlexibleAppVersionDeploymentContainerImage(original["image"], d, config)
return []interface{}{transformed}
}

func flattenAppEngineFlexibleAppVersionDeploymentContainerImage(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}

func flattenAppEngineFlexibleAppVersionDeploymentCloudBuildOptions(v interface{}, d *schema.ResourceData, config *Config) interface{} {
if v == nil {
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["app_yaml_path"] =
flattenAppEngineFlexibleAppVersionDeploymentCloudBuildOptionsAppYamlPath(original["appYamlPath"], d, config)
transformed["cloud_build_timeout"] =
flattenAppEngineFlexibleAppVersionDeploymentCloudBuildOptionsCloudBuildTimeout(original["cloudBuildTimeout"], d, config)
return []interface{}{transformed}
}

func flattenAppEngineFlexibleAppVersionDeploymentCloudBuildOptionsAppYamlPath(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}

func flattenAppEngineFlexibleAppVersionDeploymentCloudBuildOptionsCloudBuildTimeout(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}

func flattenAppEngineFlexibleAppVersionEndpointsApiService(v interface{}, d *schema.ResourceData, config *Config) interface{} {
if v == nil {
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestAccAppEngineFlexibleAppVersion_appEngineFlexibleAppVersionExample(t *te
ResourceName: "google_app_engine_flexible_app_version.myapp_v1",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"beta_settings", "env_variables", "deployment", "entrypoint", "service", "noop_on_destroy"},
ImportStateVerifyIgnore: []string{"beta_settings", "env_variables", "entrypoint", "service", "noop_on_destroy", "deployment.0.zip"},
},
},
})
Expand Down
4 changes: 2 additions & 2 deletions google/resource_app_engine_flexible_app_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestAccAppEngineFlexibleAppVersion_update(t *testing.T) {
ResourceName: "google_app_engine_flexible_app_version.foo",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"env_variables", "deployment", "entrypoint", "service", "noop_on_destroy"},
ImportStateVerifyIgnore: []string{"env_variables", "deployment.0.files", "entrypoint", "service", "noop_on_destroy"},
},
{
Config: testAccAppEngineFlexibleAppVersion_pythonUpdate(context),
Expand All @@ -35,7 +35,7 @@ func TestAccAppEngineFlexibleAppVersion_update(t *testing.T) {
ResourceName: "google_app_engine_flexible_app_version.foo",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"env_variables", "deployment", "entrypoint", "service", "noop_on_destroy"},
ImportStateVerifyIgnore: []string{"env_variables", "deployment.0.files", "entrypoint", "service", "noop_on_destroy"},
},
},
})
Expand Down