Skip to content

Commit 355fbf1

Browse files
danawillowmodular-magician
authored andcommitted
add common compile/copy for terraform (GoogleCloudPlatform#541)
Merged PR GoogleCloudPlatform#541.
1 parent 7cdd065 commit 355fbf1

File tree

9 files changed

+60
-130
lines changed

9 files changed

+60
-130
lines changed

products/binaryauthorization/terraform.yaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,8 @@ overrides: !ruby/object:Provider::ResourceOverrides
107107
files: !ruby/object:Provider::Config::Files
108108
# All of these files will be copied verbatim.
109109
copy:
110-
'google/transport.go': 'templates/terraform/transport.go'
111-
'google/transport_test.go': 'templates/terraform/transport_test.go'
112-
'google/import.go': 'templates/terraform/import.go'
113-
'google/import_test.go': 'templates/terraform/import_test.go'
114-
# Handwritten acceptance tests for autogenerated resources.
115-
# Adding them here allows updating the tests as part of a MM pull request.
116-
'google/resource_binaryauthorization_attestor_test.go':
117-
'templates/terraform/tests/resource_binaryauthorization_attestor_test.go'
118-
'google/resource_binaryauthorization_policy_test.go':
119-
'templates/terraform/tests/resource_binaryauthorization_policy_test.go'
110+
<%= lines(indent(compile('provider/terraform/common~copy.yaml'), 4)) -%>
120111
# These files have templating (ERB) code that will be run.
121112
# This is usually to add licensing info, autogeneration notices, etc.
122113
compile:
123-
'google/provider_{{product_name}}_gen.go': 'templates/terraform/provider_gen.erb'
114+
<%= lines(indent(compile('provider/terraform/common~compile.yaml'), 4)) -%>

products/compute/terraform.yaml

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -868,55 +868,13 @@ overrides: !ruby/object:Provider::ResourceOverrides
868868
constants: templates/terraform/constants/vpn_tunnel.erb
869869
Zone: !ruby/object:Provider::Terraform::ResourceOverride
870870
exclude: true
871-
# This is for a list of example files.
872-
examples: !ruby/object:Api::Resource::HashArray
873871

874872
# This is for copying files over
875873
files: !ruby/object:Provider::Config::Files
876874
# All of these files will be copied verbatim.
877875
copy:
878-
'google/transport.go': 'templates/terraform/transport.go'
879-
'google/transport_test.go': 'templates/terraform/transport_test.go'
880-
'google/import.go': 'templates/terraform/import.go'
881-
'google/import_test.go': 'templates/terraform/import_test.go'
882-
# Handwritten acceptance tests for autogenerated resources.
883-
# Adding them here allows updating the tests as part of a MM pull request.
884-
'google/resource_compute_address_test.go':
885-
'templates/terraform/tests/resource_compute_address_test.go'
886-
'google/resource_compute_autoscaler_test.go':
887-
'templates/terraform/tests/resource_compute_autoscaler_test.go'
888-
'google/resource_compute_firewall_test.go':
889-
'templates/terraform/tests/resource_compute_firewall_test.go'
890-
'google/resource_compute_global_address_test.go':
891-
'templates/terraform/tests/resource_compute_global_address_test.go'
892-
'google/resource_compute_health_check_test.go':
893-
'templates/terraform/tests/resource_compute_health_check_test.go'
894-
'google/resource_compute_region_autoscaler_test.go':
895-
'templates/terraform/tests/resource_compute_region_autoscaler_test.go'
896-
'google/resource_compute_region_disk_test.go':
897-
'templates/terraform/tests/resource_compute_region_disk_test.go'
898-
'google/resource_compute_router_test.go':
899-
'templates/terraform/tests/resource_compute_router_test.go'
900-
'google/resource_compute_ssl_certificate_test.go':
901-
'templates/terraform/tests/resource_compute_ssl_certificate_test.go'
902-
'google/resource_compute_target_https_proxy_test.go':
903-
'templates/terraform/tests/resource_compute_target_https_proxy_test.go'
904-
'google/resource_compute_target_ssl_proxy_test.go':
905-
'templates/terraform/tests/resource_compute_target_ssl_proxy_test.go'
906-
'google/resource_compute_vpn_tunnel_test.go':
907-
'templates/terraform/tests/resource_compute_vpn_tunnel_test.go'
876+
<%= lines(indent(compile('provider/terraform/common~copy.yaml'), 4)) -%>
908877
# These files have templating (ERB) code that will be run.
909878
# This is usually to add licensing info, autogeneration notices, etc.
910879
compile:
911-
'google/provider_{{product_name}}_gen.go': 'templates/terraform/provider_gen.erb'
912-
913-
# This is for custom testing code. All of our tests follow a specific pattern
914-
# that sometimes needs to be deviated from. We're working towards a world where
915-
# these handwritten tests would be unnecessary in many cases (custom types).
916-
tests: !ruby/object:Api::Resource::HashArray
917-
918-
# This would be for custom network responses. Tests work by running some block
919-
# of autogenerated code and then verifying the network calls.
920-
# The network call verifications are automatically generated, but can be
921-
# overriden.
922-
test_data: !ruby/object:Provider::Config::TestData
880+
<%= lines(indent(compile('provider/terraform/common~compile.yaml'), 4)) -%>

products/containeranalysis/terraform.yaml

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,12 @@ overrides: !ruby/object:Provider::ResourceOverrides
2828
name: !ruby/object:Provider::Terraform::PropertyOverride
2929
custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb'
3030

31-
# This is for a list of example files.
32-
examples: !ruby/object:Api::Resource::HashArray
33-
3431
# This is for copying files over
3532
files: !ruby/object:Provider::Config::Files
3633
# All of these files will be copied verbatim.
3734
copy:
38-
'google/transport.go': 'templates/terraform/transport.go'
39-
'google/transport_test.go': 'templates/terraform/transport_test.go'
40-
'google/import.go': 'templates/terraform/import.go'
41-
'google/import_test.go': 'templates/terraform/import_test.go'
42-
# Handwritten acceptance tests for autogenerated resources.
43-
# Adding them here allows updating the tests as part of a MM pull request.
44-
'google/resource_containeranalysis_note_test.go':
45-
'templates/terraform/tests/resource_containeranalysis_note_test.go'
35+
<%= lines(indent(compile('provider/terraform/common~copy.yaml'), 4)) -%>
4636
# These files have templating (ERB) code that will be run.
4737
# This is usually to add licensing info, autogeneration notices, etc.
4838
compile:
49-
'google/provider_{{product_name}}_gen.go': 'templates/terraform/provider_gen.erb'
50-
51-
# This is for custom testing code. All of our tests follow a specific pattern
52-
# that sometimes needs to be deviated from. We're working towards a world where
53-
# these handwritten tests would be unnecessary in many cases (custom types).
54-
tests: !ruby/object:Api::Resource::HashArray
55-
56-
# This would be for custom network responses. Tests work by running some block
57-
# of autogenerated code and then verifying the network calls.
58-
# The network call verifications are automatically generated, but can be
59-
# overriden.
60-
test_data: !ruby/object:Provider::Config::TestData
39+
<%= lines(indent(compile('provider/terraform/common~compile.yaml'), 4)) -%>

products/filestore/terraform.yaml

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,12 @@ overrides: !ruby/object:Provider::ResourceOverrides
3434
pre_update: templates/terraform/pre_update/update_mask.erb
3535
constants: templates/terraform/constants/filestore.erb
3636

37-
# This is for a list of example files.
38-
examples: !ruby/object:Api::Resource::HashArray
39-
4037
# This is for copying files over
4138
files: !ruby/object:Provider::Config::Files
4239
# All of these files will be copied verbatim.
4340
copy:
44-
'google/transport.go': 'templates/terraform/transport.go'
45-
'google/transport_test.go': 'templates/terraform/transport_test.go'
46-
'google/import.go': 'templates/terraform/import.go'
47-
'google/import_test.go': 'templates/terraform/import_test.go'
48-
'google/filestore_operation.go': 'templates/terraform/filestore_operation.go'
41+
<%= lines(indent(compile('provider/terraform/common~copy.yaml'), 4)) -%>
4942
# These files have templating (ERB) code that will be run.
5043
# This is usually to add licensing info, autogeneration notices, etc.
5144
compile:
52-
'google/provider_{{product_name}}_gen.go': 'templates/terraform/provider_gen.erb'
53-
54-
# This is for custom testing code. All of our tests follow a specific pattern
55-
# that sometimes needs to be deviated from. We're working towards a world where
56-
# these handwritten tests would be unnecessary in many cases (custom types).
57-
tests: !ruby/object:Api::Resource::HashArray
58-
59-
# This would be for custom network responses. Tests work by running some block
60-
# of autogenerated code and then verifying the network calls.
61-
# The network call verifications are automatically generated, but can be
62-
# overriden.
63-
test_data: !ruby/object:Provider::Config::TestData
45+
<%= lines(indent(compile('provider/terraform/common~compile.yaml'), 4)) -%>

products/monitoring/terraform.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ overrides: !ruby/object:Provider::ResourceOverrides
8585
post_create: templates/terraform/post_create/group.erb
8686

8787
files: !ruby/object:Provider::Config::Files
88+
# All of these files will be copied verbatim.
8889
copy:
89-
'google/resource_monitoring_alert_policy_test.go':
90-
'templates/terraform/tests/resource_monitoring_alert_policy_test.go'
90+
<%= lines(indent(compile('provider/terraform/common~copy.yaml'), 4)) -%>
91+
# These files have templating (ERB) code that will be run.
92+
# This is usually to add licensing info, autogeneration notices, etc.
9193
compile:
92-
'google/provider_{{product_name}}_gen.go': 'templates/terraform/provider_gen.erb'
94+
<%= lines(indent(compile('provider/terraform/common~compile.yaml'), 4)) -%>

products/redis/terraform.yaml

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,34 +52,12 @@ overrides: !ruby/object:Provider::ResourceOverrides
5252
reservedIpRange: !ruby/object:Provider::Terraform::PropertyOverride
5353
default_from_api: true
5454

55-
# This is for a list of example files.
56-
examples: !ruby/object:Api::Resource::HashArray
57-
5855
# This is for copying files over
5956
files: !ruby/object:Provider::Config::Files
6057
# All of these files will be copied verbatim.
6158
copy:
62-
'google/transport.go': 'templates/terraform/transport.go'
63-
'google/transport_test.go': 'templates/terraform/transport_test.go'
64-
'google/import.go': 'templates/terraform/import.go'
65-
'google/import_test.go': 'templates/terraform/import_test.go'
66-
'google/redis_operation.go': 'templates/terraform/redis_operation.go'
67-
# Handwritten acceptance tests for autogenerated resources.
68-
# Adding them here allows updating the tests as part of a MM pull request.
69-
'google/resource_redis_instance_test.go':
70-
'templates/terraform/tests/resource_redis_instance_test.go'
59+
<%= lines(indent(compile('provider/terraform/common~copy.yaml'), 4)) -%>
7160
# These files have templating (ERB) code that will be run.
7261
# This is usually to add licensing info, autogeneration notices, etc.
7362
compile:
74-
'google/provider_{{product_name}}_gen.go': 'templates/terraform/provider_gen.erb'
75-
76-
# This is for custom testing code. All of our tests follow a specific pattern
77-
# that sometimes needs to be deviated from. We're working towards a world where
78-
# these handwritten tests would be unnecessary in many cases (custom types).
79-
tests: !ruby/object:Api::Resource::HashArray
80-
81-
# This would be for custom network responses. Tests work by running some block
82-
# of autogenerated code and then verifying the network calls.
83-
# The network call verifications are automatically generated, but can be
84-
# overriden.
85-
test_data: !ruby/object:Provider::Config::TestData
63+
<%= lines(indent(compile('provider/terraform/common~compile.yaml'), 4)) -%>

products/resourcemanager/terraform.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,8 @@ overrides: !ruby/object:Provider::ResourceOverrides
3838
files: !ruby/object:Provider::Config::Files
3939
# All of these files will be copied verbatim.
4040
copy:
41-
'google/transport.go': 'templates/terraform/transport.go'
42-
'google/transport_test.go': 'templates/terraform/transport_test.go'
43-
'google/import.go': 'templates/terraform/import.go'
44-
'google/import_test.go': 'templates/terraform/import_test.go'
41+
<%= lines(indent(compile('provider/terraform/common~copy.yaml'), 4)) -%>
4542
# These files have templating (ERB) code that will be run.
4643
# This is usually to add licensing info, autogeneration notices, etc.
4744
compile:
48-
'google/provider_{{product_name}}_gen.go': 'templates/terraform/provider_gen.erb'
45+
<%= lines(indent(compile('provider/terraform/common~compile.yaml'), 4)) -%>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2018 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# These files contains code that needs to be compiled before being delivered to
14+
# the final module tree structure:
15+
<% dir = _version_name == 'beta' ? 'google-beta' : 'google' -%>
16+
'<%= dir -%>/provider_<%= api.prefix[1..-1] -%>_gen.go': 'templates/terraform/provider_gen.erb'
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2018 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# These files contains code that needs to be compiled before being delivered to
14+
# the final module tree structure:
15+
<%
16+
dir = _version_name == 'beta' ? 'google-beta' : 'google'
17+
Dir["templates/terraform/tests/*#{api.prefix[1..-1]}*"].each do |file_path|
18+
fname = file_path.split('/')[-1]
19+
-%>
20+
# Handwritten acceptance tests for autogenerated resources.
21+
# Adding them here allows updating the tests as part of a MM pull request.
22+
'<%= dir -%>/<%= fname -%>': 'templates/terraform/tests/<%= fname -%>'
23+
<% end -%>
24+
'<%= dir -%>/transport.go': 'templates/terraform/transport.go'
25+
'<%= dir -%>/transport_test.go': 'templates/terraform/transport_test.go'
26+
'<%= dir -%>/import.go': 'templates/terraform/import.go'
27+
'<%= dir -%>/import_test.go': 'templates/terraform/import_test.go'

0 commit comments

Comments
 (0)