From 4d42f8ec2a2660551990d53ff2948ec4591fd148 Mon Sep 17 00:00:00 2001 From: Riley Karson Date: Wed, 8 Feb 2023 10:31:04 -0800 Subject: [PATCH] Remove Ansible references throughout the repo (#7218) --- .github/ISSUE_TEMPLATE/config.yml | 8 -- .gitignore | 5 +- docs/content/docs/getting-started/setup.md | 2 +- mmv1/TUTORIAL.md | 109 --------------------- mmv1/api/resource/nested_query.rb | 6 -- mmv1/compile/core.rb | 8 -- mmv1/compiler.rb | 4 +- mmv1/products/activedirectory/api.yaml | 1 - mmv1/products/bigtable/api.yaml | 97 ------------------ mmv1/products/bigtable/terraform.yaml | 3 - mmv1/products/dns/api.yaml | 1 - mmv1/products/resourcemanager/api.yaml | 1 - mmv1/products/serviceusage/api.yaml | 2 - mmv1/products/sql/api.yaml | 3 - mmv1/products/tags/api.yaml | 2 - mmv1/provider/core.rb | 23 ++--- mmv1/provider/file_template.rb | 3 - 17 files changed, 11 insertions(+), 267 deletions(-) delete mode 100644 mmv1/TUTORIAL.md diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 848a85eaa31e..17c0b688fe0a 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -4,11 +4,3 @@ contact_links: url: https://github.com/hashicorp/terraform-provider-google/issues/new/choose about: | Terraform-specific issues or FRs - - name: Ansible Issue - url: https://github.com/ansible-collections/google.cloud/issues/new/choose - about: | - Ansible-specific issues or FRs - - name: InSpec Issue - url: https://github.com/inspec/inspec-gcp/issues/new/choose - about: | - InSpec-specific issues or FRs diff --git a/.gitignore b/.gitignore index dc68682c18ef..76a5461db4c2 100644 --- a/.gitignore +++ b/.gitignore @@ -38,9 +38,6 @@ ehthumbs.db Thumbs.db final_api.yaml -# Ansible PR Script -mmv1/tools/ansible-pr/templates/* -!mmv1/tools/ansible-pr/templates/.keep # Used by OiCS tutorial mmv1/build/* @@ -54,4 +51,4 @@ mmv1/build/* # ignore serialization generation build data tpgtools/temp.serial -tpgtools/serialization.go \ No newline at end of file +tpgtools/serialization.go diff --git a/docs/content/docs/getting-started/setup.md b/docs/content/docs/getting-started/setup.md index 8c412b18b7f2..050fdbd61de3 100644 --- a/docs/content/docs/getting-started/setup.md +++ b/docs/content/docs/getting-started/setup.md @@ -108,4 +108,4 @@ Check for git in path... ## Test your setup -Try [generating the providers](/magic-modules/docs/getting-started/generate-providers/). If your environment is set up correctly, it should succeed with no errors! \ No newline at end of file +Try [generating the providers](/magic-modules/docs/getting-started/generate-providers/). If your environment is set up correctly, it should succeed with no errors! diff --git a/mmv1/TUTORIAL.md b/mmv1/TUTORIAL.md deleted file mode 100644 index e338feaa7df8..000000000000 --- a/mmv1/TUTORIAL.md +++ /dev/null @@ -1,109 +0,0 @@ - -# Magic Modules Tutorial - - - - -## Intro - -This tutorial will walk you through the components that make up Magic Modules. - -## api.yaml - -Each product's api definition is stored in the magic-modules repo. - -Let's open - -. - -### Product Metadata - -The - - -provides metadata about the API, such as name, scopes, and versions. - -### Resources - -Each `api.yaml` file contains a list of resources. A resource is an item in that product, -such as a PubSub Subscription, a Compute Instance, or a GKE Cluster. -Let's - - -the first one. - -This section contains data about the resource, such as its name, description, and URLs. - -### Properties - -Each resource contains a list of - - -on the resource that a user might set when creating the resource, or access when reading it. - -See the [property type fields](https://github.com/GoogleCloudPlatform/magic-modules/blob/main/mmv1/api/resource.rb#L22) -for more information about the values that can be set on properties. - -All of this information comes from the PubSub Subscription [REST API docs](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions) - -## [provider].yaml - -Within each product directory, each provider has its own `[provider].yaml` file to set information -specific to that provider. - -Let's look at - -. - -This file consists of information that is specific to Ansible, like Ansible version numbers, -helper code, and additional files to include. - -## Making Changes - -To add a new API or resource, the only files that need to be modified are `api.yaml`, each -`[provider].yaml`, and any custom code or provider-specific extras. - -Let's actually make a change. Go back to - - - -We're going to add in the Topic Resource now. - -## Compiling magic-modules - -Now, let's compile those changes. - -Since we're running in Cloud Shell, this command will make sure we connect to GitHub via HTTPS -instead of SSH. You will probably not have to do this in your typical development environment. - -Run the compiler: -```bash -ruby compiler.rb -p products/pubsub -e ansible -o build/ansible -``` - -This command tells us to run the compiler for the pubsub API, and generate Ansible into the -`build/ansible/plugins/modules` directory. - -Let's see our changes! Navigate to the Ansible folder -```bash -cd build/ansible/plugins/modules/ -// view gcp_pubsub_topic.py in editor of your choice. -``` - -## Congratulations! - - - -You've successfully made a change to a resource in Magic Modules. diff --git a/mmv1/api/resource/nested_query.rb b/mmv1/api/resource/nested_query.rb index ea9970c9a965..b6b30ecc55db 100644 --- a/mmv1/api/resource/nested_query.rb +++ b/mmv1/api/resource/nested_query.rb @@ -44,18 +44,12 @@ class NestedQuery < Api::Object # } attr_reader :modify_by_patch - # Nested resources generally don't have a kind field. - # This is used as a (potentially unnecessary) placeholder by Ansible - attr_reader :kind - def validate super check :keys, type: Array, item_type: String, required: true check :is_list_of_ids, type: :boolean, default: false check :modify_by_patch, type: :boolean, default: false - - check :kind, type: String end end end diff --git a/mmv1/compile/core.rb b/mmv1/compile/core.rb index 883e0c5e53e5..c612b5f387d2 100644 --- a/mmv1/compile/core.rb +++ b/mmv1/compile/core.rb @@ -132,14 +132,6 @@ def compile(file, caller_frame = 1) raise end - def ansible_style_yaml(obj, options = {}) - if obj.is_a?(::Hash) - obj.reject { |_, v| v.nil? }.to_yaml(options).sub("---\n", '') - else - obj.to_yaml(options).sub("---\n", '') - end - end - # Compiles a ERB template from a file. # # Arguments: diff --git a/mmv1/compiler.rb b/mmv1/compiler.rb index b6d17ee9054b..7cfd5aeb641e 100755 --- a/mmv1/compiler.rb +++ b/mmv1/compiler.rb @@ -14,9 +14,7 @@ $LOAD_PATH.unshift File.dirname(__FILE__) -# Run from compiler dir so all references are relative to the compiler -# executable. This allows the following command line: -# ruby compiler.rb -p products/compute -e ansible -o build/ansible +# Run from compiler dir so all references are relative to compiler.rb Dir.chdir(File.dirname(__FILE__)) # Our default timezone is UTC, to avoid local time compromise test code seed diff --git a/mmv1/products/activedirectory/api.yaml b/mmv1/products/activedirectory/api.yaml index 2e47028759dd..0133b1f0b6a7 100644 --- a/mmv1/products/activedirectory/api.yaml +++ b/mmv1/products/activedirectory/api.yaml @@ -194,7 +194,6 @@ objects: identity: - targetDomainName nested_query: !ruby/object:Api::Resource::NestedQuery - kind: 'domain#trustList' keys: ['trusts'] async: !ruby/object:Api::OpAsync operation: !ruby/object:Api::OpAsync::Operation diff --git a/mmv1/products/bigtable/api.yaml b/mmv1/products/bigtable/api.yaml index c4e933c94d58..f87f06f2e6f5 100644 --- a/mmv1/products/bigtable/api.yaml +++ b/mmv1/products/bigtable/api.yaml @@ -92,100 +92,3 @@ objects: description: | If true, CheckAndMutateRow and ReadModifyWriteRow requests are allowed by this app profile. It is unsafe to send these requests to the same table/row/column in multiple clusters. - - !ruby/object:Api::Resource - name: Instance - base_url: projects/{{project}}/instances - description: | - A collection of Bigtable Tables and the resources that serve them. All - tables in an instance are served from all Clusters in the instance. - async: !ruby/object:Api::OpAsync - actions: ['create'] - operation: !ruby/object:Api::OpAsync::Operation - path: 'name' - # TODO: change this to be less Pythonic. - # Only Ansible uses this, so it's alright for now. - base_url: "operations/{module.params['clusters'][0]['location']}/{{op_id}}" - wait_ms: 1000 - result: !ruby/object:Api::OpAsync::Result - path: 'response' - resource_inside_response: true - status: !ruby/object:Api::OpAsync::Status - path: 'done' - complete: True - allowed: - - True - - False - error: !ruby/object:Api::OpAsync::Error - path: 'error' - message: 'message' - properties: - - !ruby/object:Api::Type::Enum - name: state - description: The current state of the instance. - values: - - :STATE_NOT_KNOWN - - :READY - - :CREATING - output: true - - !ruby/object:Api::Type::String - name: name - description: The unique name of the instance. - - !ruby/object:Api::Type::String - name: displayName - description: | - The descriptive name for this instance as it appears in UIs. - Can be changed at any time, but should be kept globally unique - to avoid confusion. - - !ruby/object:Api::Type::Enum - name: type - description: The type of the instance. Defaults to `PRODUCTION`. - values: - - :TYPE_UNSPECIFIED - - :PRODUCTION - - :DEVELOPMENT - - !ruby/object:Api::Type::KeyValuePairs - name: labels - description: | - Labels are a flexible and lightweight mechanism for organizing cloud - resources into groups that reflect a customer's organizational needs and - deployment strategies. They can be used to filter resources and aggregate - metrics. - - !ruby/object:Api::Type::Array - name: clusters - description: An array of clusters. Maximum 4. - item_type: !ruby/object:Api::Type::NestedObject - properties: - - !ruby/object:Api::Type::String - name: name - description: The unique name of the cluster. - - !ruby/object:Api::Type::Integer - name: serveNodes - description: | - The number of nodes allocated to this cluster. More nodes enable higher - throughput and more consistent performance. - - !ruby/object:Api::Type::Enum - name: defaultStorageType - description: | - The type of storage used by this cluster to serve its - parent instance's tables, unless explicitly overridden. - values: - - :STORAGE_TYPE_UNSPECIFIED - - :SSD - - :HDD - - !ruby/object:Api::Type::String - name: location - description: | - The location where this cluster's nodes and storage reside. For best - performance, clients should be located as close as possible to this - cluster. Currently only zones are supported, so values should be of the - form `projects//locations/`. - - !ruby/object:Api::Type::Enum - name: state - description: The current state of the cluster. - values: - - :STATE_NOT_KNOWN - - :READY - - :CREATING - - :RESIZING - - :DISABLED - output: true diff --git a/mmv1/products/bigtable/terraform.yaml b/mmv1/products/bigtable/terraform.yaml index d6eee93fd449..ca77b00ee102 100644 --- a/mmv1/products/bigtable/terraform.yaml +++ b/mmv1/products/bigtable/terraform.yaml @@ -13,9 +13,6 @@ --- !ruby/object:Provider::Terraform::Config overrides: !ruby/object:Overrides::ResourceOverrides - Instance: !ruby/object:Overrides::Terraform::ResourceOverride - exclude_resource: true - exclude: true AppProfile: !ruby/object:Overrides::Terraform::ResourceOverride id_format: "projects/{{project}}/instances/{{instance}}/appProfiles/{{app_profile_id}}" import_format: ["projects/{{project}}/instances/{{instance}}/appProfiles/{{app_profile_id}}"] diff --git a/mmv1/products/dns/api.yaml b/mmv1/products/dns/api.yaml index 167bdb0290e8..02b9efe91c02 100644 --- a/mmv1/products/dns/api.yaml +++ b/mmv1/products/dns/api.yaml @@ -471,7 +471,6 @@ objects: base_url: 'projects/{{project}}/managedZones/{{managed_zone}}/changes' self_link: 'projects/{{project}}/managedZones/{{managed_zone}}/rrsets?name={{name}}&type={{type}}' nested_query: !ruby/object:Api::Resource::NestedQuery - kind: 'dns#resourceRecordSetsListResponse' keys: ['rrsets'] collection_url_key: 'rrsets' identity: diff --git a/mmv1/products/resourcemanager/api.yaml b/mmv1/products/resourcemanager/api.yaml index e0f65f90dc41..031ed78429fa 100644 --- a/mmv1/products/resourcemanager/api.yaml +++ b/mmv1/products/resourcemanager/api.yaml @@ -121,7 +121,6 @@ objects: # of where that happens. self_link: liens?parent={{parent}} nested_query: !ruby/object:Api::Resource::NestedQuery - kind: 'resourceManager#liensList' keys: - liens identity: diff --git a/mmv1/products/serviceusage/api.yaml b/mmv1/products/serviceusage/api.yaml index 3a7cc46195bb..82d7a7f98965 100644 --- a/mmv1/products/serviceusage/api.yaml +++ b/mmv1/products/serviceusage/api.yaml @@ -42,7 +42,6 @@ objects: 'Getting Started': 'https://cloud.google.com/service-usage/docs/manage-quota#create_consumer_quota_override' 'REST API documentation': 'https://cloud.google.com/service-usage/docs/reference/rest/v1beta1/services.consumerQuotaMetrics.limits.adminOverrides' nested_query: !ruby/object:Api::Resource::NestedQuery - kind: 'serviceusage#overridesList' keys: - overrides identity: @@ -132,7 +131,6 @@ objects: 'Getting Started': 'https://cloud.google.com/service-usage/docs/getting-started' 'REST API documentation': 'https://cloud.google.com/service-usage/docs/reference/rest/v1beta1/services.consumerQuotaMetrics.limits.consumerOverrides' nested_query: !ruby/object:Api::Resource::NestedQuery - kind: 'serviceusage#overridesList' keys: - overrides identity: diff --git a/mmv1/products/sql/api.yaml b/mmv1/products/sql/api.yaml index fdceb4baa801..0f1b4a0034b3 100644 --- a/mmv1/products/sql/api.yaml +++ b/mmv1/products/sql/api.yaml @@ -514,7 +514,6 @@ objects: base_url: projects/{{project}}/instances/{{instance}}/users self_link: 'projects/{{project}}/instances/{{instance}}/users?name={{name}}&host={{host}}' nested_query: !ruby/object:Api::Resource::NestedQuery - kind: 'sql#usersList' keys: ['items'] collection_url_key: 'items' identity: @@ -602,7 +601,6 @@ objects: base_url: flags self_link: flags nested_query: !ruby/object:Api::Resource::NestedQuery - kind: 'sql#flagsList' keys: ['items'] readonly: true properties: @@ -655,7 +653,6 @@ objects: base_url: projects/{{project}}/tiers self_link: projects/{{project}}/tiers nested_query: !ruby/object:Api::Resource::NestedQuery - kind: 'sql#tiersList' keys: ['items'] identity: - tier diff --git a/mmv1/products/tags/api.yaml b/mmv1/products/tags/api.yaml index 0a57faa68b5b..3135279fb33d 100644 --- a/mmv1/products/tags/api.yaml +++ b/mmv1/products/tags/api.yaml @@ -180,7 +180,6 @@ objects: self_link: "tagBindings/?parent={{parent}}&pageSize=300" delete_url: "tagBindings/{{name}}" nested_query: !ruby/object:Api::Resource::NestedQuery - kind: 'tags#tagBindingList' keys: ['tagBindings'] input: true description: A TagBinding represents a connection between a TagValue and a cloud resource (currently project, folder, or organization). Once a TagBinding is created, the TagValue is applied to all the descendants of the cloud resource. @@ -205,4 +204,3 @@ objects: description: | The TagValue of the TagBinding. Must be of the form tagValues/456. required: true - \ No newline at end of file diff --git a/mmv1/provider/core.rb b/mmv1/provider/core.rb index 62205c790ffe..01f2e1065c8c 100644 --- a/mmv1/provider/core.rb +++ b/mmv1/provider/core.rb @@ -257,25 +257,18 @@ def field_specific_update_methods(properties) # Filter the properties to keep only the ones requiring custom update # method and group them by update url & verb. - def properties_by_custom_update(properties, behavior = :new) + def properties_by_custom_update(properties) update_props = properties.reject do |p| p.update_url.nil? || p.update_verb.nil? || p.update_verb == :NOOP end - # TODO(rambleraptor): Add support to Ansible for one-at-a-time updates. - if behavior == :old - update_props.group_by do |p| - { update_url: p.update_url, update_verb: p.update_verb, fingerprint: p.fingerprint_name } - end - else - update_props.group_by do |p| - { - update_url: p.update_url, - update_verb: p.update_verb, - update_id: p.update_id, - fingerprint_name: p.fingerprint_name - } - end + update_props.group_by do |p| + { + update_url: p.update_url, + update_verb: p.update_verb, + update_id: p.update_id, + fingerprint_name: p.fingerprint_name + } end end diff --git a/mmv1/provider/file_template.rb b/mmv1/provider/file_template.rb index 1f1cc2df3195..836946f97da9 100644 --- a/mmv1/provider/file_template.rb +++ b/mmv1/provider/file_template.rb @@ -55,9 +55,6 @@ def generate(pwd, template, path, provider) ctx.local_variable_set(name[1..-1], instance_variable_get(name)) end - # This variable is used in ansible/resource.erb - ctx.local_variable_set('file_relative', - relative_path(@output_folder + '/' + path, @output_folder).to_s) ctx.local_variable_set('pwd', pwd) # check if the parent folder exists, and make it if not