From 3bf4df05f506bbacc0b3f3f290aaf023397a0d76 Mon Sep 17 00:00:00 2001 From: "Stephen Lewis (Burrows)" Date: Fri, 24 Jan 2025 14:18:29 -0800 Subject: [PATCH] Removed trailing ruby files (#12852) --- mmv1/.rubocop.yml | 57 --- mmv1/.ruby-version | 1 - mmv1/Gemfile | 12 - mmv1/Gemfile.lock | 64 ---- mmv1/Rakefile | 27 -- .../terraform/resource_iam.html.markdown.erb | 324 ------------------ 6 files changed, 485 deletions(-) delete mode 100644 mmv1/.rubocop.yml delete mode 100644 mmv1/.ruby-version delete mode 100644 mmv1/Gemfile delete mode 100644 mmv1/Gemfile.lock delete mode 100644 mmv1/Rakefile delete mode 100644 mmv1/templates/terraform/resource_iam.html.markdown.erb diff --git a/mmv1/.rubocop.yml b/mmv1/.rubocop.yml deleted file mode 100644 index 65b59c0f17e4..000000000000 --- a/mmv1/.rubocop.yml +++ /dev/null @@ -1,57 +0,0 @@ -AllCops: - NewCops: enable - Exclude: - - 'build/**/*' - # We do not validate the templates as they will have code that will only be - # properly formatted when compiled for the target module. These files should - # be checked in their final generated form. - - 'products/**/files/*' - - 'products/**/examples/**/*' - - 'templates/**/*' - # TravisCI is installing the bundle deps in that directory. - - 'vendor/**/*' - -Metrics/AbcSize: - Enabled: false - -Metrics/ClassLength: - Enabled: false - -Metrics/CyclomaticComplexity: - Enabled: false - -Metrics/MethodLength: - Enabled: false - -Metrics/ModuleLength: - Enabled: false - -Metrics/PerceivedComplexity: - Enabled: false - -Naming/MemoizedInstanceVariableName: - Enabled: false - -Style/FrozenStringLiteralComment: - Enabled: false - -Layout/LineLength: - Max: 100 - -Style/AccessorGrouping: - Enabled: false - -Style/CommandLiteral: - EnforcedStyle: percent_x - -# TODO: Turn this on and remove the usage at this point. It's not clear if this -# makes sense to do at the moment. -Style/OpenStructUse: - Enabled: false - -# Seems to generate invalid code -Style/HashTransformValues: - Enabled: false - -Metrics/ParameterLists: - Enabled: false diff --git a/mmv1/.ruby-version b/mmv1/.ruby-version deleted file mode 100644 index fd2a01863fdd..000000000000 --- a/mmv1/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -3.1.0 diff --git a/mmv1/Gemfile b/mmv1/Gemfile deleted file mode 100644 index b0b4949b38d6..000000000000 --- a/mmv1/Gemfile +++ /dev/null @@ -1,12 +0,0 @@ -source 'https://rubygems.org' - -gem 'binding_of_caller' -gem 'openapi_parser', '~> 1.0.0' -gem 'parallel' -gem 'rake' - -group :test do - gem 'mocha', '~> 1.3.0' - gem 'rspec' - gem 'rubocop', '>= 0.77.0' -end diff --git a/mmv1/Gemfile.lock b/mmv1/Gemfile.lock deleted file mode 100644 index 15bdf9153dc2..000000000000 --- a/mmv1/Gemfile.lock +++ /dev/null @@ -1,64 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - ast (2.4.2) - binding_of_caller (1.0.0) - debug_inspector (>= 0.0.1) - debug_inspector (1.1.0) - diff-lcs (1.5.0) - json (2.6.3) - metaclass (0.0.4) - mocha (1.3.0) - metaclass (~> 0.0.1) - openapi_parser (1.0.0) - parallel (1.22.1) - parser (3.2.0.0) - ast (~> 2.4.1) - rainbow (3.1.1) - rake (13.0.6) - regexp_parser (2.6.2) - rexml (3.3.3) - strscan - rspec (3.12.0) - rspec-core (~> 3.12.0) - rspec-expectations (~> 3.12.0) - rspec-mocks (~> 3.12.0) - rspec-core (3.12.1) - rspec-support (~> 3.12.0) - rspec-expectations (3.12.2) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-mocks (3.12.3) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-support (3.12.0) - rubocop (1.44.1) - json (~> 2.3) - parallel (~> 1.10) - parser (>= 3.2.0.0) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.24.1, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.24.1) - parser (>= 3.1.1.0) - ruby-progressbar (1.11.0) - strscan (3.1.0) - unicode-display_width (2.4.2) - -PLATFORMS - ruby - -DEPENDENCIES - binding_of_caller - mocha (~> 1.3.0) - openapi_parser (~> 1.0.0) - parallel - rake - rspec - rubocop (>= 0.77.0) - -BUNDLED WITH - 2.4.6 diff --git a/mmv1/Rakefile b/mmv1/Rakefile deleted file mode 100644 index b725e22450bc..000000000000 --- a/mmv1/Rakefile +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2018 Google Inc. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. - -# Configuration -$LOAD_PATH.unshift File.dirname(__FILE__) -Dir.chdir(File.dirname(__FILE__)) - -# Requires -require 'rspec/core/rake_task' -require 'rubocop/rake_task' - -RSpec::Core::RakeTask.new(:spec) -RuboCop::RakeTask.new - -# Test Tasks -desc 'Run all of the MM tests (rubocop, rspec)' -multitask test: %w[rubocop spec] diff --git a/mmv1/templates/terraform/resource_iam.html.markdown.erb b/mmv1/templates/terraform/resource_iam.html.markdown.erb deleted file mode 100644 index 4671f132bea2..000000000000 --- a/mmv1/templates/terraform/resource_iam.html.markdown.erb +++ /dev/null @@ -1,324 +0,0 @@ -<%- # 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. --%> -<%# NOTE NOTE NOTE - The newlines in this file are *load bearing*. This file outputs - Markdown, which is extremely sensitive to newlines. You have got - to have a newline after every attribute and property, because - otherwise MD will think the next element is part of the previous - property's bullet point. You cannot have any double newlines in the - middle of a property or attribute, because MD will think that the - empty line ends the bullet point and the indentation will be off. - You must have a newline before and after all --- document indicators, - and you must have a newline before and after all - - - hlines. - You cannot have more than one blank line between properties. - The --- document indicator must be the first line of the file. - As long as you only use `build_property_documentation`, it all works - fine - but when you need to add custom docs (notes, etc), you need - to remember these things. - - Know also that the `lines` function in heavy use in MagicModules will - strip exactly one trailing newline - unless that's what you've designed - your docstring for, it's easier to insert newlines where you need them - manually. That's why, in this file, we use `lines` on anything which - is generated from a ruby function, but skip it on anything that is - directly inserted from YAML. --%> -<% - tf_product = (object.__product.legacy_name || object.__product.name ).underscore - product_ns_display = (object.__product.legacy_name || object.__product.name ).camelize - tf_subcategory = (object.__product.display_name) - resource_ns = object.legacy_name || "google_#{tf_product}_#{object.name.underscore}" - resource_ns_iam = "#{resource_ns}_iam" - properties = object.all_user_properties - - # In order of preference, use TF override, - # general defined timeouts, or default Timeouts - timeouts = object.timeouts - timeouts ||= object&.async&.operation&.timeouts - timeouts ||= Api::Timeouts.new --%> ---- -<%= lines(autogen_notice(:yaml, pwd)) -%> -subcategory: "<%= tf_subcategory -%>" -description: |- - Collection of resources to manage IAM policy for <%= product.display_name -%> <%= object.name %> ---- - -# IAM policy for <%= product.display_name -%> <%= object.name %> -Three different resources help you manage your IAM policy for <%= product.display_name -%> <%= object.name -%>. Each of these resources serves a different use case: - -* `<%= resource_ns_iam -%>_policy`: Authoritative. Sets the IAM policy for the <%= object.name.downcase -%> and replaces any existing policy already attached. -* `<%= resource_ns_iam -%>_binding`: Authoritative for a given role. Updates the IAM policy to grant a role to a list of members. Other roles within the IAM policy for the <%= object.name.downcase -%> are preserved. -* `<%= resource_ns_iam -%>_member`: Non-authoritative. Updates the IAM policy to grant a role to a new member. Other members for the role for the <%= object.name.downcase -%> are preserved. - -A data source can be used to retrieve policy data in advent you do not need creation - -* `<%= resource_ns_iam -%>_policy`: Retrieves the IAM policy for the <%= object.name.downcase %> - -~> **Note:** `<%= resource_ns_iam -%>_policy` **cannot** be used in conjunction with `<%= resource_ns_iam -%>_binding` and `<%= resource_ns_iam -%>_member` or they will fight over what your policy should be. - -~> **Note:** `<%= resource_ns_iam -%>_binding` resources **can be** used in conjunction with `<%= resource_ns_iam -%>_member` resources **only if** they do not grant privilege to the same role. - -<% unless object.iam_policy.iam_conditions_request_type.nil? -%> -~> **Note:** This resource supports IAM Conditions but they have some known limitations which can be found [here](https://cloud.google.com/iam/docs/conditions-overview#limitations). Please review this article if you are having issues with IAM Conditions. -<% end -%> - -<% if object.min_version.name == 'beta' || object.iam_policy&.min_version == 'beta' -%> -~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider. -See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources. -<% end -%> - -<% params = extract_identifiers(object.iam_policy.self_link || object.self_link_url) -%> -<% -url_properties = object.all_user_properties.select do - |param| params.include?(param.name) -end --%> -## <%= resource_ns_iam -%>_policy - -```hcl -data "google_iam_policy" "admin" { -<% if object.min_version.name == 'beta' -%> - provider = google-beta -<% end -%> - binding { - role = "<%= object.iam_policy.admin_iam_role || object.iam_policy.allowed_iam_role -%>" - members = [ - "user:jane@example.com", - ] - } -} - -resource "<%= resource_ns_iam -%>_policy" "policy" { -<% if object.min_version.name == 'beta' -%> - provider = google-beta -<% end -%> -<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> - policy_data = data.google_iam_policy.admin.policy_data -} -``` - -<% unless object.iam_policy.iam_conditions_request_type.nil? -%> -With IAM Conditions: - -```hcl -data "google_iam_policy" "admin" { -<% if object.min_version.name == 'beta' -%> - provider = google-beta -<% end -%> - binding { - role = "<%= object.iam_policy.admin_iam_role || object.iam_policy.allowed_iam_role -%>" - members = [ - "user:jane@example.com", - ] - - condition { - title = "expires_after_2019_12_31" - description = "Expiring at midnight of 2019-12-31" - expression = "request.time < timestamp(\"2020-01-01T00:00:00Z\")" - } - } -} - -resource "<%= resource_ns_iam -%>_policy" "policy" { -<% if object.min_version.name == 'beta' -%> - provider = google-beta -<% end -%> -<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> - policy_data = data.google_iam_policy.admin.policy_data -} -``` -<% end -%> -## <%= resource_ns_iam -%>_binding - -```hcl -resource "<%= resource_ns_iam -%>_binding" "binding" { -<% if object.min_version.name == 'beta' -%> - provider = google-beta -<% end -%> -<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> - role = "<%= object.iam_policy.admin_iam_role || object.iam_policy.allowed_iam_role -%>" - members = [ - "user:jane@example.com", - ] -} -``` - -<% unless object.iam_policy.iam_conditions_request_type.nil? -%> -With IAM Conditions: - -```hcl -resource "<%= resource_ns_iam -%>_binding" "binding" { -<% if object.min_version.name == 'beta' -%> - provider = google-beta -<% end -%> -<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> - role = "<%= object.iam_policy.admin_iam_role || object.iam_policy.allowed_iam_role -%>" - members = [ - "user:jane@example.com", - ] - - condition { - title = "expires_after_2019_12_31" - description = "Expiring at midnight of 2019-12-31" - expression = "request.time < timestamp(\"2020-01-01T00:00:00Z\")" - } -} -``` -<% end -%> -## <%= resource_ns_iam -%>_member - -```hcl -resource "<%= resource_ns_iam -%>_member" "member" { -<% if object.min_version.name == 'beta' -%> - provider = google-beta -<% end -%> -<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> - role = "<%= object.iam_policy.admin_iam_role || object.iam_policy.allowed_iam_role -%>" - member = "user:jane@example.com" -} -``` - -<% unless object.iam_policy.iam_conditions_request_type.nil? -%> -With IAM Conditions: - -```hcl -resource "<%= resource_ns_iam -%>_member" "member" { -<% if object.min_version.name == 'beta' -%> - provider = google-beta -<% end -%> -<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> - role = "<%= object.iam_policy.admin_iam_role || object.iam_policy.allowed_iam_role -%>" - member = "user:jane@example.com" - - condition { - title = "expires_after_2019_12_31" - description = "Expiring at midnight of 2019-12-31" - expression = "request.time < timestamp(\"2020-01-01T00:00:00Z\")" - } -} -``` -<% end -%> - -## Argument Reference - -The following arguments are supported: - -<% url_properties.each do |param| -%> -<% if param.name == "name" -%> -* `<%= object.iam_policy.parent_resource_attribute || object.name.underscore -%>` - (Required) Used to find the parent resource to bind the IAM policy to -<% elsif ["location", "region", "zone"].include?(param.name.underscore) -%> -* `<%= param.name.underscore -%>` - (Optional) <%= param.description -%> Used to find the parent resource to bind the IAM policy to. If not specified, - the value will be parsed from the identifier of the parent resource. If no <%= param.name.underscore -%> is provided in the parent identifier and no - <%= param.name.underscore -%> is specified, it is taken from the provider configuration. -<% else -%> -* `<%= param.name.underscore -%>` - (Required) <%= param.description -%> Used to find the parent resource to bind the IAM policy to -<% end -%> -<% end -%> -<% if !object.iam_policy.base_url.nil? -%> -<% if object.iam_policy.base_url.include?("{{project}}") -%> -<%# The following new line allow for project to be bullet-formatted properly. -%> - -* `project` - (Optional) The ID of the project in which the resource belongs. - If it is not provided, the project will be parsed from the identifier of the parent resource. If no project is provided in the parent identifier and no project is specified, the provider project is used. -<% end -%> -<% elsif object.base_url.include?("{{project}}")-%> -<%# The following new line allow for project to be bullet-formatted properly. -%> - -* `project` - (Optional) The ID of the project in which the resource belongs. - If it is not provided, the project will be parsed from the identifier of the parent resource. If no project is provided in the parent identifier and no project is specified, the provider project is used. -<% end -%> - -* `member/members` - (Required) Identities that will be granted the privilege in `role`. - Each entry can have one of the following values: - * **allUsers**: A special identifier that represents anyone who is on the internet; with or without a Google account. - * **allAuthenticatedUsers**: A special identifier that represents anyone who is authenticated with a Google account or a service account. - * **user:{emailid}**: An email address that represents a specific Google account. For example, alice@gmail.com or joe@example.com. - * **serviceAccount:{emailid}**: An email address that represents a service account. For example, my-other-app@appspot.gserviceaccount.com. - * **group:{emailid}**: An email address that represents a Google group. For example, admins@example.com. - * **domain:{domain}**: A G Suite domain (primary, instead of alias) name that represents all the users of that domain. For example, google.com or example.com. - * **projectOwner:projectid**: Owners of the given project. For example, "projectOwner:my-example-project" - * **projectEditor:projectid**: Editors of the given project. For example, "projectEditor:my-example-project" - * **projectViewer:projectid**: Viewers of the given project. For example, "projectViewer:my-example-project" - -* `role` - (Required) The role that should be applied. Only one - `<%= resource_ns_iam -%>_binding` can be used per role. Note that custom roles must be of the format - `[projects|organizations]/{parent-name}/roles/{role-name}`. - -* `policy_data` - (Required only by `<%= resource_ns_iam -%>_policy`) The policy data generated by - a `google_iam_policy` data source. - -<% unless object.iam_policy.iam_conditions_request_type.nil? -%> -* `condition` - (Optional) An [IAM Condition](https://cloud.google.com/iam/docs/conditions-overview) for a given binding. - Structure is documented below. - ---- - -The `condition` block supports: - -* `expression` - (Required) Textual representation of an expression in Common Expression Language syntax. - -* `title` - (Required) A title for the expression, i.e. a short string describing its purpose. - -* `description` - (Optional) An optional description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI. - -~> **Warning:** Terraform considers the `role` and condition contents (`title`+`description`+`expression`) as the - identifier for the binding. This means that if any part of the condition is changed out-of-band, Terraform will - consider it to be an entirely different resource and will treat it as such. -<% end -%> -## Attributes Reference - -In addition to the arguments listed above, the following computed attributes are -exported: - -* `etag` - (Computed) The etag of the IAM policy. - -## Import - -For all import syntaxes, the "resource in question" can take any of the following forms: -<% import_format = object.iam_policy.import_format || object.import_format -%> -<% all_formats = import_id_formats(import_format, object.identity, object.base_url).map{ |id| id.gsub('%', '') } -%> - -<% all_formats.each do |id_format| -%> -* <%= id_format %> -<% end -%> - -Any variables not passed in the import command will be taken from the provider configuration. - -<%= product.display_name -%> <%= object.name.downcase -%> IAM resources can be imported using the resource identifiers, role, and member. - -IAM member imports use space-delimited identifiers: the resource in question, the role, and the member identity, e.g. -``` -$ terraform import <%= resource_ns_iam -%>_member.editor "<%= all_formats.first.gsub('{{name}}', "{{#{object.name.underscore}}}") -%> <%= object.iam_policy.allowed_iam_role -%> user:jane@example.com" -``` - -IAM binding imports use space-delimited identifiers: the resource in question and the role, e.g. -``` -$ terraform import <%= resource_ns_iam -%>_binding.editor "<%= all_formats.first.gsub('{{name}}', "{{#{object.name.underscore}}}") -%> <%= object.iam_policy.allowed_iam_role -%>" -``` - -IAM policy imports use the identifier of the resource in question, e.g. -``` -$ terraform import <%= resource_ns_iam -%>_policy.editor <%= all_formats.first.gsub('{{name}}', "{{#{object.name.underscore}}}") %> -``` - --> **Custom Roles** If you're importing a IAM resource with a custom role, make sure to use the - full name of the custom role, e.g. `[projects/my-project|organizations/my-org]/roles/my-custom-role`. - -<% if object.base_url.include?("{{project}}")-%> -## User Project Overrides - -This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override). -<% end -%>