From 3a6483df8fb2b24e886582f9a7c6ca9e2dcc7552 Mon Sep 17 00:00:00 2001 From: Riley Karson Date: Wed, 12 Sep 2018 18:21:45 +0000 Subject: [PATCH] Minor schema/docs update to SslCertificate. --- README.md | 19 +-- .../compute/property/disktype_selflink.rb | 2 +- .../compute/property/machinetype_selflink.rb | 2 +- .../gcompute_ssl_certificate/google.rb | 6 +- lib/puppet/type/gcompute_ssl_certificate.rb | 7 +- .../gcompute_ssl_certificate_provider_spec.rb | 36 ++++-- ...ompute_target_https_proxy_provider_spec.rb | 120 +++++++++++------- ...gcompute_target_ssl_proxy_provider_spec.rb | 120 +++++++++++------- 8 files changed, 184 insertions(+), 128 deletions(-) diff --git a/README.md b/README.md index 2c83a27c..99ddb6c3 100644 --- a/README.md +++ b/README.md @@ -945,9 +945,9 @@ gcompute_zone { 'us-central1-a': persistent disk faster and at a much lower cost than if you regularly created a full image of the disk. * [`gcompute_ssl_certificate`][]: - An SslCertificate resource. This resource provides a mechanism to upload - an SSL key and certificate to the load balancer to serve secure - connections from the user. + An SslCertificate resource, used for HTTPS load balancing. This resource + provides a mechanism to upload an SSL key and certificate to + the load balancer to serve secure connections from the user. * [`gcompute_subnetwork`][]: A VPC network is a virtual version of the traditional physical networks that exist within and between physical data centers. A VPC network @@ -5280,10 +5280,13 @@ Output only. The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied #### `gcompute_ssl_certificate` -An SslCertificate resource. This resource provides a mechanism to upload -an SSL key and certificate to the load balancer to serve secure -connections from the user. +An SslCertificate resource, used for HTTPS load balancing. This resource +provides a mechanism to upload an SSL key and certificate to +the load balancer to serve secure connections from the user. +#### Reference Guides +* [API Reference](https://cloud.google.com/compute/docs/reference/rest/v1/sslCertificates) +* [Official Documentation](https://cloud.google.com/load-balancing/docs/ssl-certificates) #### Example @@ -5350,7 +5353,7 @@ gcompute_ssl_certificate { 'id-of-resource': ##### `certificate` - The certificate in PEM format. +Required. The certificate in PEM format. The certificate chain must be no greater than 5 certs long. The chain must include at least one intermediate cert. @@ -5370,7 +5373,7 @@ gcompute_ssl_certificate { 'id-of-resource': ##### `private_key` - The private key in PEM format. +Required. The write-only private key in PEM format. ##### Output-only properties diff --git a/lib/google/compute/property/disktype_selflink.rb b/lib/google/compute/property/disktype_selflink.rb index 2ca6c029..18cab969 100644 --- a/lib/google/compute/property/disktype_selflink.rb +++ b/lib/google/compute/property/disktype_selflink.rb @@ -74,7 +74,7 @@ def resource return entry.exports[:self_link] if entry.title == @title end - unless /https:\/\/www.googleapis.com\/compute\/v1\/projects\/.*\/zones\/{{zone}}\/diskTypes\/[a-z1-9\-]*/.match(@title) + unless /https:\/\/www.googleapis.com\/compute\/v1\/projects\/.*\/zones\/[a-z1-9\-]*\/diskTypes\/[a-z1-9\-]*/.match(@title) # We'll asssmble the self_link for the user. # We need to get the project name to assemble the self_link diff --git a/lib/google/compute/property/machinetype_selflink.rb b/lib/google/compute/property/machinetype_selflink.rb index 5d73070d..4a0e307c 100644 --- a/lib/google/compute/property/machinetype_selflink.rb +++ b/lib/google/compute/property/machinetype_selflink.rb @@ -74,7 +74,7 @@ def resource return entry.exports[:self_link] if entry.title == @title end - unless /https:\/\/www.googleapis.com\/compute\/v1\/projects\/.*\/zones\/{{zone}}\/machineTypes\/[a-z1-9\-]*/.match(@title) + unless /https:\/\/www.googleapis.com\/compute\/v1\/projects\/.*\/zones\/[a-z1-9\-]*\/machineTypes\/[a-z1-9\-]*/.match(@title) # We'll asssmble the self_link for the user. # We need to get the project name to assemble the self_link diff --git a/lib/puppet/provider/gcompute_ssl_certificate/google.rb b/lib/puppet/provider/gcompute_ssl_certificate/google.rb index e3d1f1ed..9d475ee1 100644 --- a/lib/puppet/provider/gcompute_ssl_certificate/google.rb +++ b/lib/puppet/provider/gcompute_ssl_certificate/google.rb @@ -107,11 +107,7 @@ def flush debug('flush') # return on !@dirty is for aiding testing (puppet already guarantees that) return if @created || @deleted || !@dirty - update_req = Google::Compute::Network::Put.new(self_link(@resource), - fetch_auth(@resource), - 'application/json', - resource_to_request) - @fetched = wait_for_operation update_req.send, @resource + raise 'SslCertificate cannot be edited.' end def dirty(field, from, to) diff --git a/lib/puppet/type/gcompute_ssl_certificate.rb b/lib/puppet/type/gcompute_ssl_certificate.rb index 6f4f1ef1..087b6d89 100644 --- a/lib/puppet/type/gcompute_ssl_certificate.rb +++ b/lib/puppet/type/gcompute_ssl_certificate.rb @@ -33,8 +33,9 @@ Puppet::Type.newtype(:gcompute_ssl_certificate) do @doc = <<-DOC - An SslCertificate resource. This resource provides a mechanism to upload an SSL key and - certificate to the load balancer to serve secure connections from the user. + An SslCertificate resource, used for HTTPS load balancing. This resource provides a mechanism + to upload an SSL key and certificate to the load balancer to serve secure connections from the + user. DOC autorequire(:gauth_credential) do @@ -91,7 +92,7 @@ end newproperty(:private_key, parent: Google::Compute::Property::String) do - desc 'The private key in PEM format.' + desc 'The write-only private key in PEM format.' end # Returns all properties that a provider can export to other resources diff --git a/spec/gcompute_ssl_certificate_provider_spec.rb b/spec/gcompute_ssl_certificate_provider_spec.rb index 88642ddd..425709e6 100644 --- a/spec/gcompute_ssl_certificate_provider_spec.rb +++ b/spec/gcompute_ssl_certificate_provider_spec.rb @@ -392,9 +392,11 @@ apply_with_error_check( <<-MANIFEST gcompute_ssl_certificate { 'title0': - ensure => absent, - project => 'test project#0 data', - credential => 'cred0', + ensure => absent, + certificate => 'test certificate#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } MANIFEST ).catalog.resource('Gcompute_ssl_certificate[title0]') @@ -424,10 +426,12 @@ apply_with_error_check( <<-MANIFEST gcompute_ssl_certificate { 'title0': - ensure => absent, - name => 'test name#0 data', - project => 'test project#0 data', - credential => 'cred0', + ensure => absent, + certificate => 'test certificate#0 data', + name => 'test name#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } MANIFEST ).catalog.resource('Gcompute_ssl_certificate[title0]') @@ -461,9 +465,11 @@ apply_with_error_check( <<-MANIFEST gcompute_ssl_certificate { 'title0': - ensure => absent, - project => 'test project#0 data', - credential => 'cred0', + ensure => absent, + certificate => 'test certificate#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } MANIFEST ).catalog.resource('Gcompute_ssl_certificate[title0]') @@ -495,10 +501,12 @@ apply_with_error_check( <<-MANIFEST gcompute_ssl_certificate { 'title0': - ensure => absent, - name => 'test name#0 data', - project => 'test project#0 data', - credential => 'cred0', + ensure => absent, + certificate => 'test certificate#0 data', + name => 'test name#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } MANIFEST ).catalog.resource('Gcompute_ssl_certificate[title0]') diff --git a/spec/gcompute_target_https_proxy_provider_spec.rb b/spec/gcompute_target_https_proxy_provider_spec.rb index 10ecb869..c5280611 100644 --- a/spec/gcompute_target_https_proxy_provider_spec.rb +++ b/spec/gcompute_target_https_proxy_provider_spec.rb @@ -69,24 +69,30 @@ apply_with_error_check( <<-MANIFEST gcompute_ssl_certificate { 'resource(ssl_certificate,0)': - ensure => present, - name => 'test name#0 data', - project => 'test project#0 data', - credential => 'cred0', + ensure => present, + certificate => 'test certificate#0 data', + name => 'test name#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } gcompute_ssl_certificate { 'resource(ssl_certificate,1)': - ensure => present, - name => 'test name#1 data', - project => 'test project#1 data', - credential => 'cred1', + ensure => present, + certificate => 'test certificate#1 data', + name => 'test name#1 data', + private_key => 'test private_key#1 data', + project => 'test project#1 data', + credential => 'cred1', } gcompute_ssl_certificate { 'resource(ssl_certificate,2)': - ensure => present, - name => 'test name#2 data', - project => 'test project#2 data', - credential => 'cred2', + ensure => present, + certificate => 'test certificate#2 data', + name => 'test name#2 data', + private_key => 'test private_key#2 data', + project => 'test project#2 data', + credential => 'cred2', } gcompute_backend_service { 'resource(backend_service,0)': @@ -271,24 +277,30 @@ apply_with_error_check( <<-MANIFEST gcompute_ssl_certificate { 'resource(ssl_certificate,0)': - ensure => present, - name => 'test name#0 data', - project => 'test project#0 data', - credential => 'cred0', + ensure => present, + certificate => 'test certificate#0 data', + name => 'test name#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } gcompute_ssl_certificate { 'resource(ssl_certificate,1)': - ensure => present, - name => 'test name#1 data', - project => 'test project#1 data', - credential => 'cred1', + ensure => present, + certificate => 'test certificate#1 data', + name => 'test name#1 data', + private_key => 'test private_key#1 data', + project => 'test project#1 data', + credential => 'cred1', } gcompute_ssl_certificate { 'resource(ssl_certificate,2)': - ensure => present, - name => 'test name#2 data', - project => 'test project#2 data', - credential => 'cred2', + ensure => present, + certificate => 'test certificate#2 data', + name => 'test name#2 data', + private_key => 'test private_key#2 data', + project => 'test project#2 data', + credential => 'cred2', } gcompute_backend_service { 'resource(backend_service,0)': @@ -515,10 +527,12 @@ apply_with_error_check( <<-MANIFEST gcompute_ssl_certificate { 'resource(ssl_certificate,0)': - ensure => present, - name => 'test name#0 data', - project => 'test project#0 data', - credential => 'cred0', + ensure => present, + certificate => 'test certificate#0 data', + name => 'test name#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } gcompute_backend_service { 'resource(backend_service,0)': @@ -586,10 +600,12 @@ apply_with_error_check( <<-MANIFEST gcompute_ssl_certificate { 'resource(ssl_certificate,0)': - ensure => present, - name => 'test name#0 data', - project => 'test project#0 data', - credential => 'cred0', + ensure => present, + certificate => 'test certificate#0 data', + name => 'test name#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } gcompute_backend_service { 'resource(backend_service,0)': @@ -651,10 +667,12 @@ apply_with_error_check( <<-MANIFEST gcompute_ssl_certificate { 'resource(ssl_certificate,0)': - ensure => present, - name => 'test name#0 data', - project => 'test project#0 data', - credential => 'cred0', + ensure => present, + certificate => 'test certificate#0 data', + name => 'test name#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } gcompute_backend_service { 'resource(backend_service,0)': @@ -710,10 +728,12 @@ apply_with_error_check( <<-MANIFEST gcompute_ssl_certificate { 'resource(ssl_certificate,0)': - ensure => present, - name => 'test name#0 data', - project => 'test project#0 data', - credential => 'cred0', + ensure => present, + certificate => 'test certificate#0 data', + name => 'test name#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } gcompute_backend_service { 'resource(backend_service,0)': @@ -774,10 +794,12 @@ apply_with_error_check( <<-MANIFEST gcompute_ssl_certificate { 'resource(ssl_certificate,0)': - ensure => present, - name => 'test name#0 data', - project => 'test project#0 data', - credential => 'cred0', + ensure => present, + certificate => 'test certificate#0 data', + name => 'test name#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } gcompute_backend_service { 'resource(backend_service,0)': @@ -835,10 +857,12 @@ apply_with_error_check( <<-MANIFEST gcompute_ssl_certificate { 'resource(ssl_certificate,0)': - ensure => present, - name => 'test name#0 data', - project => 'test project#0 data', - credential => 'cred0', + ensure => present, + certificate => 'test certificate#0 data', + name => 'test name#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } gcompute_backend_service { 'resource(backend_service,0)': diff --git a/spec/gcompute_target_ssl_proxy_provider_spec.rb b/spec/gcompute_target_ssl_proxy_provider_spec.rb index 2835363a..7c2d6e52 100644 --- a/spec/gcompute_target_ssl_proxy_provider_spec.rb +++ b/spec/gcompute_target_ssl_proxy_provider_spec.rb @@ -87,24 +87,30 @@ } gcompute_ssl_certificate { 'resource(ssl_certificate,0)': - ensure => present, - name => 'test name#0 data', - project => 'test project#0 data', - credential => 'cred0', + ensure => present, + certificate => 'test certificate#0 data', + name => 'test name#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } gcompute_ssl_certificate { 'resource(ssl_certificate,1)': - ensure => present, - name => 'test name#1 data', - project => 'test project#1 data', - credential => 'cred1', + ensure => present, + certificate => 'test certificate#1 data', + name => 'test name#1 data', + private_key => 'test private_key#1 data', + project => 'test project#1 data', + credential => 'cred1', } gcompute_ssl_certificate { 'resource(ssl_certificate,2)': - ensure => present, - name => 'test name#2 data', - project => 'test project#2 data', - credential => 'cred2', + ensure => present, + certificate => 'test certificate#2 data', + name => 'test name#2 data', + private_key => 'test private_key#2 data', + project => 'test project#2 data', + credential => 'cred2', } gcompute_target_ssl_proxy { 'title0': @@ -262,24 +268,30 @@ } gcompute_ssl_certificate { 'resource(ssl_certificate,0)': - ensure => present, - name => 'test name#0 data', - project => 'test project#0 data', - credential => 'cred0', + ensure => present, + certificate => 'test certificate#0 data', + name => 'test name#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } gcompute_ssl_certificate { 'resource(ssl_certificate,1)': - ensure => present, - name => 'test name#1 data', - project => 'test project#1 data', - credential => 'cred1', + ensure => present, + certificate => 'test certificate#1 data', + name => 'test name#1 data', + private_key => 'test private_key#1 data', + project => 'test project#1 data', + credential => 'cred1', } gcompute_ssl_certificate { 'resource(ssl_certificate,2)': - ensure => present, - name => 'test name#2 data', - project => 'test project#2 data', - credential => 'cred2', + ensure => present, + certificate => 'test certificate#2 data', + name => 'test name#2 data', + private_key => 'test private_key#2 data', + project => 'test project#2 data', + credential => 'cred2', } gcompute_target_ssl_proxy { 'title0': @@ -467,10 +479,12 @@ } gcompute_ssl_certificate { 'resource(ssl_certificate,0)': - ensure => present, - name => 'test name#0 data', - project => 'test project#0 data', - credential => 'cred0', + ensure => present, + certificate => 'test certificate#0 data', + name => 'test name#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } gcompute_target_ssl_proxy { 'title0': @@ -529,10 +543,12 @@ } gcompute_ssl_certificate { 'resource(ssl_certificate,0)': - ensure => present, - name => 'test name#0 data', - project => 'test project#0 data', - credential => 'cred0', + ensure => present, + certificate => 'test certificate#0 data', + name => 'test name#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } gcompute_target_ssl_proxy { 'title0': @@ -585,10 +601,12 @@ } gcompute_ssl_certificate { 'resource(ssl_certificate,0)': - ensure => present, - name => 'test name#0 data', - project => 'test project#0 data', - credential => 'cred0', + ensure => present, + certificate => 'test certificate#0 data', + name => 'test name#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } gcompute_target_ssl_proxy { 'title0': @@ -635,10 +653,12 @@ } gcompute_ssl_certificate { 'resource(ssl_certificate,0)': - ensure => present, - name => 'test name#0 data', - project => 'test project#0 data', - credential => 'cred0', + ensure => present, + certificate => 'test certificate#0 data', + name => 'test name#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } gcompute_target_ssl_proxy { 'title0': @@ -690,10 +710,12 @@ } gcompute_ssl_certificate { 'resource(ssl_certificate,0)': - ensure => present, - name => 'test name#0 data', - project => 'test project#0 data', - credential => 'cred0', + ensure => present, + certificate => 'test certificate#0 data', + name => 'test name#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } gcompute_target_ssl_proxy { 'title0': @@ -742,10 +764,12 @@ } gcompute_ssl_certificate { 'resource(ssl_certificate,0)': - ensure => present, - name => 'test name#0 data', - project => 'test project#0 data', - credential => 'cred0', + ensure => present, + certificate => 'test certificate#0 data', + name => 'test name#0 data', + private_key => 'test private_key#0 data', + project => 'test project#0 data', + credential => 'cred0', } gcompute_target_ssl_proxy { 'title0':