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

Generate SslCertificate in Terraform. #445

Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 12 additions & 8 deletions .ci/ci.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@ build/{{repo}}/{{name}}
}
%}
{% set puppet_test_excludes = {
'compute': [
'spec/gcompute_instance_group_manager_provider_spec.rb',
'spec/gcompute_instance_provider_spec.rb',
'spec/gcompute_instance_template_provider_spec.rb',
'spec/gcompute_target_https_proxy_provider_spec.rb',
'spec/gcompute_target_ssl_proxy_provider_spec.rb',
'spec/gcompute_vpn_tunnel_provider_spec.rb',
'spec/puppetlint_spec.rb']
'compute': [
'spec/gcompute_instance_group_manager_provider_spec.rb',
'spec/gcompute_instance_provider_spec.rb',
'spec/gcompute_instance_template_provider_spec.rb',
'spec/gcompute_target_https_proxy_provider_spec.rb',
'spec/gcompute_target_ssl_proxy_provider_spec.rb',
'spec/gcompute_vpn_tunnel_provider_spec.rb',
'spec/puppetlint_spec.rb'
],
'bigquery': [
'spec/gbigquery_table_provider_spec.rb'
]
}
%}

Expand Down
4 changes: 2 additions & 2 deletions TEMPLATE_SDK.md
Original file line number Diff line number Diff line change
Expand Up @@ -761,12 +761,12 @@ line #1 by compiling the license template:
To ensure no doubts exist on the readers' minds, we recommend that you mark the
copyright notice on the template with a ERB block:

<% if false # the license inside this if block assertains to this file -%>
<%# The license inside this block applies to this file
# Copyright 2017 Google Inc.
...
...
...
<% end # copyright -%>
-%>

### Determining the generated artifact "effective year"

Expand Down
1 change: 1 addition & 0 deletions api/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ def full_delete_url
def regex_url
self_link_url.join.gsub('{{project}}', '.*')
.gsub('{{name}}', '[a-z1-9\-]*')
.gsub('{{zone}}', '[a-z1-9\-]*')
end

private
Expand Down
25 changes: 23 additions & 2 deletions api/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

module Api
# Represents a property type
# rubocop:disable Metrics/ClassLength
class Type < Api::Object::Named
# The list of properties (attr_reader) that can be overridden in
# <provider>.yaml.
Expand All @@ -37,6 +38,9 @@ module Fields
# "ForceSendFields" concepts in the autogenerated API clients.
attr_reader :send_empty_value
attr_reader :min_version

# Can only be overriden - we should never set this ourselves.
attr_reader :new_type
end

include Fields
Expand Down Expand Up @@ -128,6 +132,22 @@ def exclude_if_not_in_version(version)
@exclude ||= version < min_version
end

# Overriding is_a? to enable class overrides.
# Ruby does not let you natively change types, so this is the next best
# thing.
def is_a?(clazz)
return Module.const_get(@new_type).new.is_a?(clazz) if @new_type
super(clazz)
end

# Overriding class to enable class overrides.
# Ruby does not let you natively change types, so this is the next best
# thing.
def class
return Module.const_get(@new_type) if @new_type
super
end

private

# A constant value to be provided as field
Expand Down Expand Up @@ -158,8 +178,8 @@ class Double < Primitive

# Represents a string
class String < Primitive
def initialize(name)
@name = name
def initialize(name = nil)
@name ||= name
end

PROJECT = Api::Type::String.new('project')
Expand Down Expand Up @@ -518,4 +538,5 @@ def property_ns_prefix
]
end
end
# rubocop:enable Metrics/ClassLength
end
2 changes: 1 addition & 1 deletion build/chef/_bundle
Submodule _bundle updated 1 files
+3 −3 README.md
2 changes: 1 addition & 1 deletion build/chef/compute
Submodule compute updated 112 files
2 changes: 1 addition & 1 deletion build/chef/iam
2 changes: 1 addition & 1 deletion build/puppet/_bundle
Submodule _bundle updated 1 files
+6 −3 README.md
2 changes: 1 addition & 1 deletion build/puppet/bigquery
Submodule bigquery updated 30 files
+9 −4 .tools/end2end/data/table.pp
+25 −0 CONTRIBUTING.md
+440 −0 README.md
+9 −4 examples/table.pp
+64 −0 lib/google/bigquery/property/boolean.rb
+59 −0 lib/google/bigquery/property/string_array.rb
+143 −0 lib/google/bigquery/property/table_bigtable_options.rb
+170 −0 lib/google/bigquery/property/table_column_families.rb
+169 −0 lib/google/bigquery/property/table_columns.rb
+155 −0 lib/google/bigquery/property/table_csv_options.rb
+118 −0 lib/google/bigquery/property/table_encryption_configuration.rb
+183 −0 lib/google/bigquery/property/table_external_data_configuration.rb
+167 −0 lib/google/bigquery/property/table_fields.rb
+120 −0 lib/google/bigquery/property/table_google_sheets_options.rb
+120 −0 lib/google/bigquery/property/table_schema.rb
+133 −0 lib/google/bigquery/property/table_streaming_buffer.rb
+130 −0 lib/google/bigquery/property/table_table_reference.rb
+124 −0 lib/google/bigquery/property/table_time_partitioning.rb
+149 −0 lib/google/bigquery/property/table_user_defined_function_resources.rb
+132 −0 lib/google/bigquery/property/table_view.rb
+302 −0 lib/puppet/provider/gbigquery_table/google.rb
+185 −0 lib/puppet/type/gbigquery_table.rb
+256 −0 spec/data/network/gbigquery_table/success1~name.yaml
+256 −0 spec/data/network/gbigquery_table/success1~title.yaml
+253 −0 spec/data/network/gbigquery_table/success2~name.yaml
+253 −0 spec/data/network/gbigquery_table/success2~title.yaml
+222 −0 spec/data/network/gbigquery_table/success3~name.yaml
+222 −0 spec/data/network/gbigquery_table/success3~title.yaml
+3,479 −0 spec/gbigquery_table_provider_spec.rb
+27 −0 spec/test_constants.rb
2 changes: 1 addition & 1 deletion build/puppet/compute
Submodule compute updated 64 files
+0 −9 .tools/end2end/data/instance.pp
+11 −8 README.md
+0 −9 examples/instance.pp
+5 −4 lib/google/compute/property/address_address.rb
+5 −4 lib/google/compute/property/backendservice_selflink.rb
+5 −4 lib/google/compute/property/disk_name.rb
+5 −4 lib/google/compute/property/disk_selflink.rb
+8 −20 lib/google/compute/property/disktype_selflink.rb
+8 −7 lib/google/compute/property/forwardingrule_selflink.rb
+5 −4 lib/google/compute/property/httphealthcheck_selflink.rb
+8 −7 lib/google/compute/property/instance_selflink.rb
+5 −4 lib/google/compute/property/instancegroup_selflink.rb
+5 −4 lib/google/compute/property/instancetemplate_selflink.rb
+10 −22 lib/google/compute/property/license_selflink.rb
+5 −4 lib/google/compute/property/machinetype_name.rb
+8 −20 lib/google/compute/property/machinetype_selflink.rb
+5 −4 lib/google/compute/property/network_selflink.rb
+5 −4 lib/google/compute/property/region_name.rb
+7 −19 lib/google/compute/property/region_selflink.rb
+5 −4 lib/google/compute/property/router_selflink.rb
+5 −4 lib/google/compute/property/snapshot_selflink.rb
+8 −7 lib/google/compute/property/sslcertificate_selflink.rb
+5 −4 lib/google/compute/property/subnetwork_selflink.rb
+8 −7 lib/google/compute/property/targetpool_selflink.rb
+5 −4 lib/google/compute/property/targetvpngateway_selflink.rb
+5 −4 lib/google/compute/property/urlmap_selflink.rb
+5 −4 lib/google/compute/property/zone_name.rb
+1 −2 lib/puppet/provider/gcompute_address/google.rb
+1 −2 lib/puppet/provider/gcompute_backend_bucket/google.rb
+1 −2 lib/puppet/provider/gcompute_backend_service/google.rb
+1 −2 lib/puppet/provider/gcompute_disk/google.rb
+1 −2 lib/puppet/provider/gcompute_disk_type/google.rb
+1 −2 lib/puppet/provider/gcompute_firewall/google.rb
+1 −2 lib/puppet/provider/gcompute_forwarding_rule/google.rb
+1 −2 lib/puppet/provider/gcompute_global_address/google.rb
+1 −2 lib/puppet/provider/gcompute_health_check/google.rb
+1 −2 lib/puppet/provider/gcompute_http_health_check/google.rb
+1 −2 lib/puppet/provider/gcompute_https_health_check/google.rb
+1 −2 lib/puppet/provider/gcompute_instance/google.rb
+1 −2 lib/puppet/provider/gcompute_instance_group/google.rb
+1 −2 lib/puppet/provider/gcompute_instance_group_manager/google.rb
+1 −2 lib/puppet/provider/gcompute_instance_template/google.rb
+1 −2 lib/puppet/provider/gcompute_license/google.rb
+1 −2 lib/puppet/provider/gcompute_machine_type/google.rb
+1 −2 lib/puppet/provider/gcompute_network/google.rb
+1 −2 lib/puppet/provider/gcompute_region/google.rb
+1 −2 lib/puppet/provider/gcompute_route/google.rb
+1 −2 lib/puppet/provider/gcompute_router/google.rb
+1 −2 lib/puppet/provider/gcompute_snapshot/google.rb
+2 −7 lib/puppet/provider/gcompute_ssl_certificate/google.rb
+1 −2 lib/puppet/provider/gcompute_subnetwork/google.rb
+1 −2 lib/puppet/provider/gcompute_target_http_proxy/google.rb
+1 −2 lib/puppet/provider/gcompute_target_https_proxy/google.rb
+1 −2 lib/puppet/provider/gcompute_target_pool/google.rb
+1 −2 lib/puppet/provider/gcompute_target_ssl_proxy/google.rb
+1 −2 lib/puppet/provider/gcompute_target_tcp_proxy/google.rb
+1 −2 lib/puppet/provider/gcompute_target_vpn_gateway/google.rb
+1 −2 lib/puppet/provider/gcompute_url_map/google.rb
+1 −2 lib/puppet/provider/gcompute_vpn_tunnel/google.rb
+1 −2 lib/puppet/provider/gcompute_zone/google.rb
+4 −3 lib/puppet/type/gcompute_ssl_certificate.rb
+22 −14 spec/gcompute_ssl_certificate_provider_spec.rb
+72 −48 spec/gcompute_target_https_proxy_provider_spec.rb
+72 −48 spec/gcompute_target_ssl_proxy_provider_spec.rb
2 changes: 1 addition & 1 deletion build/terraform
50 changes: 27 additions & 23 deletions compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
require 'provider/terraform'
require 'pp' if ENV['COMPILER_DEBUG']

catalog = nil
output = nil
provider = nil
product_name = nil
output_path = nil
provider_name = nil
types_to_generate = []
version = nil

Expand All @@ -47,13 +47,13 @@

OptionParser.new do |opt|
opt.on('-p', '--product PRODUCT', 'Folder with product catalog') do |p|
catalog = p
product_name = p
end
opt.on('-o', '--output OUTPUT', 'Folder for module output') do |o|
output = o
output_path = o
end
opt.on('-e', '--engine ENGINE', 'Technology to build for') do |e|
provider = "#{e}.yaml"
opt.on('-e', '--engine ENGINE', 'Provider ("engine") to build') do |e|
provider_name = e
end
opt.on('-t', '--type TYPE[,TYPE...]', Array, 'Types to generate') do |t|
types_to_generate = t
Expand All @@ -70,27 +70,31 @@
end
end.parse!

raise 'Option -p/--product is a required parameter' if catalog.nil?
raise 'Option -o/--output is a required parameter' if output.nil?
raise 'Option -e/--engine is a required parameter' if provider.nil?
raise 'Option -p/--product is a required parameter' if product_name.nil?
raise 'Option -o/--output is a required parameter' if output_path.nil?
raise 'Option -e/--engine is a required parameter' if provider_name.nil?

raise "Product '#{catalog}' does not have api.yaml" \
unless File.exist?(File.join(catalog, 'api.yaml'))
raise "Product '#{catalog}' does not have #{provider} settings" \
unless File.exist?(File.join(catalog, provider))
product_yaml_path = File.join(product_name, 'api.yaml')
raise "Product '#{product_name}' does not have an api.yaml file" \
unless File.exist?(product_yaml_path)

raise "Output '#{output}' is not a directory" unless Dir.exist?(output)
provider_yaml_path = File.join(product_name, "#{provider_name}.yaml")
raise "Product '#{product_name}' does not have a #{provider_name}.yaml file" \
unless File.exist?(provider_yaml_path)

Google::LOGGER.info "Compiling '#{catalog}' output to '#{output}'"
raise "Output path '#{output_path}' does not exist or is not a directory" \
unless Dir.exist?(output_path)

Google::LOGGER.info "Compiling '#{product_name}' output to '#{output_path}'"
Google::LOGGER.info \
"Generating types: #{types_to_generate.empty? ? 'ALL' : types_to_generate}"

api = Api::Compiler.new(File.join(catalog, 'api.yaml')).run
api.validate
pp api if ENV['COMPILER_DEBUG']
product_api = Api::Compiler.new(product_yaml_path).run
product_api.validate
pp product_api if ENV['COMPILER_DEBUG']

config = Provider::Config.parse(File.join(catalog, provider), api, version)
pp config if ENV['COMPILER_DEBUG']
provider_config = Provider::Config.parse(provider_yaml_path, product_api, version)
pp provider_config if ENV['COMPILER_DEBUG']

provider = config.provider.new(config, api)
provider.generate output, types_to_generate, version
provider = provider_config.provider.new(provider_config, product_api)
provider.generate output_path, types_to_generate, version
4 changes: 2 additions & 2 deletions products/_bundle/templates/chef/README.md.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if false # the license inside this if block assertains to this file -%>
<%# The license inside this block applies to this file.
# Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -11,7 +11,7 @@
# 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.
<% end -%>
-%>
<% autogen_exception -%>

Google Cloud Platform for Chef
Expand Down
4 changes: 2 additions & 2 deletions products/_bundle/templates/puppet/README.md.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if false # the license inside this if block assertains to this file -%>
<%# The license inside this block applies to this file.
# Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -11,7 +11,7 @@
# 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.
<% end -%>
-%>
<% autogen_exception -%>

Google Cloud Platform for Puppet
Expand Down
19 changes: 16 additions & 3 deletions products/bigquery/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,28 @@ objects:
name: 'Table'
kind: 'bigquery#table'
base_url: projects/{{project}}/datasets/{{dataset}}/tables
exclude: true
description: >
A Table that belongs to a Dataset
parameters:
# TODO: Convert to ResourceRef when multi-layered exports exist
# TODO(alexstephen): Remove once we have support for placing
# nested object fields in URL
- !ruby/object:Api::Type::String
name: 'dataset'
description: The dataset this table belongs to.
description: Name of the dataset
properties:
- !ruby/object:Api::Type::NestedObject
name: tableReference
description: Reference describing the ID of this table
properties:
- !ruby/object:Api::Type::String
name: 'datasetId'
description: The ID of the dataset containing this table
- !ruby/object:Api::Type::String
name: 'projectid'
description: The ID of the project containing this table
- !ruby/object:Api::Type::String
name: 'tableId'
description: The ID of the the table
- !ruby/object:Api::Type::Integer
name: 'creationTime'
output: true
Expand Down
4 changes: 2 additions & 2 deletions products/bigquery/examples/puppet/dataset.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if false # the license inside this if block assertains to this file -%>
<%# The license inside this block applies to this file
# Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -11,7 +11,7 @@
# 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.
<% end -%>
-%>
<% unless name == "README.md" -%>
<%= compile 'templates/license.erb' -%>

Expand Down
4 changes: 2 additions & 2 deletions products/bigquery/examples/puppet/delete_dataset.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if false # the license inside this if block assertains to this file -%>
<%# The license inside this block applies to this file
# Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -11,7 +11,7 @@
# 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.
<% end -%>
-%>
<% unless name == "README.md" -%>
<%= compile 'templates/license.erb' -%>

Expand Down
17 changes: 11 additions & 6 deletions products/bigquery/examples/puppet/table.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if false # the license inside this if block assertains to this file -%>
<%# The license inside this block applies to this file
# Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -11,7 +11,7 @@
# 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.
<% end -%>
-%>
<% unless name == "README.md" -%>
<%= compile 'templates/license.erb' -%>

Expand All @@ -30,8 +30,13 @@
}

gbigquery_table { <%= example_resource_name('example_table') -%>:
ensure => present,
dataset => <%= example_resource_name('example_dataset') -%>,
project => $project, # e.g. 'my-test-project'
credential => 'mycred',
ensure => present,
dataset => <%= example_resource_name('example_dataset') -%>,
table_reference => {
dataset_id => <%= example_resource_name('example_dataset') -%>,
project_id => $project,
table_id => <%= example_resource_name('example_table') %>
},
project => $project, # e.g. 'my-test-project'
credential => 'mycred',
}
Loading