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 #5187

Merged
merged 1 commit into from
Sep 12, 2021
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
5 changes: 4 additions & 1 deletion mmv1/products/appengine/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ overrides: !ruby/object:Overrides::ResourceOverrides
id: !ruby/object:Overrides::Terraform::PropertyOverride
name: 'version_id'
deployment: !ruby/object:Overrides::Terraform::PropertyOverride
ignore_read: true
custom_flatten: templates/terraform/custom_flatten/app_version.go.erb
deployment.container: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
entrypoint: !ruby/object:Overrides::Terraform::PropertyOverride
ignore_read: true
envVariables: !ruby/object:Overrides::Terraform::PropertyOverride
Expand Down Expand Up @@ -145,6 +147,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides
primary_resource_id: "myapp_v1"
ignore_read_extra:
- "noop_on_destroy"
- "deployment.0.zip"
vars:
bucket_name: "appengine-static-content"
project: "appeng-flex"
Expand Down
68 changes: 68 additions & 0 deletions mmv1/templates/terraform/custom_flatten/app_version.go.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<%# The license inside this block applies to this file.
# Copyright 2022 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-%>
func flatten<%= prefix -%><%= titlelize_property(property) -%>(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
}
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