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

add common compile/copy for terraform #541

Merged
merged 1 commit into from
Oct 12, 2018
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
13 changes: 2 additions & 11 deletions products/binaryauthorization/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,8 @@ overrides: !ruby/object:Provider::ResourceOverrides
files: !ruby/object:Provider::Config::Files
# All of these files will be copied verbatim.
copy:
'google/transport.go': 'templates/terraform/transport.go'
'google/transport_test.go': 'templates/terraform/transport_test.go'
'google/import.go': 'templates/terraform/import.go'
'google/import_test.go': 'templates/terraform/import_test.go'
# Handwritten acceptance tests for autogenerated resources.
# Adding them here allows updating the tests as part of a MM pull request.
'google/resource_binaryauthorization_attestor_test.go':
'templates/terraform/tests/resource_binaryauthorization_attestor_test.go'
'google/resource_binaryauthorization_policy_test.go':
'templates/terraform/tests/resource_binaryauthorization_policy_test.go'
<%= lines(indent(compile('provider/terraform/common~copy.yaml'), 4)) -%>
# These files have templating (ERB) code that will be run.
# This is usually to add licensing info, autogeneration notices, etc.
compile:
'google/provider_{{product_name}}_gen.go': 'templates/terraform/provider_gen.erb'
<%= lines(indent(compile('provider/terraform/common~compile.yaml'), 4)) -%>
46 changes: 2 additions & 44 deletions products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -868,55 +868,13 @@ overrides: !ruby/object:Provider::ResourceOverrides
constants: templates/terraform/constants/vpn_tunnel.erb
Zone: !ruby/object:Provider::Terraform::ResourceOverride
exclude: true
# This is for a list of example files.
examples: !ruby/object:Api::Resource::HashArray

# This is for copying files over
files: !ruby/object:Provider::Config::Files
# All of these files will be copied verbatim.
copy:
'google/transport.go': 'templates/terraform/transport.go'
'google/transport_test.go': 'templates/terraform/transport_test.go'
'google/import.go': 'templates/terraform/import.go'
'google/import_test.go': 'templates/terraform/import_test.go'
# Handwritten acceptance tests for autogenerated resources.
# Adding them here allows updating the tests as part of a MM pull request.
'google/resource_compute_address_test.go':
'templates/terraform/tests/resource_compute_address_test.go'
'google/resource_compute_autoscaler_test.go':
'templates/terraform/tests/resource_compute_autoscaler_test.go'
'google/resource_compute_firewall_test.go':
'templates/terraform/tests/resource_compute_firewall_test.go'
'google/resource_compute_global_address_test.go':
'templates/terraform/tests/resource_compute_global_address_test.go'
'google/resource_compute_health_check_test.go':
'templates/terraform/tests/resource_compute_health_check_test.go'
'google/resource_compute_region_autoscaler_test.go':
'templates/terraform/tests/resource_compute_region_autoscaler_test.go'
'google/resource_compute_region_disk_test.go':
'templates/terraform/tests/resource_compute_region_disk_test.go'
'google/resource_compute_router_test.go':
'templates/terraform/tests/resource_compute_router_test.go'
'google/resource_compute_ssl_certificate_test.go':
'templates/terraform/tests/resource_compute_ssl_certificate_test.go'
'google/resource_compute_target_https_proxy_test.go':
'templates/terraform/tests/resource_compute_target_https_proxy_test.go'
'google/resource_compute_target_ssl_proxy_test.go':
'templates/terraform/tests/resource_compute_target_ssl_proxy_test.go'
'google/resource_compute_vpn_tunnel_test.go':
'templates/terraform/tests/resource_compute_vpn_tunnel_test.go'
<%= lines(indent(compile('provider/terraform/common~copy.yaml'), 4)) -%>
# These files have templating (ERB) code that will be run.
# This is usually to add licensing info, autogeneration notices, etc.
compile:
'google/provider_{{product_name}}_gen.go': 'templates/terraform/provider_gen.erb'

# This is for custom testing code. All of our tests follow a specific pattern
# that sometimes needs to be deviated from. We're working towards a world where
# these handwritten tests would be unnecessary in many cases (custom types).
tests: !ruby/object:Api::Resource::HashArray

# This would be for custom network responses. Tests work by running some block
# of autogenerated code and then verifying the network calls.
# The network call verifications are automatically generated, but can be
# overriden.
test_data: !ruby/object:Provider::Config::TestData
<%= lines(indent(compile('provider/terraform/common~compile.yaml'), 4)) -%>
25 changes: 2 additions & 23 deletions products/containeranalysis/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,12 @@ overrides: !ruby/object:Provider::ResourceOverrides
name: !ruby/object:Provider::Terraform::PropertyOverride
custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb'

# This is for a list of example files.
examples: !ruby/object:Api::Resource::HashArray

# This is for copying files over
files: !ruby/object:Provider::Config::Files
# All of these files will be copied verbatim.
copy:
'google/transport.go': 'templates/terraform/transport.go'
'google/transport_test.go': 'templates/terraform/transport_test.go'
'google/import.go': 'templates/terraform/import.go'
'google/import_test.go': 'templates/terraform/import_test.go'
# Handwritten acceptance tests for autogenerated resources.
# Adding them here allows updating the tests as part of a MM pull request.
'google/resource_containeranalysis_note_test.go':
'templates/terraform/tests/resource_containeranalysis_note_test.go'
<%= lines(indent(compile('provider/terraform/common~copy.yaml'), 4)) -%>
# These files have templating (ERB) code that will be run.
# This is usually to add licensing info, autogeneration notices, etc.
compile:
'google/provider_{{product_name}}_gen.go': 'templates/terraform/provider_gen.erb'

# This is for custom testing code. All of our tests follow a specific pattern
# that sometimes needs to be deviated from. We're working towards a world where
# these handwritten tests would be unnecessary in many cases (custom types).
tests: !ruby/object:Api::Resource::HashArray

# This would be for custom network responses. Tests work by running some block
# of autogenerated code and then verifying the network calls.
# The network call verifications are automatically generated, but can be
# overriden.
test_data: !ruby/object:Provider::Config::TestData
<%= lines(indent(compile('provider/terraform/common~compile.yaml'), 4)) -%>
22 changes: 2 additions & 20 deletions products/filestore/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,12 @@ overrides: !ruby/object:Provider::ResourceOverrides
pre_update: templates/terraform/pre_update/update_mask.erb
constants: templates/terraform/constants/filestore.erb

# This is for a list of example files.
examples: !ruby/object:Api::Resource::HashArray

# This is for copying files over
files: !ruby/object:Provider::Config::Files
# All of these files will be copied verbatim.
copy:
'google/transport.go': 'templates/terraform/transport.go'
'google/transport_test.go': 'templates/terraform/transport_test.go'
'google/import.go': 'templates/terraform/import.go'
'google/import_test.go': 'templates/terraform/import_test.go'
'google/filestore_operation.go': 'templates/terraform/filestore_operation.go'
<%= lines(indent(compile('provider/terraform/common~copy.yaml'), 4)) -%>
# These files have templating (ERB) code that will be run.
# This is usually to add licensing info, autogeneration notices, etc.
compile:
'google/provider_{{product_name}}_gen.go': 'templates/terraform/provider_gen.erb'

# This is for custom testing code. All of our tests follow a specific pattern
# that sometimes needs to be deviated from. We're working towards a world where
# these handwritten tests would be unnecessary in many cases (custom types).
tests: !ruby/object:Api::Resource::HashArray

# This would be for custom network responses. Tests work by running some block
# of autogenerated code and then verifying the network calls.
# The network call verifications are automatically generated, but can be
# overriden.
test_data: !ruby/object:Provider::Config::TestData
<%= lines(indent(compile('provider/terraform/common~compile.yaml'), 4)) -%>
8 changes: 5 additions & 3 deletions products/monitoring/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ overrides: !ruby/object:Provider::ResourceOverrides
post_create: templates/terraform/post_create/group.erb

files: !ruby/object:Provider::Config::Files
# All of these files will be copied verbatim.
copy:
'google/resource_monitoring_alert_policy_test.go':
'templates/terraform/tests/resource_monitoring_alert_policy_test.go'
<%= lines(indent(compile('provider/terraform/common~copy.yaml'), 4)) -%>
# These files have templating (ERB) code that will be run.
# This is usually to add licensing info, autogeneration notices, etc.
compile:
'google/provider_{{product_name}}_gen.go': 'templates/terraform/provider_gen.erb'
<%= lines(indent(compile('provider/terraform/common~compile.yaml'), 4)) -%>
26 changes: 2 additions & 24 deletions products/redis/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,12 @@ overrides: !ruby/object:Provider::ResourceOverrides
reservedIpRange: !ruby/object:Provider::Terraform::PropertyOverride
default_from_api: true

# This is for a list of example files.
examples: !ruby/object:Api::Resource::HashArray

# This is for copying files over
files: !ruby/object:Provider::Config::Files
# All of these files will be copied verbatim.
copy:
'google/transport.go': 'templates/terraform/transport.go'
'google/transport_test.go': 'templates/terraform/transport_test.go'
'google/import.go': 'templates/terraform/import.go'
'google/import_test.go': 'templates/terraform/import_test.go'
'google/redis_operation.go': 'templates/terraform/redis_operation.go'
# Handwritten acceptance tests for autogenerated resources.
# Adding them here allows updating the tests as part of a MM pull request.
'google/resource_redis_instance_test.go':
'templates/terraform/tests/resource_redis_instance_test.go'
<%= lines(indent(compile('provider/terraform/common~copy.yaml'), 4)) -%>
# These files have templating (ERB) code that will be run.
# This is usually to add licensing info, autogeneration notices, etc.
compile:
'google/provider_{{product_name}}_gen.go': 'templates/terraform/provider_gen.erb'

# This is for custom testing code. All of our tests follow a specific pattern
# that sometimes needs to be deviated from. We're working towards a world where
# these handwritten tests would be unnecessary in many cases (custom types).
tests: !ruby/object:Api::Resource::HashArray

# This would be for custom network responses. Tests work by running some block
# of autogenerated code and then verifying the network calls.
# The network call verifications are automatically generated, but can be
# overriden.
test_data: !ruby/object:Provider::Config::TestData
<%= lines(indent(compile('provider/terraform/common~compile.yaml'), 4)) -%>
7 changes: 2 additions & 5 deletions products/resourcemanager/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@ overrides: !ruby/object:Provider::ResourceOverrides
files: !ruby/object:Provider::Config::Files
# All of these files will be copied verbatim.
copy:
'google/transport.go': 'templates/terraform/transport.go'
'google/transport_test.go': 'templates/terraform/transport_test.go'
'google/import.go': 'templates/terraform/import.go'
'google/import_test.go': 'templates/terraform/import_test.go'
<%= lines(indent(compile('provider/terraform/common~copy.yaml'), 4)) -%>
# These files have templating (ERB) code that will be run.
# This is usually to add licensing info, autogeneration notices, etc.
compile:
'google/provider_{{product_name}}_gen.go': 'templates/terraform/provider_gen.erb'
<%= lines(indent(compile('provider/terraform/common~compile.yaml'), 4)) -%>
16 changes: 16 additions & 0 deletions provider/terraform/common~compile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2018 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.
# These files contains code that needs to be compiled before being delivered to
# the final module tree structure:
<% dir = _version_name == 'beta' ? 'google-beta' : 'google' -%>
'<%= dir -%>/provider_<%= api.prefix[1..-1] -%>_gen.go': 'templates/terraform/provider_gen.erb'
27 changes: 27 additions & 0 deletions provider/terraform/common~copy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2018 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.
# These files contains code that needs to be compiled before being delivered to
# the final module tree structure:
<%
dir = _version_name == 'beta' ? 'google-beta' : 'google'
Dir["templates/terraform/tests/*#{api.prefix[1..-1]}*"].each do |file_path|
fname = file_path.split('/')[-1]
-%>
# Handwritten acceptance tests for autogenerated resources.
# Adding them here allows updating the tests as part of a MM pull request.
'<%= dir -%>/<%= fname -%>': 'templates/terraform/tests/<%= fname -%>'
<% end -%>
'<%= dir -%>/transport.go': 'templates/terraform/transport.go'
'<%= dir -%>/transport_test.go': 'templates/terraform/transport_test.go'
'<%= dir -%>/import.go': 'templates/terraform/import.go'
'<%= dir -%>/import_test.go': 'templates/terraform/import_test.go'