diff --git a/GOVERNANCE.md b/GOVERNANCE.md index 92911be3a594..cb4875369cab 100644 --- a/GOVERNANCE.md +++ b/GOVERNANCE.md @@ -287,15 +287,15 @@ to remind you where they belong improves readability <% objects.each do |obj| -%> ... - <% if obj.virtual -%> + <% if obj.readonly -%> ... ... many lines later ... - <% elsif !obj.virtual && obj.broken -%> + <% elsif !obj.readonly && obj.broken -%> ... ... many lines later ... - <% end # if obj.virtual -%> + <% end # if obj.readonly -%> ... ... many lines later ... @@ -311,14 +311,14 @@ the example below it is easier to note the if is inside the `each` and there are <% objects.each do |obj| -%> ... - <% if obj.virtual -%> + <% if obj.readonly -%> ... <% if obj.input -%> ... ... many lines later ... <% end # if obj.input -%> - <% end # if obj.virtual -%> + <% end # if obj.readonly -%> ... ... many lines later ... @@ -328,14 +328,14 @@ the example below it is easier to note the if is inside the `each` and there are <% objects.each do |obj| -%> ... - <% if obj.virtual -%> + <% if obj.readonly -%> ... <% if obj.input -%> ... ... many lines later ... <% end # if obj.input -%> - <% end # if obj.virtual -%> + <% end # if obj.readonly -%> ... ... many lines later ... @@ -417,8 +417,8 @@ phases. **Good** <%= - # List all virtual properties that are not nested objects alphabetically - lines(object.all_properties.select(&:virtual) + # List all readonly properties that are not nested objects alphabetically + lines(object.all_properties.select(&:readonly) .reject { |p| p.is_a?(Api::Type::NestedObject) } .sort .map { |p| "- #{p.out_name}" }) @@ -427,12 +427,12 @@ phases. **Bad** <% - # List all virtual properties that are not nested objects alphabetically + # List all readonly properties that are not nested objects alphabetically my_properties = [] object.all_proerties.each do |p| - if p.virtual && !p.is_a?(Api::Type::NestedObject) + if p.readonly && !p.is_a?(Api::Type::NestedObject) my_properties << p - end # p.virtual + end # p.readonly end # object...each %> <% my_properties.sort.each do |p| -%> diff --git a/api/resource.rb b/api/resource.rb index 0abc79d6f79b..0d33dd821bf7 100644 --- a/api/resource.rb +++ b/api/resource.rb @@ -42,7 +42,6 @@ module Properties # If empty, we assume that `name` is the identifier. attr_reader :identity attr_reader :exclude - attr_reader :virtual attr_reader :async attr_reader :readonly attr_reader :exports @@ -235,7 +234,6 @@ def validate check_optional_property :exports, Array check_optional_property :self_link, String check_optional_property :self_link_query, Api::Resource::ResponseList - check_optional_property :virtual, :boolean check_optional_property :readonly, :boolean check_optional_property :label_override, String check_optional_property :transport, Transport diff --git a/build/chef/compute b/build/chef/compute index 7eda9402d2a9..34d43bee5bd8 160000 --- a/build/chef/compute +++ b/build/chef/compute @@ -1 +1 @@ -Subproject commit 7eda9402d2a9a86323e0c765b1d3801c7382dc7c +Subproject commit 34d43bee5bd8de99de7f76177a702c32adb2fa6e diff --git a/build/chef/sql b/build/chef/sql index df2a7589ac09..ae9cb77eb0a2 160000 --- a/build/chef/sql +++ b/build/chef/sql @@ -1 +1 @@ -Subproject commit df2a7589ac097086bd923e4edf860826daae8d2f +Subproject commit ae9cb77eb0a27d376fb54cc21ddc9e277cfad7c1 diff --git a/build/puppet/compute b/build/puppet/compute index 05f91d1264d8..518670c10c34 160000 --- a/build/puppet/compute +++ b/build/puppet/compute @@ -1 +1 @@ -Subproject commit 05f91d1264d8222f350c887396835fde9ac448d1 +Subproject commit 518670c10c34f365e133eaeb13a1f681750de138 diff --git a/build/puppet/sql b/build/puppet/sql index f52a273e15b3..63906e69a111 160000 --- a/build/puppet/sql +++ b/build/puppet/sql @@ -1 +1 @@ -Subproject commit f52a273e15b307eb94671e1d8408f1f45bc3030e +Subproject commit 63906e69a1111fdf8c04066664b4cb32e0e9a2b1 diff --git a/products/_bundle/templates/ansible/lookup.erb b/products/_bundle/templates/ansible/lookup.erb index 16acff225e5a..abb2b5500a66 100644 --- a/products/_bundle/templates/ansible/lookup.erb +++ b/products/_bundle/templates/ansible/lookup.erb @@ -28,13 +28,13 @@ options: default: null choices: <% - # Looking for virtual objects that export for ResourceRefs - virtuals = products.map { |product, _| product.objects } + # Looking for readonly objects that export for ResourceRefs + readonlys = products.map { |product, _| product.objects } .flatten - .select(&:virtual) + .select(&:readonly) .reject { |obj| obj.exports.nil? } -%> -<% virtuals.each do |virt| -%> +<% readonlys.each do |virt| -%> - <%= Google::StringUtils.underscore(virt.name) %> <% end -%> return: @@ -95,7 +95,7 @@ class GcpModule(object): raise AnsibleError(kwargs['msg']) -<% virtuals.each do |object| -%> +<% readonlys.each do |object| -%> <% prod_name = object.__product.prefix[1..-1] -%> @@ -153,14 +153,14 @@ class Gcp<%= object.name -%>(object): return response[<%= quote_string(default) -%>] -<% end # virtuals.each -%> +<% end # readonlys.each -%> class LookupModule(LookupBase): def run(self, terms, variables, **kwargs): self.set_options(var_options=variables, direct=kwargs) <% opts_code = [] - virtuals.each do |object| + readonlys.each do |object| name = Google::StringUtils.underscore(object.name) opts_code << "#{quote_string(name)}: Gcp#{object.name}" end diff --git a/products/compute/api.yaml b/products/compute/api.yaml index 7d26104e3167..14232bcea510 100644 --- a/products/compute/api.yaml +++ b/products/compute/api.yaml @@ -511,7 +511,7 @@ objects: # triggered for create. Implement support for read only objects, and delete # the virtual tag # | readonly: true - virtual: true + readonly: true exports: - !ruby/object:Api::Type::SelfLink name: 'selfLink' @@ -1516,7 +1516,7 @@ objects: name: 'License' kind: 'compute#license' base_url: /projects/{{project}}/global/licenses - virtual: true + readonly: true exports: - !ruby/object:Api::Type::SelfLink name: 'selfLink' @@ -2145,7 +2145,7 @@ objects: - 'name' - !ruby/object:Api::Type::SelfLink name: 'selfLink' - virtual: true + readonly: true description: | Represents a MachineType resource. Machine types determine the virtualized hardware specifications of your virtual machine instances, such as the @@ -2334,7 +2334,7 @@ objects: - name - !ruby/object:Api::Type::SelfLink name: 'selfLink' - virtual: true + readonly: true description: | Represents a Region resource. A region is a specific geographical location where you can run your resources. Each region has one or more @@ -3628,7 +3628,7 @@ objects: - name - !ruby/object:Api::Type::SelfLink name: 'selfLink' - virtual: true + readonly: true description: 'Represents a Zone resource.' properties: - !ruby/object:Api::Type::Time diff --git a/products/dns/api.yaml b/products/dns/api.yaml index 8baf3d955c3f..3de3a00fbe85 100644 --- a/products/dns/api.yaml +++ b/products/dns/api.yaml @@ -85,7 +85,7 @@ objects: A project resource. The project is a top level container for resources including Cloud DNS ManagedZones. base_url: 'projects' - virtual: true + readonly: true properties: - !ruby/object:Api::Type::Integer name: 'number' diff --git a/products/spanner/api.yaml b/products/spanner/api.yaml index 9903d9e4dc93..955565146330 100644 --- a/products/spanner/api.yaml +++ b/products/spanner/api.yaml @@ -30,7 +30,7 @@ objects: exports: - !ruby/object:Api::Type::FetchedExternal name: name - virtual: true + readonly: true transport: !ruby/object:Api::Resource::Transport encoder: encode_request decoder: decode_response diff --git a/products/sql/api.yaml b/products/sql/api.yaml index 80d8587c10aa..859130073948 100644 --- a/products/sql/api.yaml +++ b/products/sql/api.yaml @@ -400,7 +400,7 @@ objects: self_link: | projects/{{project}}/instances/{{instance}}/sslCerts/ {{sha1_fingerprint}} - virtual: true # we're not enforcing state as it is all server-side driven. + readonly: true # we're not enforcing state as it is all server-side driven. description: | Represents an SSL certificate created for a Cloud SQL instance. To use the SSL certificate you must have the SSL Client Certificate and the @@ -451,7 +451,7 @@ objects: self_link_query: !ruby/object:Api::Resource::ResponseList kind: 'sql#flagsList' items: 'items' - virtual: true + readonly: true properties: - !ruby/object:Api::Type::Array name: 'allowedStringValues' @@ -506,7 +506,7 @@ objects: items: 'items' identity: - tier - virtual: true + readonly: true parameters: - !ruby/object:Api::Type::String name: 'tier' diff --git a/provider/ansible.rb b/provider/ansible.rb index b28fa81ba97c..bd1919b40d92 100644 --- a/provider/ansible.rb +++ b/provider/ansible.rb @@ -76,7 +76,7 @@ def python_type(prop) prop = Module.const_get(prop).new('') unless prop.is_a?(Api::Type) # All ResourceRefs are dicts with properties. if prop.is_a? Api::Type::ResourceRef - return 'str' if prop.resource_ref.virtual + return 'str' if prop.resource_ref.readonly return 'dict' end PYTHON_TYPE_FROM_MM_TYPE.fetch(prop.class.to_s, 'str') @@ -181,7 +181,7 @@ def rrefs_in_link(link, object) props_in_link = link.scan(/{([a-z_]*)}/).flatten (object.parameters || []).select do |p| props_in_link.include?(Google::StringUtils.underscore(p.name)) && \ - p.is_a?(Api::Type::ResourceRef) && !p.resource_ref.virtual + p.is_a?(Api::Type::ResourceRef) && !p.resource_ref.readonly end.any? end @@ -192,7 +192,7 @@ def resourceref_hash_for_links(link, object) # Select a resourceref if it exists. rref = (object.parameters || []).select do |prop| Google::StringUtils.underscore(prop.name) == p && \ - prop.is_a?(Api::Type::ResourceRef) && !prop.resource_ref.virtual + prop.is_a?(Api::Type::ResourceRef) && !prop.resource_ref.readonly end if rref.any? [ @@ -217,10 +217,10 @@ def emit_link_var_args(url, extra_data) ].compact end - # Returns a list of all first-level ResourceRefs that are not virtual - def nonvirtual_rrefs(object) + # Returns a list of all first-level ResourceRefs that are not readonly + def nonreadonly_rrefs(object) object.all_resourcerefs - .reject { |prop| prop.resource_ref.virtual } + .reject { |prop| prop.resource_ref.readonly } end # Converts a path in the form a/b/c/d into ['a', 'b', 'c', 'd'] diff --git a/provider/ansible/request.rb b/provider/ansible/request.rb index 6e3888c025b2..332782ed15da 100644 --- a/provider/ansible/request.rb +++ b/provider/ansible/request.rb @@ -128,7 +128,7 @@ def request_output(prop, hash_name, module_name) "#{hash_name}.get(#{quote_string(prop.out_name)}, [])", ", #{module_name}).to_request()" ].join - elsif prop.is_a?(Api::Type::ResourceRef) && !prop.resource_ref.virtual + elsif prop.is_a?(Api::Type::ResourceRef) && !prop.resource_ref.readonly prop_name = Google::StringUtils.underscore(prop.name) [ "replace_resource_dict(#{hash_name}", @@ -136,7 +136,7 @@ def request_output(prop, hash_name, module_name) "#{quote_string(prop.imports)})" ].join elsif prop.is_a?(Api::Type::ResourceRef) && \ - prop.resource_ref.virtual && prop.imports == 'selfLink' + prop.resource_ref.readonly && prop.imports == 'selfLink' func = "#{Google::StringUtils.underscore(prop.resource)}_selflink" [ "#{func}(#{hash_name}.get(#{quote_string(prop.out_name)}),", @@ -144,7 +144,7 @@ def request_output(prop, hash_name, module_name) ].join(' ') elsif prop.is_a?(Api::Type::Array) && \ prop.item_type.is_a?(Api::Type::ResourceRef) && \ - !prop.item_type.resource_ref.virtual + !prop.item_type.resource_ref.readonly prop_name = Google::StringUtils.underscore(prop.name) [ "replace_resource_dict(#{hash_name}", diff --git a/provider/ansible/resourceref.rb b/provider/ansible/resourceref.rb index 0f2f18ef020f..54209dafda4d 100644 --- a/provider/ansible/resourceref.rb +++ b/provider/ansible/resourceref.rb @@ -26,7 +26,7 @@ module Ansible module ResourceRef # Builds out a list of statements that handle ResourceRef creation def resourceref_handlers(object) - rrefs = nonvirtual_rrefs(object) + rrefs = nonreadonly_rrefs(object) return unless rrefs.any? comments = [ '# Converts data from:', diff --git a/provider/ansible/selflink.rb b/provider/ansible/selflink.rb index 95d04c3d8bfd..7d3a57b99ee9 100644 --- a/provider/ansible/selflink.rb +++ b/provider/ansible/selflink.rb @@ -20,25 +20,25 @@ module Provider module Ansible # Responsible for building out all logic for checking + assembling selflinks - # on Ansible virtual properties. + # on Ansible readonly properties. # - # Some virtual properties (regions, zones) will probably be entered as + # Some readonly properties (regions, zones) will probably be entered as # names by users (that's most intuitive). If a self-link is required, # the module should assemble that itself. module SelfLink - # Returns all rrefs that are virtual and require selflinks. - def virtual_selflink_rrefs(object) + # Returns all rrefs that are readonly and require selflinks. + def readonly_selflink_rrefs(object) object.all_resourcerefs - .select { |prop| prop.resource_ref.virtual } + .select { |prop| prop.resource_ref.readonly } .select { |prop| prop.imports == 'selfLink' } end # Build out functions that will check + create selflinks. def selflink_functions(object) - virtuals = virtual_selflink_rrefs(object).map(&:resource_ref) - .uniq - virtuals.map do |virt| - if virt == virtuals.last + readonlys = readonly_selflink_rrefs(object).map(&:resource_ref) + .uniq + readonlys.map do |virt| + if virt == readonlys.last lines(selflink_function(virt)) else lines(selflink_function(virt), 1) diff --git a/provider/puppet/test_manifest.rb b/provider/puppet/test_manifest.rb index 59f5827ed3fd..7ecc7678f999 100644 --- a/provider/puppet/test_manifest.rb +++ b/provider/puppet/test_manifest.rb @@ -47,8 +47,8 @@ def generate_object(object, title, kind, seed, extra) credential: "'cred#{seed}'" }.merge(extra) - # Puppet does not like when virtual resources have an ensure property - extra.delete(:ensure) if object.virtual + # Puppet does not like when readonly resources have an ensure property + extra.delete(:ensure) if object.readonly [ "#{object.out_name} { '#{title}':", diff --git a/templates/ansible/example.erb b/templates/ansible/example.erb index a09b1c323741..ca3c604973de 100644 --- a/templates/ansible/example.erb +++ b/templates/ansible/example.erb @@ -11,26 +11,26 @@ <% resource_name = Google::StringUtils.uncombine(object.name).downcase -%> <%= lines(example.task.build_test('present', object, false)) -%> register: result -<% if object.virtual -%> +<% if object.readonly -%> - name: assert changed is false -<% else # if object.virtual -%> +<% else # if object.readonly -%> - name: assert changed is true -<% end # if object.virtual -%> +<% end # if object.readonly -%> assert: that: -<% if object.virtual -%> +<% if object.readonly -%> # <%= object.name -%> is not altered, just verified. - result.changed == false -<% else # if object.virtual -%> +<% else # if object.readonly -%> - result.changed == true -<% end # if object.virtual -%> +<% end # if object.readonly -%> <% if object.kind? -%> - "result.kind == <%= quote_string(object.kind) -%>" <% end # if object.kind -%> <% unless example.verifier.nil? -%> <%= lines(example.verifier.build_task('present', object)) -%> <% end -%> -<% unless object.virtual -%> +<% unless object.readonly -%> # ---------------------------------------------------------------------------- <%= lines(example.task.build_test('present', object, true)) -%> register: result @@ -64,7 +64,7 @@ <% if object.kind? -%> - result.has_key('kind') == False <% end # if object.kind? -%> -<% end # object.virtual -%> +<% end # object.readonly -%> <% if example.dependencies and !example.dependencies.empty? -%> #--------------------------------------------------------- # Post-test teardown diff --git a/templates/ansible/resource.erb b/templates/ansible/resource.erb index 172bc542a846..3a1939c29ac9 100644 --- a/templates/ansible/resource.erb +++ b/templates/ansible/resource.erb @@ -79,14 +79,14 @@ RETURN = ''' <% import = 'from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest' import += ', remove_nones_from_dict' unless properties_with_classes(object.all_user_properties).empty? - import += ', replace_resource_dict' if nonvirtual_rrefs(object) + import += ', replace_resource_dict' if nonreadonly_rrefs(object) -%> <%= lines(import) -%> import json <% imports = object.imports || [] imports << 'time' if object.async - imports << 're' unless virtual_selflink_rrefs(object).empty? + imports << 're' unless readonly_selflink_rrefs(object).empty? -%> <%= lines(imports.sort.uniq.map { |i| "import #{i}" }) -%> @@ -131,10 +131,10 @@ def main(): '<%= object.self_link_query.items -%>') <% end # object.self_link_query.nil? -%> changed = False -<% if object.virtual -%> +<% if object.readonly -%> if not fetch: module.fail_json(msg="<%= object.name -%> is not valid") -<% else # object.virtual -%> +<% else # object.readonly -%> if fetch: if state == 'present': @@ -178,13 +178,13 @@ def main(): fetch = {} fetch.update({'changed': changed}) -<% end # object.virtual -%> +<% end # object.readonly -%> module.exit_json(**fetch) <% prod_name = object.__product.prefix[1..-1] -%> -<% unless object.virtual -%> +<% unless object.readonly -%> <%# TODO: kind param not always needed. # https://github.com/GoogleCloudPlatform/magic-modules/issues/45 -%> @@ -277,7 +277,7 @@ def main(): <% end # if object.delete.nil? -%> -<% end # unless object.virtual -%> +<% end # unless object.readonly -%> def resource_to_request(module): <% properties_in_request = [ diff --git a/templates/chef/resource_spec.erb b/templates/chef/resource_spec.erb index 171f6c4e722c..d9c6278bbffb 100644 --- a/templates/chef/resource_spec.erb +++ b/templates/chef/resource_spec.erb @@ -40,7 +40,7 @@ require 'spec_helper' # TODO(alexstephen): Add tests for manage # TODO(alexstephen): Add tests for modify <% -if object.virtual +if object.readonly test_matrix = Provider::TestMatrix.new(template, object, self, exists: { changes: [ # read-only object mistmatch @@ -95,7 +95,7 @@ prop_data = Provider::TestData::Expectations.new(self, @data_gen) catalogger = Provider::ChefTestCatalogFormatter.new self -%> context '<%= object.out_name -%>' do -<% if object.virtual -%> +<% if object.readonly -%> <% # Object does NOT provides 'ensure' parameter -%> <%= test_matrix.push(:ignore, :exists) -%> <%= test_matrix.push(:ignore, :exists, :no_change) -%> diff --git a/templates/network_mocks.erb b/templates/network_mocks.erb index 351ea0c901f3..017f025f2b07 100644 --- a/templates/network_mocks.erb +++ b/templates/network_mocks.erb @@ -72,7 +72,7 @@ def http_failed_object_missing Net::HTTPNotFound.new(1.0, 404, 'Not Found') end <% end -%> -<% unless object.virtual -%> +<% unless object.readonly -%> <% if !true?(Google::HashUtils.navigate(tests, %w[expectations custom create])) -%> diff --git a/templates/puppet/provider.erb b/templates/puppet/provider.erb index cd636aac1db4..637c401d837d 100644 --- a/templates/puppet/provider.erb +++ b/templates/puppet/provider.erb @@ -211,7 +211,7 @@ Puppet::Type.type(:<%= object.out_name -%>).provide(:google) do f2h_code, file_relative), 2), 1) -%> <%= lines(get_code_multiline(config, 'constructor')) -%> -<% unless object.virtual -%> +<% unless object.readonly -%> def exists? debug("exists? #{@property_hash[:ensure] == :present}") @property_hash[:ensure] == :present diff --git a/templates/puppet/provider_spec.erb b/templates/puppet/provider_spec.erb index 4f95755b7b0a..63ec9d77a0b9 100644 --- a/templates/puppet/provider_spec.erb +++ b/templates/puppet/provider_spec.erb @@ -19,7 +19,7 @@ require 'spec_helper' <% -if object.virtual +if object.readonly test_matrix = Provider::TestMatrix.new(template, object, self, exists: { changes: [ # read-only object mistmatch @@ -94,7 +94,7 @@ manifester = Provider::PuppetTestManifestFormatter.new self /not supported/) end -<% if object.virtual -%> +<% if object.readonly -%> <% # Object does NOT provides 'ensure' parameter -%> <%= test_matrix.push(:ignore, :exists) -%> <%= test_matrix.push(:ignore, :exists, :no_change) -%> @@ -309,7 +309,7 @@ manifester = Provider::PuppetTestManifestFormatter.new self context '#flush' do subject do Puppet::Type.type(:<%= object.out_name -%>).new( -<% unless object.virtual -%> +<% unless object.readonly -%> ensure: :present, <% end -%> name: 'my-name' @@ -343,7 +343,7 @@ manifester = Provider::PuppetTestManifestFormatter.new self -%> def create_type(id) Puppet::Type.type(:<%= object.out_name -%>).new( -<% unless object.virtual -%> +<% unless object.readonly -%> ensure: :present, <% end -%> <% diff --git a/templates/puppet/type.erb b/templates/puppet/type.erb index 5e2e49b088a9..c96dc4281286 100644 --- a/templates/puppet/type.erb +++ b/templates/puppet/type.erb @@ -68,7 +68,7 @@ Puppet::Type.newtype(:<%= object.out_name -%>) do end end -%> -<% unless object.virtual -%> +<% unless object.readonly -%> ensurable <% end -%> diff --git a/tools/end2end/chef_test_templates.rb b/tools/end2end/chef_test_templates.rb index 065060d8f7f3..28ef03329e69 100644 --- a/tools/end2end/chef_test_templates.rb +++ b/tools/end2end/chef_test_templates.rb @@ -193,7 +193,7 @@ def setup_hash(item) end end - # A template for a test that follows the virtual test workflow: + # A template for a test that follows the readonly test workflow: # # @pre # - create @@ -210,7 +210,7 @@ def build_plan file = Google::StringUtils.underscore(@resource_name || @name) resources = @resource_count || 2 # 1=resource + 1=auth - affected = @affected_count || 0 # virtual resources are never updated. + affected = @affected_count || 0 # readonly resources are never updated. changed_resource = \ "Chef Client finished, #{affected}/#{resources} resources updated" create_name = @create || "tests~#{file}" diff --git a/tools/end2end/puppet_test_templates.rb b/tools/end2end/puppet_test_templates.rb index fa4c427bb30f..32a76a918e28 100644 --- a/tools/end2end/puppet_test_templates.rb +++ b/tools/end2end/puppet_test_templates.rb @@ -87,7 +87,7 @@ def build_plan # rubocop:enable Metrics/MethodLength end - # A template for a test that follows the virtual test workflow: + # A template for a test that follows the readonly test workflow: # # @pre # - run