diff --git a/.ci/containers/downstream-builder/Dockerfile b/.ci/containers/downstream-builder/Dockerfile index d5a91fec73ce..143905b57791 100644 --- a/.ci/containers/downstream-builder/Dockerfile +++ b/.ci/containers/downstream-builder/Dockerfile @@ -9,8 +9,7 @@ RUN go get github.com/github/hub RUN ssh-keyscan github.com >> /known_hosts RUN echo "UserKnownHostsFile /known_hosts" >> /etc/ssh/ssh_config -ENV GOFLAGS "-mod=vendor" -ENV GO111MODULE "off" +ENV GO111MODULE "on" # Install Ruby from source. RUN apt-get update diff --git a/.ci/containers/downstream-builder/generate_downstream.sh b/.ci/containers/downstream-builder/generate_downstream.sh index 4b5800f3fe1d..5066d97bb622 100755 --- a/.ci/containers/downstream-builder/generate_downstream.sh +++ b/.ci/containers/downstream-builder/generate_downstream.sh @@ -85,7 +85,8 @@ fi if [ "$REPO" == "terraform" ]; then pushd $LOCAL_PATH - find . -type f -not -wholename "./.git*" -not -wholename "./.changelog*" -not -wholename "./vendor*" -not -name ".travis.yml" -not -name ".golangci.yml" -not -name "CHANGELOG.md" -not -name "GNUmakefile" -not -name "docscheck.sh" -not -name "LICENSE" -not -name "README.md" -not -wholename "./examples*" -not -name "go.mod" -not -name "go.sum" -not -name "staticcheck.conf" -not -name ".go-version" -not -name ".hashibot.hcl" -not -name "tools.go" -exec git rm {} \; + find . -type f -not -wholename "./.git*" -not -wholename "./.changelog*" -not -name ".travis.yml" -not -name ".golangci.yml" -not -name "CHANGELOG.md" -not -name "GNUmakefile" -not -name "docscheck.sh" -not -name "LICENSE" -not -name "README.md" -not -wholename "./examples*" -not -name "go.mod" -not -name "go.sum" -not -name "staticcheck.conf" -not -name ".go-version" -not -name ".hashibot.hcl" -not -name "tools.go" -exec git rm {} \; + go mod download popd fi diff --git a/compile/core.rb b/compile/core.rb index d5731df55ee0..883e0c5e53e5 100644 --- a/compile/core.rb +++ b/compile/core.rb @@ -226,9 +226,9 @@ def compile_string(ctx, source) end end - def autogen_notice(lang) + def autogen_notice(lang, pwd) Thread.current[:autogen] = true - comment_block(compile('templates/autogen_notice.erb').split("\n"), lang) + comment_block(compile(pwd + '/templates/autogen_notice.erb').split("\n"), lang) end def autogen_exception diff --git a/products/iam/helpers/ansible/service_account_key_template.erb b/products/iam/helpers/ansible/service_account_key_template.erb index 0c9b69a3a261..a8f57fdebe7a 100644 --- a/products/iam/helpers/ansible/service_account_key_template.erb +++ b/products/iam/helpers/ansible/service_account_key_template.erb @@ -3,12 +3,12 @@ # # Copyright (C) 2017 Google # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -<%= lines(autogen_notice :python) -%> +<%= lines(autogen_notice(:python, pwd)) -%> from __future__ import absolute_import, division, print_function __metaclass__ = type -<%= lines(compile('templates/ansible/documentation.erb'), 1) -%> +<%= lines(compile(pwd + '/templates/ansible/documentation.erb'), 1) -%> ################################################################################ # Imports ################################################################################ @@ -48,7 +48,7 @@ import base64 def main(): """Main function""" -<%= lines(indent(compile('templates/ansible/module.erb'), 4)) -%> +<%= lines(indent(compile(pwd + '/templates/ansible/module.erb'), 4)) -%> if not module.params['scopes']: module.params['scopes'] = <%= python_literal(object.__product.scopes) %> diff --git a/provider/ansible.rb b/provider/ansible.rb index 32b40ff46175..a15208919545 100644 --- a/provider/ansible.rb +++ b/provider/ansible.rb @@ -94,7 +94,7 @@ def module_name(object) object.name.underscore].join('_') end - def build_object_data(object, output_folder, version) + def build_object_data(pwd, object, output_folder, version) # Method is overridden to add Ansible example objects to the data object. data = AnsibleProductFileTemplate.file_for_resource( output_folder, @@ -105,7 +105,7 @@ def build_object_data(object, output_folder, version) ) prod_name = data.object.name.underscore - path = ["products/#{data.product.api_name}", + path = [pwd + "/products/#{data.product.api_name}", "examples/ansible/#{prod_name}.yaml"].join('/') data.example = get_example(path) if File.file?(path) @@ -233,19 +233,20 @@ def get_example(cfg_file) ex end - def generate_resource(data) + def generate_resource(pwd, data) target_folder = data.output_folder name = module_name(data.object) path = File.join(target_folder, "plugins/modules/#{name}.py") data.generate( + pwd, data.object.template || 'templates/ansible/resource.erb', path, self ) end - def generate_resource_tests(data) + def generate_resource_tests(pwd, data) prod_name = data.object.name.underscore path = ["products/#{data.product.api_name}", "examples/ansible/#{prod_name}.yaml"].join('/') @@ -260,6 +261,7 @@ def generate_resource_tests(data) path = File.join(target_folder, "tests/integration/targets/#{name}/tasks/main.yml") data.generate( + pwd, 'templates/ansible/tests_main.erb', path, self @@ -270,6 +272,7 @@ def generate_resource_tests(data) path = File.join(target_folder, "tests/integration/targets/#{name}/tasks/#{t.name}.yml") data.generate( + pwd, t.path, path, self @@ -280,20 +283,22 @@ def generate_resource_tests(data) path = File.join(target_folder, "tests/integration/targets/#{name}/defaults/main.yml") data.generate( + pwd, 'templates/ansible/integration_test_variables.erb', path, self ) end - def generate_resource_sweepers(data) + def generate_resource_sweepers(pwd, data) # No generated sweepers for this provider end - def compile_datasource(data) + def compile_datasource(pwd, data) target_folder = data.output_folder name = module_name(data.object) - data.generate('templates/ansible/facts.erb', + data.generate(pwd, + 'templates/ansible/facts.erb', File.join(target_folder, "plugins/modules/#{name}_info.py"), self) @@ -344,7 +349,7 @@ def regex_url(url) # Generates files on a per-resource basis. # All paths are allowed a '%s' where the module name # will be added. - def generate_resource_files(data) + def generate_resource_files(pwd, data) return unless @config&.files&.resource files = @config.files.resource @@ -358,7 +363,7 @@ def generate_resource_files(data) data.version, build_env ) - compile_file_list(data.output_folder, files, file_template) + compile_file_list(data.output_folder, files, file_template, pwd) end def copy_common_files(output_folder, provider_name = 'ansible') diff --git a/provider/ansible/example.rb b/provider/ansible/example.rb index 6591304402a2..83fc317937e6 100644 --- a/provider/ansible/example.rb +++ b/provider/ansible/example.rb @@ -229,7 +229,7 @@ class NoVerifier < Verifier attr_reader :reason def validate() end - def build_task(_state, _object) + def build_task(_state, _object, _pwd) '' end end @@ -262,9 +262,9 @@ def validate true end - def build_task(_state, object) + def build_task(_state, object, pwd) @parameters = build_parameters(object) - compile 'templates/ansible/verifiers/facts.yaml.erb' + compile(pwd + '/templates/ansible/verifiers/facts.yaml.erb') end private diff --git a/provider/ansible_devel.rb b/provider/ansible_devel.rb index 08d745a0fba6..51a3a5ae692b 100644 --- a/provider/ansible_devel.rb +++ b/provider/ansible_devel.rb @@ -34,22 +34,24 @@ def module_utils_import_path 'ansible.module_utils.gcp_utils' end - def generate_resource(data) + def generate_resource(pwd, data) target_folder = data.output_folder name = module_name(data.object) path = File.join(target_folder, "lib/ansible/modules/cloud/google/#{name}.py") data.generate( + pwd, data.object.template || 'templates/ansible/resource.erb', path, self ) end - def compile_datasource(data) + def compile_datasource(pwd, data) target_folder = data.output_folder name = module_name(data.object) - data.generate('templates/ansible/facts.erb', + data.generate(pwd, + 'templates/ansible/facts.erb', File.join(target_folder, "lib/ansible/modules/cloud/google/#{name}_info.py"), self) @@ -64,7 +66,7 @@ def compile_datasource(data) File.symlink "#{name}_info.py", deprecated_facts_path end - def generate_resource_tests(data) + def generate_resource_tests(pwd, data) prod_name = data.object.name.underscore path = ["products/#{data.product.api_name}", "examples/ansible/#{prod_name}.yaml"].join('/') @@ -79,6 +81,7 @@ def generate_resource_tests(data) path = File.join(target_folder, "test/integration/targets/#{name}/tasks/main.yml") data.generate( + pwd, 'templates/ansible/tests_main.erb', path, self @@ -89,6 +92,7 @@ def generate_resource_tests(data) path = File.join(target_folder, "test/integration/targets/#{name}/tasks/#{t.name}.yml") data.generate( + pwd, t.path, path, self @@ -96,7 +100,7 @@ def generate_resource_tests(data) end end - def generate_resource_sweepers(data) end + def generate_resource_sweepers(pwd, data) end def compile_common_files(_arg1, _arg2, _arg3) end @@ -115,7 +119,7 @@ def copy_common_files(output_folder, provider_name = nil) copy_file_list(output_folder, files) end - def generate_resource_files(data) + def generate_resource_files(pwd, data) return unless @config&.files&.resource files = @config.files.resource @@ -132,7 +136,7 @@ def generate_resource_files(data) data.version, build_env ) - compile_file_list(data.output_folder, files, file_template) + compile_file_list(data.output_folder, files, file_template, pwd) end end end diff --git a/provider/core.rb b/provider/core.rb index e43a5bf29fe6..a9d4361b6317 100644 --- a/provider/core.rb +++ b/provider/core.rb @@ -89,10 +89,14 @@ def generate(output_folder, types, product_path, dump_yaml) compile_product_files(output_folder) \ unless @config.files.nil? || @config.files.compile.nil? - generate_datasources(output_folder, types) \ + FileUtils.mkpath output_folder unless Dir.exist?(output_folder) + pwd = Dir.pwd + Dir.chdir output_folder + generate_datasources(pwd, output_folder, types) \ unless @config.datasources.nil? - generate_operation(output_folder, types) + generate_operation(pwd, output_folder, types) + Dir.chdir pwd # Write a file with the final version of the api, after overrides # have been applied. @@ -107,7 +111,7 @@ def generate(output_folder, types, product_path, dump_yaml) end end - def generate_operation(output_folder, types); end + def generate_operation(pwd, output_folder, types); end def copy_files(output_folder) copy_file_list(output_folder, @config.files.copy) @@ -181,14 +185,16 @@ def compile_common_files( compile_file_list(output_folder, files, file_template) end - def compile_file_list(output_folder, files, file_template) + def compile_file_list(output_folder, files, file_template, pwd = Dir.pwd) + FileUtils.mkpath output_folder unless Dir.exist?(output_folder) + Dir.chdir output_folder files.map do |target, source| Thread.new do Google::LOGGER.debug "Compiling #{source} => #{target}" - target_file = File.join(output_folder, target) - file_template.generate(source, target_file, self) + file_template.generate(pwd, source, target, self) end end.map(&:join) + Dir.chdir pwd end def generate_objects(output_folder, types) @@ -215,27 +221,34 @@ def generate_objects(output_folder, types) end def generate_object(object, output_folder, version_name) - data = build_object_data(object, output_folder, version_name) + pwd = Dir.pwd + data = build_object_data(pwd, object, output_folder, version_name) unless object.exclude_resource + FileUtils.mkpath output_folder unless Dir.exist?(output_folder) + Dir.chdir output_folder Google::LOGGER.debug "Generating #{object.name} resource" - generate_resource data.clone + generate_resource(pwd, data.clone) Google::LOGGER.debug "Generating #{object.name} tests" - generate_resource_tests data.clone - generate_resource_sweepers data.clone - generate_resource_files data.clone + generate_resource_tests(pwd, data.clone) + generate_resource_sweepers(pwd, data.clone) + generate_resource_files(pwd, data.clone) + Dir.chdir pwd end # if iam_policy is not defined or excluded, don't generate it return if object.iam_policy.nil? || object.iam_policy.exclude + FileUtils.mkpath output_folder unless Dir.exist?(output_folder) + Dir.chdir output_folder Google::LOGGER.debug "Generating #{object.name} IAM policy" - generate_iam_policy data.clone + generate_iam_policy(pwd, data.clone) + Dir.chdir pwd end # Generate files at a per-resource basis. - def generate_resource_files(data) end + def generate_resource_files(pwd, data) end - def generate_datasources(output_folder, types) + def generate_datasources(pwd, output_folder, types) # We need to apply overrides for datasources @api = Overrides::Runner.build(@api, @config.datasources, @config.resource_override, @@ -257,18 +270,18 @@ def generate_datasources(output_folder, types) "Excluding #{object.name} datasource per API version" ) else - generate_datasource object, output_folder + generate_datasource(pwd, object, output_folder) end end end - def generate_datasource(object, output_folder) - data = build_object_data(object, output_folder, @target_version_name) + def generate_datasource(pwd, object, output_folder) + data = build_object_data(pwd, object, output_folder, @target_version_name) - compile_datasource data.clone + compile_datasource(pwd, data.clone) end - def build_object_data(object, output_folder, version) + def build_object_data(_pwd, object, output_folder, version) ProductFileTemplate.file_for_resource(output_folder, object, version, @config, build_env) end @@ -329,7 +342,7 @@ def update_uri(resource, url_part) url_part end - def generate_iam_policy(data) end + def generate_iam_policy(pwd, data) end # TODO(nelsonjr): Review all object interfaces and move to private methods # that should not be exposed outside the object hierarchy. diff --git a/provider/file_template.rb b/provider/file_template.rb index 1694ca9a511a..5831be9aca0f 100644 --- a/provider/file_template.rb +++ b/provider/file_template.rb @@ -35,10 +35,7 @@ class FileTemplate # # Once the file's contents are written, set the proper [chmod] mode and # format the file with a language-appropriate formatter. - def generate(template, path, provider) - folder = File.dirname(path) - FileUtils.mkpath folder unless Dir.exist?(folder) - + def generate(pwd, template, path, provider) # If we've modified a file since starting an MM run, it's a reasonable # assumption that it was this run that modified it. if File.exist?(path) && File.mtime(path) > @env[:start_time] @@ -58,17 +55,19 @@ def generate(template, path, provider) end # This variable is used in ansible/resource.erb - ctx.local_variable_set('file_relative', relative_path(path, @output_folder).to_s) + ctx.local_variable_set('file_relative', + relative_path(@output_folder + '/' + path, @output_folder).to_s) + ctx.local_variable_set('pwd', pwd) Google::LOGGER.debug "Generating #{path}" - File.open(path, 'w') { |f| f.puts compile_file(ctx, template) } + File.open(path, 'w') { |f| f.puts compile_file(ctx, pwd + '/' + template) } # Files are often generated in parallel. # We can use thread-local variables to ensure that autogen checking # stays specific to the file each thred represents. raise "#{path} missing autogen" unless Thread.current[:autogen] - old_file_chmod_mode = File.stat(template).mode + old_file_chmod_mode = File.stat(pwd + '/' + template).mode FileUtils.chmod(old_file_chmod_mode, path) format_output_file(path) diff --git a/provider/inspec.rb b/provider/inspec.rb index e57437d0411d..7d4ef3077747 100644 --- a/provider/inspec.rb +++ b/provider/inspec.rb @@ -61,36 +61,39 @@ class NestedObjectProductFileTemplate < Provider::ProductFileTemplate # This function uses the resource templates to create singular and plural # resources that can be used by InSpec - def generate_resource(data) + def generate_resource(pwd, data) target_folder = File.join(data.output_folder, 'libraries') name = data.object.name.underscore data.generate( + pwd, 'templates/inspec/singular_resource.erb', File.join(target_folder, "#{resource_name(data.object, data.product)}.rb"), self ) - generate_documentation(data.clone, name, false) + generate_documentation(pwd, data.clone, name, false) unless data.object.singular_only data.generate( + pwd, 'templates/inspec/plural_resource.erb', File.join(target_folder, resource_name(data.object, data.product).pluralize + '.rb'), self ) - generate_documentation(data.clone, name, true) + generate_documentation(pwd, data.clone, name, true) end - generate_properties(data.clone, data.object.all_user_properties) + generate_properties(pwd, data.clone, data.object.all_user_properties) end # Generate the IAM policy for this object. This is used to query and test # IAM policies separately from the resource itself - def generate_iam_policy(data) + def generate_iam_policy(pwd, data) target_folder = File.join(data.output_folder, 'libraries') iam_policy_resource_name = "#{resource_name(data.object, data.product)}_iam_policy" data.generate( + pwd, 'templates/inspec/iam_policy/iam_policy.erb', File.join(target_folder, "#{iam_policy_resource_name}.rb"), self @@ -98,21 +101,23 @@ def generate_iam_policy(data) markdown_target_folder = File.join(data.output_folder, 'docs/resources') data.generate( + pwd, 'templates/inspec/iam_policy/iam_policy.md.erb', File.join(markdown_target_folder, "#{iam_policy_resource_name}.md"), self ) - generate_iam_binding(data) + generate_iam_binding(pwd, data) end # Generate the IAM binding for this object. This is used to query and test # IAM bindings in a more convienient way than using the IAM policy resource - def generate_iam_binding(data) + def generate_iam_binding(pwd, data) target_folder = File.join(data.output_folder, 'libraries') iam_binding_resource_name = "#{resource_name(data.object, data.product)}_iam_binding" data.generate( + pwd, 'templates/inspec/iam_binding/iam_binding.erb', File.join(target_folder, "#{iam_binding_resource_name}.rb"), self @@ -120,25 +125,26 @@ def generate_iam_binding(data) markdown_target_folder = File.join(data.output_folder, 'docs/resources') data.generate( + pwd, 'templates/inspec/iam_binding/iam_binding.md.erb', File.join(markdown_target_folder, "#{iam_binding_resource_name}.md"), self ) end - def generate_properties(data, props) + def generate_properties(pwd, data, props) nested_objects = props.select(&:nested_properties?) return if nested_objects.empty? # Create property files for any nested objects. - generate_property_files(nested_objects, data) + generate_property_files(pwd, nested_objects, data) # Create property files for any deeper nested objects. - nested_objects.each { |prop| generate_properties(data, prop.nested_properties) } + nested_objects.each { |prop| generate_properties(pwd, data, prop.nested_properties) } end # Generate the files for the properties - def generate_property_files(properties, data) + def generate_property_files(pwd, properties, data) properties.flatten.compact.each do |property| nested_object_template = NestedObjectProductFileTemplate.new( data.output_folder, @@ -153,11 +159,11 @@ def generate_property_files(properties, data) nested_object_template.output_folder, "libraries/#{nested_object_requires(property)}.rb" ) - nested_object_template.generate(source, target, self) + nested_object_template.generate(pwd, source, target, self) end end - def build_object_data(object, output_folder, version) + def build_object_data(_pwd, object, output_folder, version) InspecProductFileTemplate.file_for_resource( output_folder, object, @@ -168,7 +174,7 @@ def build_object_data(object, output_folder, version) end # Generates InSpec markdown documents for the resource - def generate_documentation(data, base_name, plural) + def generate_documentation(pwd, data, base_name, plural) docs_folder = File.join(data.output_folder, 'docs', 'resources') name = plural ? base_name.pluralize : base_name @@ -179,6 +185,7 @@ def generate_documentation(data, base_name, plural) file_name = resource_name(data.object, data.product) file_name = file_name.pluralize if plural data.generate( + pwd, 'templates/inspec/doc_template.md.erb', File.join(docs_folder, "#{file_name}.md"), self @@ -193,28 +200,29 @@ def format_url(url) end # Copies InSpec tests to build folder - def generate_resource_tests(data) + def generate_resource_tests(pwd, data) target_folder = File.join(data.output_folder, 'test') FileUtils.mkpath target_folder - FileUtils.cp_r 'templates/inspec/tests/.', target_folder + FileUtils.cp_r pwd + '/templates/inspec/tests/.', target_folder name = resource_name(data.object, data.product) - generate_inspec_test(data.clone, name, target_folder, name) + generate_inspec_test(pwd, data.clone, name, target_folder, name) # Build test for plural resource - generate_inspec_test(data.clone, name.pluralize, target_folder, name)\ + generate_inspec_test(pwd, data.clone, name.pluralize, target_folder, name)\ unless data.object.singular_only end - def generate_inspec_test(data, name, target_folder, attribute_file_name) + def generate_inspec_test(pwd, data, name, target_folder, attribute_file_name) data.name = name data.attribute_file_name = attribute_file_name data.doc_generation = false data.privileged = data.object.privileged data.generate( + pwd, 'templates/inspec/integration_test_template.erb', File.join( target_folder, @@ -225,7 +233,7 @@ def generate_inspec_test(data, name, target_folder, attribute_file_name) ) end - def generate_resource_sweepers(data) + def generate_resource_sweepers(pwd, data) # No generated sweepers for this provider end @@ -314,18 +322,18 @@ def markdown_format(property, indent = 1) description end - def grab_attributes - YAML.load_file('templates/inspec/tests/integration/configuration/mm-attributes.yml') + def grab_attributes(pwd) + YAML.load_file(pwd + '/templates/inspec/tests/integration/configuration/mm-attributes.yml') end # Returns a variable name OR default value for that variable based on # defaults from the existing inspec-gcp tests that do not exist within MM # Default values are used within documentation to show realistic examples - def external_attribute(attribute_name, doc_generation = false) + def external_attribute(pwd, attribute_name, doc_generation = false) return attribute_name unless doc_generation external_attribute_file = 'templates/inspec/examples/attributes/external_attributes.yml' - "'#{YAML.load_file(external_attribute_file)[attribute_name]}'" + "'#{YAML.load_file(pwd + '/' + external_attribute_file)[attribute_name]}'" end def qualified_property_class(property) diff --git a/provider/terraform.rb b/provider/terraform.rb index d34f5a2ebd82..d0338a65ee3c 100644 --- a/provider/terraform.rb +++ b/provider/terraform.rb @@ -178,18 +178,19 @@ def folder_name(version) # This function uses the resource.erb template to create one file # per resource. The resource.erb template forms the basis of a single # GCP Resource on Terraform. - def generate_resource(data) - target_folder = File.join(data.output_folder, folder_name(data.version)) - + def generate_resource(pwd, data) name = data.object.name.underscore product_name = data.product.name.underscore - filepath = File.join(target_folder, "resource_#{product_name}_#{name}.go") - data.generate('templates/terraform/resource.erb', filepath, self) - generate_documentation(data) + FileUtils.mkpath folder_name(data.version) unless Dir.exist?(folder_name(data.version)) + data.generate(pwd, + '/templates/terraform/resource.erb', + "#{folder_name(data.version)}/resource_#{product_name}_#{name}.go", + self) + generate_documentation(pwd, data) end - def generate_documentation(data) + def generate_documentation(pwd, data) target_folder = data.output_folder target_folder = File.join(target_folder, 'website', 'docs', 'r') FileUtils.mkpath target_folder @@ -198,10 +199,10 @@ def generate_documentation(data) filepath = File.join(target_folder, "#{product_name}_#{name}.html.markdown") - data.generate('templates/terraform/resource.html.markdown.erb', filepath, self) + data.generate(pwd, 'templates/terraform/resource.html.markdown.erb', filepath, self) end - def generate_resource_tests(data) + def generate_resource_tests(pwd, data) return if data.object.examples .reject(&:skip_test) .reject do |e| @@ -210,85 +211,79 @@ def generate_resource_tests(data) end .empty? - target_folder = File.join(data.output_folder, folder_name(data.version)) - name = data.object.name.underscore product_name = data.product.name.underscore - filepath = - File.join( - target_folder, - "resource_#{product_name}_#{name}_generated_test.go" - ) data.product = data.product.name data.resource_name = data.object.name.camelize(:upper) - data.generate('templates/terraform/examples/base_configs/test_file.go.erb', - filepath, self) + FileUtils.mkpath folder_name(data.version) unless Dir.exist?(folder_name(data.version)) + data.generate( + pwd, + 'templates/terraform/examples/base_configs/test_file.go.erb', + "#{folder_name(data.version)}/resource_#{product_name}_#{name}_generated_test.go", + self + ) end - def generate_resource_sweepers(data) + def generate_resource_sweepers(pwd, data) return if data.object.skip_sweeper || data.object.custom_code.custom_delete || data.object.custom_code.pre_delete || data.object.skip_delete - target_folder = File.join(data.output_folder, folder_name(data.version)) - name = data.object.name.underscore product_name = data.product.name.underscore - filepath = - File.join( - target_folder, - "resource_#{product_name}_#{name}_sweeper_test.go" - ) data.product = data.product.name data.resource_name = data.object.name.camelize(:upper) - data.generate('templates/terraform/sweeper_file.go.erb', - filepath, self) + FileUtils.mkpath folder_name(data.version) unless Dir.exist?(folder_name(data.version)) + data.generate(pwd, + 'templates/terraform/sweeper_file.go.erb', + "#{folder_name(data.version)}/resource_#{product_name}_#{name}_sweeper_test.go", + self) end - def generate_operation(output_folder, _types) + def generate_operation(pwd, output_folder, _types) return if @api.objects.select(&:autogen_async).empty? product_name = @api.name.underscore - data = build_object_data(@api.objects.first, output_folder, @target_version_name) - target_folder = File.join(data.output_folder, folder_name(data.version)) + data = build_object_data(pwd, @api.objects.first, output_folder, @target_version_name) data.object = @api.objects.select(&:autogen_async).first data.async = data.object.async - data.generate('templates/terraform/operation.go.erb', - File.join(target_folder, - "#{product_name}_operation.go"), + FileUtils.mkpath folder_name(data.version) unless Dir.exist?(folder_name(data.version)) + data.generate(pwd, + 'templates/terraform/operation.go.erb', + "#{folder_name(data.version)}/#{product_name}_operation.go", self) end # Generate the IAM policy for this object. This is used to query and test # IAM policies separately from the resource itself - def generate_iam_policy(data) - target_folder = File.join(data.output_folder, folder_name(data.version)) - + def generate_iam_policy(pwd, data) name = data.object.name.underscore product_name = data.product.name.underscore - filepath = File.join(target_folder, "iam_#{product_name}_#{name}.go") - data.generate('templates/terraform/iam_policy.go.erb', filepath, self) + FileUtils.mkpath folder_name(data.version) unless Dir.exist?(folder_name(data.version)) + data.generate(pwd, + 'templates/terraform/iam_policy.go.erb', + "#{folder_name(data.version)}/iam_#{product_name}_#{name}.go", + self) # Only generate test if testable examples exist. unless data.object.examples.reject(&:skip_test).empty? - generated_test_name = "iam_#{product_name}_#{name}_generated_test.go" - filepath = File.join(target_folder, generated_test_name) data.generate( + pwd, 'templates/terraform/examples/base_configs/iam_test_file.go.erb', - filepath, + "#{folder_name(data.version)}/iam_#{product_name}_#{name}_generated_test.go", self ) end - generate_iam_documentation(data) + generate_iam_documentation(pwd, data) end - def generate_iam_documentation(data) + def generate_iam_documentation(pwd, data) target_folder = data.output_folder target_folder = File.join(target_folder, 'website', 'docs', 'r') FileUtils.mkpath target_folder @@ -297,10 +292,10 @@ def generate_iam_documentation(data) filepath = File.join(target_folder, "#{product_name}_#{name}_iam.html.markdown") - data.generate('templates/terraform/resource_iam.html.markdown.erb', filepath, self) + data.generate(pwd, 'templates/terraform/resource_iam.html.markdown.erb', filepath, self) end - def build_object_data(object, output_folder, version) + def build_object_data(_pwd, object, output_folder, version) TerraformProductFileTemplate.file_for_resource( output_folder, object, diff --git a/provider/terraform/examples.rb b/provider/terraform/examples.rb index 73b1fc36b17a..64403c1823b0 100644 --- a/provider/terraform/examples.rb +++ b/provider/terraform/examples.rb @@ -119,7 +119,7 @@ class Examples < Api::Object # Defaults to `templates/terraform/examples/{{name}}.tf.erb` attr_reader :config_path - def config_documentation + def config_documentation(pwd) docs_defaults = { PROJECT_NAME: 'my-project-name', FIRESTORE_PROJECT_NAME: 'my-project-name', @@ -139,26 +139,26 @@ def config_documentation test_env_vars: test_env_vars.map { |k, v| [k, docs_defaults[v]] }.to_h, primary_resource_id: primary_resource_id }, - config_path + pwd + '/' + config_path )) lines(compile_file( { content: body }, - 'templates/terraform/examples/base_configs/documentation.tf.erb' + pwd + '/templates/terraform/examples/base_configs/documentation.tf.erb' )) end - def config_test - body = config_test_body + def config_test(pwd) + body = config_test_body(pwd) lines(compile_file( { content: body }, - 'templates/terraform/examples/base_configs/test_body.go.erb' + pwd + '/templates/terraform/examples/base_configs/test_body.go.erb' )) end # rubocop:disable Style/FormatStringToken - def config_test_body + def config_test_body(pwd) @vars ||= {} @test_env_vars ||= {} @test_vars_overrides ||= {} @@ -189,13 +189,13 @@ def config_test_body test_env_vars: test_env_vars.map { |k, _| [k, "%{#{k}}"] }.to_h, primary_resource_id: primary_resource_id }, - config_path + pwd + '/' + config_path )) substitute_test_paths body end - def config_example + def config_example(pwd) @vars ||= [] @oics_vars_overrides ||= {} @@ -207,7 +207,7 @@ def config_example vars: rand_vars.merge(oics_vars_overrides), primary_resource_id: primary_resource_id }, - config_path + pwd + '/' + config_path )) substitute_example_paths body diff --git a/provider/terraform/sub_template.rb b/provider/terraform/sub_template.rb index 0b3149f91547..03c58ab37139 100644 --- a/provider/terraform/sub_template.rb +++ b/provider/terraform/sub_template.rb @@ -17,55 +17,62 @@ module Provider class Terraform < Provider::AbstractCore # Functions to compile sub-templates. module SubTemplate - def build_schema_property(property, object) - compile_template'templates/terraform/schema_property.erb', - property: property, - object: object + def build_schema_property(property, object, pwd) + compile_template pwd + '/templates/terraform/schema_property.erb', + property: property, + object: object, + pwd: pwd end - def build_subresource_schema(property, object) - compile_template'templates/terraform/schema_subresource.erb', - property: property, - object: object + def build_subresource_schema(property, object, pwd) + compile_template pwd + '/templates/terraform/schema_subresource.erb', + property: property, + object: object, + pwd: pwd end # Transforms a Cloud API representation of a property into a Terraform # schema representation. - def build_flatten_method(prefix, property, object) - compile_template 'templates/terraform/flatten_property_method.erb', + def build_flatten_method(prefix, property, object, pwd) + compile_template pwd + '/templates/terraform/flatten_property_method.erb', prefix: prefix, property: property, - object: object + object: object, + pwd: pwd end # Transforms a Terraform schema representation of a property into a # representation used by the Cloud API. - def build_expand_method(prefix, property, object) - compile_template 'templates/terraform/expand_property_method.erb', + def build_expand_method(prefix, property, object, pwd) + compile_template pwd + '/templates/terraform/expand_property_method.erb', prefix: prefix, property: property, - object: object + object: object, + pwd: pwd end - def build_expand_resource_ref(var_name, property) - compile_template 'templates/terraform/expand_resource_ref.erb', + def build_expand_resource_ref(var_name, property, pwd) + compile_template pwd + '/templates/terraform/expand_resource_ref.erb', var_name: var_name, - property: property + property: property, + pwd: pwd end - def build_property_documentation(property) + def build_property_documentation(property, pwd) return if property.removed? - compile_template 'templates/terraform/property_documentation.erb', - property: property + compile_template pwd + '/templates/terraform/property_documentation.erb', + property: property, + pwd: pwd end - def build_nested_property_documentation(property) + def build_nested_property_documentation(property, pwd) return if property.removed? compile_template( - 'templates/terraform/nested_property_documentation.erb', - property: property + pwd + '/templates/terraform/nested_property_documentation.erb', + property: property, + pwd: pwd ) end diff --git a/provider/terraform_object_library.rb b/provider/terraform_object_library.rb index bc4ccb0f0dc6..a84048880132 100644 --- a/provider/terraform_object_library.rb +++ b/provider/terraform_object_library.rb @@ -30,11 +30,12 @@ def generate_object(object, output_folder, version_name) super(object, output_folder, version_name) end - def generate_resource(data) + def generate_resource(pwd, data) target_folder = data.output_folder product_ns = data.object.__product.name - data.generate('templates/terraform/objectlib/base.go.erb', + data.generate(pwd, + 'templates/terraform/objectlib/base.go.erb', File.join(target_folder, "google/#{product_ns.downcase}_#{data.object.name.underscore}.go"), self) @@ -137,10 +138,10 @@ def copy_common_files(output_folder) ]) end - def generate_resource_tests(data) end + def generate_resource_tests(pwd, data) end - def generate_iam_policy(data) end + def generate_iam_policy(pwd, data) end - def generate_resource_sweepers(data) end + def generate_resource_sweepers(pwd, data) end end end diff --git a/provider/terraform_oics.rb b/provider/terraform_oics.rb index c7590169e404..f4fba172e7fe 100644 --- a/provider/terraform_oics.rb +++ b/provider/terraform_oics.rb @@ -24,7 +24,7 @@ def generate(output_folder, types, _product_path, _dump_yaml) end # Create a directory of examples per resource - def generate_resource(data) + def generate_resource(pwd, data) examples = data.object.examples .reject(&:skip_test) .reject { |e| !e.test_env_vars.nil? && e.test_env_vars.any? } @@ -37,41 +37,37 @@ def generate_resource(data) data.example = example - data.generate( - 'templates/terraform/examples/base_configs/example_file.tf.erb', - File.join(target_folder, 'main.tf'), - self - ) + data.generate(pwd, + 'templates/terraform/examples/base_configs/example_file.tf.erb', + File.join(target_folder, 'main.tf'), + self) - data.generate( - 'templates/terraform/examples/base_configs/tutorial.md.erb', - File.join(target_folder, 'tutorial.md'), - self - ) + data.generate(pwd, + 'templates/terraform/examples/base_configs/tutorial.md.erb', + File.join(target_folder, 'tutorial.md'), + self) - data.generate( - 'templates/terraform/examples/base_configs/example_backing_file.tf.erb', - File.join(target_folder, 'backing_file.tf'), - self - ) + data.generate(pwd, + 'templates/terraform/examples/base_configs/example_backing_file.tf.erb', + File.join(target_folder, 'backing_file.tf'), + self) - data.generate( - 'templates/terraform/examples/static/motd', - File.join(target_folder, 'motd'), - self - ) + data.generate(pwd, + 'templates/terraform/examples/static/motd', + File.join(target_folder, 'motd'), + self) end end # We don't want to generate anything but the resource. - def generate_resource_tests(data) end + def generate_resource_tests(pwd, data) end - def generate_resource_sweepers(data) end + def generate_resource_sweepers(pwd, data) end def compile_common_files(output_folder, products, common_compile_file) end def copy_common_files(output_folder) end - def generate_iam_policy(data) end + def generate_iam_policy(pwd, data) end end end diff --git a/templates/ansible/facts.erb b/templates/ansible/facts.erb index c7d7506672c4..ceb233356088 100644 --- a/templates/ansible/facts.erb +++ b/templates/ansible/facts.erb @@ -3,7 +3,7 @@ # # Copyright (C) 2017 Google # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -<%= lines(autogen_notice :python) -%> +<%= lines(autogen_notice(:python, pwd)) -%> from __future__ import absolute_import, division, print_function __metaclass__ = type diff --git a/templates/ansible/integration_test.erb b/templates/ansible/integration_test.erb index 6cb30d90812e..0cf793faa2cb 100644 --- a/templates/ansible/integration_test.erb +++ b/templates/ansible/integration_test.erb @@ -1,5 +1,5 @@ --- -<%= lines(autogen_notice :yaml) -%> +<%= lines(autogen_notice(:yaml, pwd)) -%> # Pre-test setup <% unless example.dependencies.nil? -%> <% example.dependencies.each do |depend| -%> @@ -25,7 +25,7 @@ - result.changed == true <% end # if object.readonly -%> <% unless example.verifier.nil? -%> -<%= lines(example.verifier.build_task('present', object)) -%> +<%= lines(example.verifier.build_task('present', object, pwd)) -%> <% end -%> <% unless object.readonly -%> # ---------------------------------------------------------------------------- @@ -43,7 +43,7 @@ that: - result.changed == true <% unless example.verifier.nil? -%> -<%= lines(example.verifier.build_task('absent', object)) -%> +<%= lines(example.verifier.build_task('absent', object, pwd)) -%> <% end -%> # ---------------------------------------------------------------------------- <%= lines(example.task.build_test('absent', object, true)) -%> diff --git a/templates/ansible/provider_helpers.erb b/templates/ansible/provider_helpers.erb index db854570bd65..34380b2ef8bf 100644 --- a/templates/ansible/provider_helpers.erb +++ b/templates/ansible/provider_helpers.erb @@ -4,9 +4,9 @@ <%= object.provider_helpers.map do |f| if f == object.provider_helpers.last - lines(compile(f)) + lines(compile(pwd + '/' + f)) else - lines(compile(f), 2) + lines(compile(pwd + '/' + f), 2) end end.join -%> diff --git a/templates/ansible/resource.erb b/templates/ansible/resource.erb index 51ecd909b5e4..801cf167353c 100644 --- a/templates/ansible/resource.erb +++ b/templates/ansible/resource.erb @@ -3,12 +3,12 @@ # # Copyright (C) 2017 Google # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -<%= lines(autogen_notice :python) -%> +<%= lines(autogen_notice(:python, pwd)) -%> from __future__ import absolute_import, division, print_function __metaclass__ = type -<%= lines(compile('templates/ansible/documentation.erb'), 1) -%> +<%= lines(compile(pwd + '/templates/ansible/documentation.erb'), 1) -%> ################################################################################ # Imports ################################################################################ @@ -44,7 +44,7 @@ import json def main(): """Main function""" -<%= lines(indent(compile('templates/ansible/module.erb'), 4)) -%> +<%= lines(indent(compile(pwd + '/templates/ansible/module.erb'), 4)) -%> if not module.params['scopes']: module.params['scopes'] = <%= python_literal(object.__product.scopes) %> @@ -295,7 +295,7 @@ def <%= func_name -%>(module, request, response): <% end -%> <% end # unless update_props.empty? -%> <% if object.update_mask -%> -<%= lines(compile('templates/ansible/update_mask.erb')) -%> +<%= lines(compile(pwd + '/templates/ansible/update_mask.erb')) -%> <% end # if update_mask -%> <%= lines(method_decl('delete', ['module', 'link', ('kind' if object.kind?), @@ -378,7 +378,7 @@ def unwrap_resource(result, module): <% end -%> -<%= lines(compile('templates/ansible/transport.erb'), 2) -%> +<%= lines(compile(pwd + '/templates/ansible/transport.erb'), 2) -%> <%= lines(emit_link('self_link', build_url(object.self_link_url), object), 2) -%> <%= lines(emit_link('collection', build_url(object.collection_url), object), 2) -%> <%- unless object.create_url.nil? -%> @@ -446,7 +446,7 @@ def is_different(module, response): def response_to_hash(module, response): return <%= lines(python_literal(response_properties(object.properties), use_hash_brackets: true)) -%> <% if object.all_user_properties.any?(&:pattern) -%> -<%= lines(compile('templates/ansible/pattern.py.erb')) -%> +<%= lines(compile(pwd + '/templates/ansible/pattern.py.erb')) -%> <% end -%> <% readonly_selflink_rrefs.each do |resource| -%> @@ -459,9 +459,9 @@ def <%= resource.name.underscore -%>_selflink(name, params): name = <%= build_url(resource.self_link_url).gsub('{name}', '%s') -%>.format(**params) % name return name <% end -%> -<%= lines_before(compile('templates/ansible/async.erb'), 1) -%> -<%= lines_before(compile('templates/ansible/provider_helpers.erb'), 1) -%> -<%= lines_before(compile('templates/ansible/properties.erb'), 1) -%> +<%= lines_before(compile(pwd + '/templates/ansible/async.erb'), 1) -%> +<%= lines_before(compile(pwd + '/templates/ansible/provider_helpers.erb'), 1) -%> +<%= lines_before(compile(pwd + '/templates/ansible/properties.erb'), 1) -%> if __name__ == '__main__': diff --git a/templates/inspec/doc_template.md.erb b/templates/inspec/doc_template.md.erb index 8c78c74d5eee..937912f3657f 100644 --- a/templates/inspec/doc_template.md.erb +++ b/templates/inspec/doc_template.md.erb @@ -30,17 +30,17 @@ This resource has beta fields available. To retrieve these fields, include `beta <% end -%> ## Examples ``` -<%= compile("templates/inspec/examples/#{resource_name(object, product)}/#{resource_underscored_name}.erb") -%> +<%= compile(pwd + "/templates/inspec/examples/#{resource_name(object, product)}/#{resource_underscored_name}.erb") -%> ``` <% if object.singular_extra_examples && !plural -%> -<%= compile(object.singular_extra_examples) -%> +<%= compile(pwd + '/' + object.singular_extra_examples) -%> <% end -%> <% if object.plural_extra_examples && plural -%> -<%= compile(object.plural_extra_examples) -%> +<%= compile(pwd + '/' + object.plural_extra_examples) -%> <% end -%> diff --git a/templates/inspec/examples/google_access_context_manager_access_policy/google_access_context_manager_access_policies.erb b/templates/inspec/examples/google_access_context_manager_access_policy/google_access_context_manager_access_policies.erb index 2ecb2957f474..93894243caa5 100644 --- a/templates/inspec/examples/google_access_context_manager_access_policy/google_access_context_manager_access_policies.erb +++ b/templates/inspec/examples/google_access_context_manager_access_policy/google_access_context_manager_access_policies.erb @@ -1,5 +1,5 @@ -<% gcp_organization_id = "#{external_attribute('gcp_organization_id', doc_generation)}" -%> -<% service_perimeter = grab_attributes['service_perimeter'] -%> +<% gcp_organization_id = "#{external_attribute(pwd, 'gcp_organization_id', doc_generation)}" -%> +<% service_perimeter = grab_attributes(pwd)['service_perimeter'] -%> describe google_access_context_manager_access_policies(org_id: <%= gcp_organization_id %>) do its('count') { should be >= 1 } diff --git a/templates/inspec/examples/google_access_context_manager_access_policy/google_access_context_manager_access_policy.erb b/templates/inspec/examples/google_access_context_manager_access_policy/google_access_context_manager_access_policy.erb index b26f00b8863d..d85d846714dd 100644 --- a/templates/inspec/examples/google_access_context_manager_access_policy/google_access_context_manager_access_policy.erb +++ b/templates/inspec/examples/google_access_context_manager_access_policy/google_access_context_manager_access_policy.erb @@ -1,5 +1,5 @@ -<% gcp_organization_id = "#{external_attribute('gcp_organization_id', doc_generation)}" -%> -<% service_perimeter = grab_attributes['service_perimeter'] -%> +<% gcp_organization_id = "#{external_attribute(pwd, 'gcp_organization_id', doc_generation)}" -%> +<% service_perimeter = grab_attributes(pwd)['service_perimeter'] -%> describe.one do google_access_context_manager_access_policies(org_id: <%= gcp_organization_id %>).names.each do |policy_name| diff --git a/templates/inspec/examples/google_access_context_manager_access_policy/google_access_context_manager_access_policy_attributes.erb b/templates/inspec/examples/google_access_context_manager_access_policy/google_access_context_manager_access_policy_attributes.erb index 4ef4a50d8d00..d7eb5a975b1c 100644 --- a/templates/inspec/examples/google_access_context_manager_access_policy/google_access_context_manager_access_policy_attributes.erb +++ b/templates/inspec/examples/google_access_context_manager_access_policy/google_access_context_manager_access_policy_attributes.erb @@ -1,3 +1,3 @@ -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization that is the parent of the perimeter') +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization that is the parent of the perimeter') gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default:0, description:'Flag to enable privileged resources requiring elevated privileges in GCP.') -service_perimeter = attribute('service_perimeter', default: <%= JSON.pretty_generate(grab_attributes['service_perimeter']) -%>, description: 'Service perimeter definition') \ No newline at end of file +service_perimeter = attribute('service_perimeter', default: <%= JSON.pretty_generate(grab_attributes(pwd)['service_perimeter']) -%>, description: 'Service perimeter definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_access_context_manager_service_perimeter/google_access_context_manager_service_perimeter.erb b/templates/inspec/examples/google_access_context_manager_service_perimeter/google_access_context_manager_service_perimeter.erb index e93362478d83..e23dca2d8df3 100644 --- a/templates/inspec/examples/google_access_context_manager_service_perimeter/google_access_context_manager_service_perimeter.erb +++ b/templates/inspec/examples/google_access_context_manager_service_perimeter/google_access_context_manager_service_perimeter.erb @@ -1,5 +1,5 @@ -<% gcp_organization_id = "#{external_attribute('gcp_organization_id', doc_generation)}" -%> -<% service_perimeter = grab_attributes['service_perimeter'] -%> +<% gcp_organization_id = "#{external_attribute(pwd, 'gcp_organization_id', doc_generation)}" -%> +<% service_perimeter = grab_attributes(pwd)['service_perimeter'] -%> describe.one do google_access_context_manager_access_policies(org_id: <%= gcp_organization_id %>).names.each do |policy_name| diff --git a/templates/inspec/examples/google_access_context_manager_service_perimeter/google_access_context_manager_service_perimeter_attributes.erb b/templates/inspec/examples/google_access_context_manager_service_perimeter/google_access_context_manager_service_perimeter_attributes.erb index 4ef4a50d8d00..d7eb5a975b1c 100644 --- a/templates/inspec/examples/google_access_context_manager_service_perimeter/google_access_context_manager_service_perimeter_attributes.erb +++ b/templates/inspec/examples/google_access_context_manager_service_perimeter/google_access_context_manager_service_perimeter_attributes.erb @@ -1,3 +1,3 @@ -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization that is the parent of the perimeter') +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization that is the parent of the perimeter') gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default:0, description:'Flag to enable privileged resources requiring elevated privileges in GCP.') -service_perimeter = attribute('service_perimeter', default: <%= JSON.pretty_generate(grab_attributes['service_perimeter']) -%>, description: 'Service perimeter definition') \ No newline at end of file +service_perimeter = attribute('service_perimeter', default: <%= JSON.pretty_generate(grab_attributes(pwd)['service_perimeter']) -%>, description: 'Service perimeter definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_access_context_manager_service_perimeter/google_access_context_manager_service_perimeters.erb b/templates/inspec/examples/google_access_context_manager_service_perimeter/google_access_context_manager_service_perimeters.erb index ed65843deb61..5ed933bff520 100644 --- a/templates/inspec/examples/google_access_context_manager_service_perimeter/google_access_context_manager_service_perimeters.erb +++ b/templates/inspec/examples/google_access_context_manager_service_perimeter/google_access_context_manager_service_perimeters.erb @@ -1,5 +1,5 @@ -<% gcp_organization_id = "#{external_attribute('gcp_organization_id', doc_generation)}" -%> -<% service_perimeter = grab_attributes['service_perimeter'] -%> +<% gcp_organization_id = "#{external_attribute(pwd, 'gcp_organization_id', doc_generation)}" -%> +<% service_perimeter = grab_attributes(pwd)['service_perimeter'] -%> describe.one do google_access_context_manager_access_policies(org_id: <%= gcp_organization_id %>).names.each do |policy_name| diff --git a/templates/inspec/examples/google_appengine_standard_app_version/google_appengine_standard_app_version.erb b/templates/inspec/examples/google_appengine_standard_app_version/google_appengine_standard_app_version.erb index c53e464c7c70..cdb414532564 100644 --- a/templates/inspec/examples/google_appengine_standard_app_version/google_appengine_standard_app_version.erb +++ b/templates/inspec/examples/google_appengine_standard_app_version/google_appengine_standard_app_version.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% standardappversion = grab_attributes['standardappversion'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% standardappversion = grab_attributes(pwd)['standardappversion'] -%> describe google_appengine_standard_app_version(project: <%= gcp_project_id -%>, location: <%= gcp_location -%>, version_id: <%= doc_generation ? "'#{standardappversion['version_id']}'" : "standardappversion['version_id']" -%>, service: <%= doc_generation ? "'#{standardappversion['service']}'" : "standardappversion['service']" -%>) do it { should exist } diff --git a/templates/inspec/examples/google_appengine_standard_app_version/google_appengine_standard_app_version_attributes.erb b/templates/inspec/examples/google_appengine_standard_app_version/google_appengine_standard_app_version_attributes.erb index 425ce2537a4f..47f6338b6dc5 100644 --- a/templates/inspec/examples/google_appengine_standard_app_version/google_appengine_standard_app_version_attributes.erb +++ b/templates/inspec/examples/google_appengine_standard_app_version/google_appengine_standard_app_version_attributes.erb @@ -1,5 +1,5 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'The GCP project location.') -standardappversion = attribute('standardappversion', default: <%= JSON.pretty_generate(grab_attributes['standardappversion']) -%>, description: 'Cloud App Engine definition') +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_location = attribute(:gcp_location, default: '<%= external_attribute(pwd, 'gcp_location') -%>', description: 'The GCP project location.') +standardappversion = attribute('standardappversion', default: <%= JSON.pretty_generate(grab_attributes(pwd)['standardappversion']) -%>, description: 'Cloud App Engine definition') gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default:0, description:'Flag to enable privileged resources requiring elevated privileges in GCP.') -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file diff --git a/templates/inspec/examples/google_appengine_standard_app_version/google_appengine_standard_app_versions.erb b/templates/inspec/examples/google_appengine_standard_app_version/google_appengine_standard_app_versions.erb index 3ecf79e4469f..485a69908c25 100644 --- a/templates/inspec/examples/google_appengine_standard_app_version/google_appengine_standard_app_versions.erb +++ b/templates/inspec/examples/google_appengine_standard_app_version/google_appengine_standard_app_versions.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% standardappversion = grab_attributes['standardappversion'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% standardappversion = grab_attributes(pwd)['standardappversion'] -%> describe google_appengine_standard_app_versions(project: <%= gcp_project_id -%>, location: <%= gcp_location -%>,service: <%= doc_generation ? "'#{standardappversion['service']}'" : "standardappversion['service']" -%>) do its('runtimes') { should include <%= doc_generation ? "'#{standardappversion['runtime']}'" : "standardappversion['runtime']" -%> } diff --git a/templates/inspec/examples/google_bigquery_dataset/google_bigquery_dataset.erb b/templates/inspec/examples/google_bigquery_dataset/google_bigquery_dataset.erb index 1fa49e1f1bc2..f8be9fe14eb6 100644 --- a/templates/inspec/examples/google_bigquery_dataset/google_bigquery_dataset.erb +++ b/templates/inspec/examples/google_bigquery_dataset/google_bigquery_dataset.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% dataset = grab_attributes['dataset'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% dataset = grab_attributes(pwd)['dataset'] -%> describe google_bigquery_dataset(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, name: <%= doc_generation ? "'#{dataset['dataset_id']}'" : "dataset['dataset_id']" -%>) do it { should exist } diff --git a/templates/inspec/examples/google_bigquery_dataset/google_bigquery_dataset_attributes.erb b/templates/inspec/examples/google_bigquery_dataset/google_bigquery_dataset_attributes.erb index 24d9298e551f..874450396a53 100644 --- a/templates/inspec/examples/google_bigquery_dataset/google_bigquery_dataset_attributes.erb +++ b/templates/inspec/examples/google_bigquery_dataset/google_bigquery_dataset_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -dataset = attribute('dataset', default: <%= JSON.pretty_generate(grab_attributes['dataset']) -%>, description: 'BigQuery dataset definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +dataset = attribute('dataset', default: <%= JSON.pretty_generate(grab_attributes(pwd)['dataset']) -%>, description: 'BigQuery dataset definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_bigquery_dataset/google_bigquery_datasets.erb b/templates/inspec/examples/google_bigquery_dataset/google_bigquery_datasets.erb index 326afb3e0ae7..a293484ca1a3 100644 --- a/templates/inspec/examples/google_bigquery_dataset/google_bigquery_datasets.erb +++ b/templates/inspec/examples/google_bigquery_dataset/google_bigquery_datasets.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% dataset = grab_attributes['dataset'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% dataset = grab_attributes(pwd)['dataset'] -%> describe google_bigquery_datasets(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>) do its('count') { should be >= 1 } its('friendly_names') { should include <%= doc_generation ? "'#{dataset['friendly_name']}'" : "dataset['friendly_name']" -%> } diff --git a/templates/inspec/examples/google_bigquery_table/google_bigquery_table.erb b/templates/inspec/examples/google_bigquery_table/google_bigquery_table.erb index 770313f62ea3..32e42aca5389 100644 --- a/templates/inspec/examples/google_bigquery_table/google_bigquery_table.erb +++ b/templates/inspec/examples/google_bigquery_table/google_bigquery_table.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% bigquery_table = grab_attributes['bigquery_table'] -%> -<% dataset = grab_attributes['dataset'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% bigquery_table = grab_attributes(pwd)['bigquery_table'] -%> +<% dataset = grab_attributes(pwd)['dataset'] -%> describe google_bigquery_table(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, dataset: <%= doc_generation ? "'#{dataset['dataset_id']}'" : "dataset['dataset_id']" -%>, name: <%= doc_generation ? "'#{bigquery_table['table_id']}'" : "bigquery_table['table_id']" -%>) do it { should exist } diff --git a/templates/inspec/examples/google_bigquery_table/google_bigquery_table_attributes.erb b/templates/inspec/examples/google_bigquery_table/google_bigquery_table_attributes.erb index cadbae7d6ce1..adbb802ba3ce 100644 --- a/templates/inspec/examples/google_bigquery_table/google_bigquery_table_attributes.erb +++ b/templates/inspec/examples/google_bigquery_table/google_bigquery_table_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -bigquery_table = attribute('bigquery_table', default: <%= JSON.pretty_generate(grab_attributes['bigquery_table']) -%>, description: 'BigQuery table definition') -dataset = attribute('dataset', default: <%= JSON.pretty_generate(grab_attributes['dataset']) -%>, description: 'BigQuery dataset definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +bigquery_table = attribute('bigquery_table', default: <%= JSON.pretty_generate(grab_attributes(pwd)['bigquery_table']) -%>, description: 'BigQuery table definition') +dataset = attribute('dataset', default: <%= JSON.pretty_generate(grab_attributes(pwd)['dataset']) -%>, description: 'BigQuery dataset definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_bigquery_table/google_bigquery_tables.erb b/templates/inspec/examples/google_bigquery_table/google_bigquery_tables.erb index 9071803b6104..bf256a6a96ac 100644 --- a/templates/inspec/examples/google_bigquery_table/google_bigquery_tables.erb +++ b/templates/inspec/examples/google_bigquery_table/google_bigquery_tables.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% bigquery_table = grab_attributes['bigquery_table'] -%> -<% dataset = grab_attributes['dataset'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% bigquery_table = grab_attributes(pwd)['bigquery_table'] -%> +<% dataset = grab_attributes(pwd)['dataset'] -%> describe.one do google_bigquery_tables(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, dataset: <%= doc_generation ? "'#{dataset['dataset_id']}'" : "dataset['dataset_id']" -%>).table_references.each do |table_reference| describe google_bigquery_table(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, dataset: <%= doc_generation ? "'#{dataset['dataset_id']}'" : "dataset['dataset_id']" -%>, name: table_reference.table_id) do diff --git a/templates/inspec/examples/google_billing_project_billing_info/google_billing_project_billing_info.erb b/templates/inspec/examples/google_billing_project_billing_info/google_billing_project_billing_info.erb index 7e300f5bf870..e62897471a67 100644 --- a/templates/inspec/examples/google_billing_project_billing_info/google_billing_project_billing_info.erb +++ b/templates/inspec/examples/google_billing_project_billing_info/google_billing_project_billing_info.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_billing_account = "#{external_attribute('gcp_billing_account', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_billing_account = "#{external_attribute(pwd, 'gcp_billing_account', doc_generation)}" -%> describe google_billing_project_billing_info(project_id: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>) do it { should exist } diff --git a/templates/inspec/examples/google_billing_project_billing_info/google_billing_project_billing_info_attributes.erb b/templates/inspec/examples/google_billing_project_billing_info/google_billing_project_billing_info_attributes.erb index 7e92ede4c630..d99baef0d604 100644 --- a/templates/inspec/examples/google_billing_project_billing_info/google_billing_project_billing_info_attributes.erb +++ b/templates/inspec/examples/google_billing_project_billing_info/google_billing_project_billing_info_attributes.erb @@ -1,4 +1,4 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_billing_account = attribute(:gcp_billing_account, default: '<%= external_attribute('gcp_billing_account') -%>', description: 'The GCP billing account name.') -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization') +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_billing_account = attribute(:gcp_billing_account, default: '<%= external_attribute(pwd, 'gcp_billing_account') -%>', description: 'The GCP billing account name.') +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization') gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default:0, description:'Flag to enable privileged resources requiring elevated privileges in GCP.') \ No newline at end of file diff --git a/templates/inspec/examples/google_cloud_scheduler_job/google_cloud_scheduler_job.erb b/templates/inspec/examples/google_cloud_scheduler_job/google_cloud_scheduler_job.erb index 5b73eb3fb4d0..de9fc2f37ca9 100644 --- a/templates/inspec/examples/google_cloud_scheduler_job/google_cloud_scheduler_job.erb +++ b/templates/inspec/examples/google_cloud_scheduler_job/google_cloud_scheduler_job.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% scheduler_job = grab_attributes['scheduler_job'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% scheduler_job = grab_attributes(pwd)['scheduler_job'] -%> describe google_cloud_scheduler_job(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, region: <%= doc_generation ? "#{scheduler_job['region']}" : "scheduler_job['region']" -%>, name: <%= doc_generation ? "'#{scheduler_job['name']}'" : "scheduler_job['name']" -%>) do it { should exist } diff --git a/templates/inspec/examples/google_cloud_scheduler_job/google_cloud_scheduler_job_attributes.erb b/templates/inspec/examples/google_cloud_scheduler_job/google_cloud_scheduler_job_attributes.erb index 3a89f2879e3b..d11ee01546a4 100644 --- a/templates/inspec/examples/google_cloud_scheduler_job/google_cloud_scheduler_job_attributes.erb +++ b/templates/inspec/examples/google_cloud_scheduler_job/google_cloud_scheduler_job_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -scheduler_job = attribute('scheduler_job', default: <%= JSON.pretty_generate(grab_attributes['scheduler_job']) -%>, description: 'Cloud Scheduler Job configuration') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +scheduler_job = attribute('scheduler_job', default: <%= JSON.pretty_generate(grab_attributes(pwd)['scheduler_job']) -%>, description: 'Cloud Scheduler Job configuration') \ No newline at end of file diff --git a/templates/inspec/examples/google_cloud_scheduler_job/google_cloud_scheduler_jobs.erb b/templates/inspec/examples/google_cloud_scheduler_job/google_cloud_scheduler_jobs.erb index 4406cf0a2311..945af3861a02 100644 --- a/templates/inspec/examples/google_cloud_scheduler_job/google_cloud_scheduler_jobs.erb +++ b/templates/inspec/examples/google_cloud_scheduler_job/google_cloud_scheduler_jobs.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% scheduler_job = grab_attributes['scheduler_job'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% scheduler_job = grab_attributes(pwd)['scheduler_job'] -%> google_cloud_scheduler_jobs(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, region: <%= doc_generation ? "#{scheduler_job['location']}" : "scheduler_job['location']" -%>).names.each do |name| describe google_cloud_scheduler_job(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, region: <%= doc_generation ? "#{scheduler_job['region']}" : "scheduler_job['region']" -%>, name: name) do it { should exist } diff --git a/templates/inspec/examples/google_cloudbuild_trigger/google_cloudbuild_trigger.erb b/templates/inspec/examples/google_cloudbuild_trigger/google_cloudbuild_trigger.erb index 3e85fc74ff3c..2658bfa017ef 100644 --- a/templates/inspec/examples/google_cloudbuild_trigger/google_cloudbuild_trigger.erb +++ b/templates/inspec/examples/google_cloudbuild_trigger/google_cloudbuild_trigger.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% trigger = grab_attributes['trigger'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% trigger = grab_attributes(pwd)['trigger'] -%> describe google_cloudbuild_triggers(project: <%= gcp_project_id -%>) do its('count') { should eq 1 } end diff --git a/templates/inspec/examples/google_cloudbuild_trigger/google_cloudbuild_trigger_attributes.erb b/templates/inspec/examples/google_cloudbuild_trigger/google_cloudbuild_trigger_attributes.erb index c96172035e84..32243cf57e81 100644 --- a/templates/inspec/examples/google_cloudbuild_trigger/google_cloudbuild_trigger_attributes.erb +++ b/templates/inspec/examples/google_cloudbuild_trigger/google_cloudbuild_trigger_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -trigger = attribute('trigger', default: <%= JSON.pretty_generate(grab_attributes['trigger']) -%>, description: 'CloudBuild trigger definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +trigger = attribute('trigger', default: <%= JSON.pretty_generate(grab_attributes(pwd)['trigger']) -%>, description: 'CloudBuild trigger definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_cloudbuild_trigger/google_cloudbuild_triggers.erb b/templates/inspec/examples/google_cloudbuild_trigger/google_cloudbuild_triggers.erb index 3e85fc74ff3c..2658bfa017ef 100644 --- a/templates/inspec/examples/google_cloudbuild_trigger/google_cloudbuild_triggers.erb +++ b/templates/inspec/examples/google_cloudbuild_trigger/google_cloudbuild_triggers.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% trigger = grab_attributes['trigger'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% trigger = grab_attributes(pwd)['trigger'] -%> describe google_cloudbuild_triggers(project: <%= gcp_project_id -%>) do its('count') { should eq 1 } end diff --git a/templates/inspec/examples/google_cloudfunctions_cloud_function/google_cloudfunctions_cloud_function.erb b/templates/inspec/examples/google_cloudfunctions_cloud_function/google_cloudfunctions_cloud_function.erb index 6a31a1bf46a7..e88608a51cdd 100644 --- a/templates/inspec/examples/google_cloudfunctions_cloud_function/google_cloudfunctions_cloud_function.erb +++ b/templates/inspec/examples/google_cloudfunctions_cloud_function/google_cloudfunctions_cloud_function.erb @@ -1,11 +1,11 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_cloud_function_region = "#{external_attribute('gcp_cloud_function_region', doc_generation)}" -%> -<% cloudfunction = grab_attributes['cloudfunction'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_cloud_function_region = "#{external_attribute(pwd, 'gcp_cloud_function_region', doc_generation)}" -%> +<% cloudfunction = grab_attributes(pwd)['cloudfunction'] -%> describe google_cloudfunctions_cloud_function(project: <%= gcp_project_id -%>, location: <%= gcp_cloud_function_region -%>, name: <%= doc_generation ? "'#{cloudfunction['name']}'" : "cloudfunction['name']" -%>) do it { should exist } its('description') { should eq <%= doc_generation ? "'#{cloudfunction['description']}'" : "cloudfunction['description']" -%> } its('available_memory_mb') { should eq <%= doc_generation ? "'#{cloudfunction['available_memory_mb']}'" : "cloudfunction['available_memory_mb']" -%> } - its('https_trigger.url') { should match /\/<%= "#{grab_attributes['cloudfunction']['name']}" -%>$/ } + its('https_trigger.url') { should match /\/<%= "#{grab_attributes(pwd)['cloudfunction']['name']}" -%>$/ } its('entry_point') { should eq <%= doc_generation ? "'#{cloudfunction['entry_point']}'" : "cloudfunction['entry_point']" -%> } its('environment_variables') { should include('MY_ENV_VAR' => <%= doc_generation ? "'#{cloudfunction['env_var_value']}'" : "cloudfunction['env_var_value']" -%>) } end diff --git a/templates/inspec/examples/google_cloudfunctions_cloud_function/google_cloudfunctions_cloud_function_attributes.erb b/templates/inspec/examples/google_cloudfunctions_cloud_function/google_cloudfunctions_cloud_function_attributes.erb index 7665cfa9ee65..d16cc55b34d8 100644 --- a/templates/inspec/examples/google_cloudfunctions_cloud_function/google_cloudfunctions_cloud_function_attributes.erb +++ b/templates/inspec/examples/google_cloudfunctions_cloud_function/google_cloudfunctions_cloud_function_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_cloud_function_region = attribute(:gcp_cloud_function_region, default: '<%= external_attribute('gcp_cloud_function_region') -%>', description: 'The Cloud Function region.') -cloudfunction = attribute('cloudfunction', default: <%= JSON.pretty_generate(grab_attributes['cloudfunction']) -%>, description: 'Cloud Function definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_cloud_function_region = attribute(:gcp_cloud_function_region, default: '<%= external_attribute(pwd, 'gcp_cloud_function_region') -%>', description: 'The Cloud Function region.') +cloudfunction = attribute('cloudfunction', default: <%= JSON.pretty_generate(grab_attributes(pwd)['cloudfunction']) -%>, description: 'Cloud Function definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_cloudfunctions_cloud_function/google_cloudfunctions_cloud_functions.erb b/templates/inspec/examples/google_cloudfunctions_cloud_function/google_cloudfunctions_cloud_functions.erb index 687c59436314..acecfacba322 100644 --- a/templates/inspec/examples/google_cloudfunctions_cloud_function/google_cloudfunctions_cloud_functions.erb +++ b/templates/inspec/examples/google_cloudfunctions_cloud_function/google_cloudfunctions_cloud_functions.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_cloud_function_region = "#{external_attribute('gcp_cloud_function_region', doc_generation)}" -%> -<% cloudfunction = grab_attributes['cloudfunction'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_cloud_function_region = "#{external_attribute(pwd, 'gcp_cloud_function_region', doc_generation)}" -%> +<% cloudfunction = grab_attributes(pwd)['cloudfunction'] -%> describe google_cloudfunctions_cloud_functions(project: <%= gcp_project_id -%>, location: <%= gcp_cloud_function_region -%>) do its('descriptions') { should include <%= doc_generation ? "'#{cloudfunction['description']}'" : "cloudfunction['description']" -%> } its('entry_points') { should include <%= doc_generation ? "'#{cloudfunction['entry_point']}'" : "cloudfunction['entry_point']" -%> } diff --git a/templates/inspec/examples/google_compute_address/google_compute_address.erb b/templates/inspec/examples/google_compute_address/google_compute_address.erb index 446d4ff7cc9d..0cee97fb8549 100644 --- a/templates/inspec/examples/google_compute_address/google_compute_address.erb +++ b/templates/inspec/examples/google_compute_address/google_compute_address.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% address = grab_attributes['address'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% address = grab_attributes(pwd)['address'] -%> describe google_compute_address(project: <%= gcp_project_id -%>, location: <%= gcp_location -%>, name: <%= doc_generation ? "'#{address['name']}'" : "address['name']" -%>) do it { should exist } its('address') { should eq <%= doc_generation ? "'#{address['address']}'" : "address['address']" -%> } diff --git a/templates/inspec/examples/google_compute_address/google_compute_address_attributes.erb b/templates/inspec/examples/google_compute_address/google_compute_address_attributes.erb index b73f6a88cc98..fcb18e906c5e 100644 --- a/templates/inspec/examples/google_compute_address/google_compute_address_attributes.erb +++ b/templates/inspec/examples/google_compute_address/google_compute_address_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'The GCP project region.') -address = attribute('address', default: <%= JSON.pretty_generate(grab_attributes['address']) -%>, description: 'Address definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_location = attribute(:gcp_location, default: '<%= external_attribute(pwd, 'gcp_location') -%>', description: 'The GCP project region.') +address = attribute('address', default: <%= JSON.pretty_generate(grab_attributes(pwd)['address']) -%>, description: 'Address definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_address/google_compute_addresses.erb b/templates/inspec/examples/google_compute_address/google_compute_addresses.erb index 49075598d54f..264a7bf03ba3 100644 --- a/templates/inspec/examples/google_compute_address/google_compute_addresses.erb +++ b/templates/inspec/examples/google_compute_address/google_compute_addresses.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% address = grab_attributes['address'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% address = grab_attributes(pwd)['address'] -%> describe google_compute_addresses(project: <%= gcp_project_id -%>, location: <%= gcp_location -%>) do its('addresses') { should include <%= doc_generation ? "'#{address['address']}'" : "address['address']" -%> } its('names') { should include <%= doc_generation ? "'#{address['name']}'" : "address['name']" -%> } diff --git a/templates/inspec/examples/google_compute_autoscaler/google_compute_autoscaler.erb b/templates/inspec/examples/google_compute_autoscaler/google_compute_autoscaler.erb index b5c47a0a8498..1f58db41928e 100644 --- a/templates/inspec/examples/google_compute_autoscaler/google_compute_autoscaler.erb +++ b/templates/inspec/examples/google_compute_autoscaler/google_compute_autoscaler.erb @@ -1,10 +1,10 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_zone = "#{external_attribute('gcp_zone', doc_generation)}" -%> -<% autoscaler = grab_attributes['autoscaler'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_zone = "#{external_attribute(pwd, 'gcp_zone', doc_generation)}" -%> +<% autoscaler = grab_attributes(pwd)['autoscaler'] -%> describe google_compute_autoscaler(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, zone: <%= doc_generation ? "#{gcp_zone}" : "gcp_zone" -%>, name: <%= doc_generation ? "'#{autoscaler['name']}'" : "autoscaler['name']" -%>) do it { should exist } - its('target') { should match /\/<%= "#{grab_attributes['instance_group_manager']['name']}" -%>$/ } + its('target') { should match /\/<%= "#{grab_attributes(pwd)['instance_group_manager']['name']}" -%>$/ } its('autoscaling_policy.max_num_replicas') { should eq <%= doc_generation ? "'#{autoscaler['max_replicas']}'" : "autoscaler['max_replicas']" -%> } its('autoscaling_policy.min_num_replicas') { should eq <%= doc_generation ? "'#{autoscaler['min_replicas']}'" : "autoscaler['min_replicas']" -%> } its('autoscaling_policy.cool_down_period_sec') { should eq <%= doc_generation ? "'#{autoscaler['cooldown_period']}'" : "autoscaler['cooldown_period']" -%> } diff --git a/templates/inspec/examples/google_compute_autoscaler/google_compute_autoscaler_attributes.erb b/templates/inspec/examples/google_compute_autoscaler/google_compute_autoscaler_attributes.erb index f478953f4152..5d6315ede0bb 100644 --- a/templates/inspec/examples/google_compute_autoscaler/google_compute_autoscaler_attributes.erb +++ b/templates/inspec/examples/google_compute_autoscaler/google_compute_autoscaler_attributes.erb @@ -1,4 +1,4 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_zone = attribute(:gcp_zone, default: '<%= external_attribute('gcp_zone') -%>', description: 'The GCP project zone.') -instance_group_manager = attribute('instance_group_manager', default: <%= JSON.pretty_generate(grab_attributes['instance_group_manager']) -%>, description: 'Instance group manager definition') -autoscaler = attribute('autoscaler', default: <%= JSON.pretty_generate(grab_attributes['autoscaler']) -%>, description: 'Autoscaler definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_zone = attribute(:gcp_zone, default: '<%= external_attribute(pwd, 'gcp_zone') -%>', description: 'The GCP project zone.') +instance_group_manager = attribute('instance_group_manager', default: <%= JSON.pretty_generate(grab_attributes(pwd)['instance_group_manager']) -%>, description: 'Instance group manager definition') +autoscaler = attribute('autoscaler', default: <%= JSON.pretty_generate(grab_attributes(pwd)['autoscaler']) -%>, description: 'Autoscaler definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_autoscaler/google_compute_autoscalers.erb b/templates/inspec/examples/google_compute_autoscaler/google_compute_autoscalers.erb index fc9d3bd4656e..3c889c152a88 100644 --- a/templates/inspec/examples/google_compute_autoscaler/google_compute_autoscalers.erb +++ b/templates/inspec/examples/google_compute_autoscaler/google_compute_autoscalers.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_zone = "#{external_attribute('gcp_zone', doc_generation)}" -%> -<% autoscaler = grab_attributes['autoscaler'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_zone = "#{external_attribute(pwd, 'gcp_zone', doc_generation)}" -%> +<% autoscaler = grab_attributes(pwd)['autoscaler'] -%> autoscalers = google_compute_autoscalers(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, zone: <%= doc_generation ? "#{gcp_zone}" : "gcp_zone" -%>) describe.one do autoscalers.autoscaling_policies.each do |autoscaling_policy| diff --git a/templates/inspec/examples/google_compute_backend_bucket/google_compute_backend_bucket.erb b/templates/inspec/examples/google_compute_backend_bucket/google_compute_backend_bucket.erb index 67d8f0798112..9c7d881256bc 100644 --- a/templates/inspec/examples/google_compute_backend_bucket/google_compute_backend_bucket.erb +++ b/templates/inspec/examples/google_compute_backend_bucket/google_compute_backend_bucket.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_storage_bucket_name = "#{external_attribute('gcp_storage_bucket_name', doc_generation)}" -%> -<% backend_bucket = grab_attributes['backend_bucket'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_storage_bucket_name = "#{external_attribute(pwd, 'gcp_storage_bucket_name', doc_generation)}" -%> +<% backend_bucket = grab_attributes(pwd)['backend_bucket'] -%> describe google_compute_backend_bucket(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{backend_bucket['name']}'" : "backend_bucket['name']" -%>) do it { should exist } its('description') { should eq <%= doc_generation ? "'#{backend_bucket['description']}'" : "backend_bucket['description']" -%> } diff --git a/templates/inspec/examples/google_compute_backend_bucket/google_compute_backend_bucket_attributes.erb b/templates/inspec/examples/google_compute_backend_bucket/google_compute_backend_bucket_attributes.erb index 2a46730a8143..e1b6caaee2ef 100644 --- a/templates/inspec/examples/google_compute_backend_bucket/google_compute_backend_bucket_attributes.erb +++ b/templates/inspec/examples/google_compute_backend_bucket/google_compute_backend_bucket_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_storage_bucket_name = attribute(:gcp_storage_bucket_name, default: '<%= external_attribute('gcp_storage_bucket_name') -%>', description: 'The GCS bucket name to use for the backend bucket.') -backend_bucket = attribute('backend_bucket', default: <%= JSON.pretty_generate(grab_attributes['backend_bucket']) -%>, description: 'Backend bucket definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_storage_bucket_name = attribute(:gcp_storage_bucket_name, default: '<%= external_attribute(pwd, 'gcp_storage_bucket_name') -%>', description: 'The GCS bucket name to use for the backend bucket.') +backend_bucket = attribute('backend_bucket', default: <%= JSON.pretty_generate(grab_attributes(pwd)['backend_bucket']) -%>, description: 'Backend bucket definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_backend_bucket/google_compute_backend_buckets.erb b/templates/inspec/examples/google_compute_backend_bucket/google_compute_backend_buckets.erb index 2d5fd5a9c5fc..7306eaffe1bd 100644 --- a/templates/inspec/examples/google_compute_backend_bucket/google_compute_backend_buckets.erb +++ b/templates/inspec/examples/google_compute_backend_bucket/google_compute_backend_buckets.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_storage_bucket_name = "#{external_attribute('gcp_storage_bucket_name', doc_generation)}" -%> -<% backend_bucket = grab_attributes['backend_bucket'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_storage_bucket_name = "#{external_attribute(pwd, 'gcp_storage_bucket_name', doc_generation)}" -%> +<% backend_bucket = grab_attributes(pwd)['backend_bucket'] -%> describe google_compute_backend_buckets(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{backend_bucket['name']}'" : "backend_bucket['name']" -%>) do its('descriptions') { should include <%= doc_generation ? "'#{backend_bucket['description']}'" : "backend_bucket['description']" -%> } <% if doc_generation # bucket name is partially random, this ruins VCR in integration tests -%> diff --git a/templates/inspec/examples/google_compute_backend_service/google_compute_backend_service.erb b/templates/inspec/examples/google_compute_backend_service/google_compute_backend_service.erb index 7fcd87046cf4..68635ea8dd11 100644 --- a/templates/inspec/examples/google_compute_backend_service/google_compute_backend_service.erb +++ b/templates/inspec/examples/google_compute_backend_service/google_compute_backend_service.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% backend_service = grab_attributes['backend_service'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% backend_service = grab_attributes(pwd)['backend_service'] -%> describe google_compute_backend_service(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{backend_service['name']}'" : "backend_service['name']" -%>) do it { should exist } its('description') { should eq <%= doc_generation ? "'#{backend_service['description']}'" : "backend_service['description']" -%> } diff --git a/templates/inspec/examples/google_compute_backend_service/google_compute_backend_service_attributes.erb b/templates/inspec/examples/google_compute_backend_service/google_compute_backend_service_attributes.erb index a672702c6a72..8a62223696f1 100644 --- a/templates/inspec/examples/google_compute_backend_service/google_compute_backend_service_attributes.erb +++ b/templates/inspec/examples/google_compute_backend_service/google_compute_backend_service_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -backend_service = attribute('backend_service', default: <%= JSON.pretty_generate(grab_attributes['backend_service']) -%>, description: 'Backend service definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +backend_service = attribute('backend_service', default: <%= JSON.pretty_generate(grab_attributes(pwd)['backend_service']) -%>, description: 'Backend service definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_backend_service/google_compute_backend_services.erb b/templates/inspec/examples/google_compute_backend_service/google_compute_backend_services.erb index 7c7e7cc29d58..8462d7df9045 100644 --- a/templates/inspec/examples/google_compute_backend_service/google_compute_backend_services.erb +++ b/templates/inspec/examples/google_compute_backend_service/google_compute_backend_services.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% backend_service = grab_attributes['backend_service'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% backend_service = grab_attributes(pwd)['backend_service'] -%> describe google_compute_backend_services(project: <%= gcp_project_id -%>) do its('count') { should be >= 1 } its('names') { should include <%= doc_generation ? "'#{backend_service['name']}'" : "backend_service['name']" -%> } diff --git a/templates/inspec/examples/google_compute_disk/google_compute_disk.erb b/templates/inspec/examples/google_compute_disk/google_compute_disk.erb index d00ed63614b0..a9cc19a9811f 100644 --- a/templates/inspec/examples/google_compute_disk/google_compute_disk.erb +++ b/templates/inspec/examples/google_compute_disk/google_compute_disk.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_zone = "#{external_attribute('gcp_zone', doc_generation)}" %> -<% snapshot = grab_attributes['snapshot'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_zone = "#{external_attribute(pwd, 'gcp_zone', doc_generation)}" %> +<% snapshot = grab_attributes(pwd)['snapshot'] -%> <% gcp_compute_disk_name = snapshot["disk_name"] -%> <% gcp_compute_disk_image = snapshot["disk_image"] -%> <% gcp_compute_disk_type = snapshot["disk_type"] -%> diff --git a/templates/inspec/examples/google_compute_disk/google_compute_disk_attributes.erb b/templates/inspec/examples/google_compute_disk/google_compute_disk_attributes.erb index 9de6cdaa0312..b426d63eebf8 100644 --- a/templates/inspec/examples/google_compute_disk/google_compute_disk_attributes.erb +++ b/templates/inspec/examples/google_compute_disk/google_compute_disk_attributes.erb @@ -1,6 +1,6 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_zone = attribute(:gcp_zone, default: '<%= external_attribute('gcp_zone') -%>', description: 'The GCP project zone.') -snapshot = attribute('snapshot', default: <%= JSON.pretty_generate(grab_attributes['snapshot']) -%>, description: 'Disk snapshot description') +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_zone = attribute(:gcp_zone, default: '<%= external_attribute(pwd, 'gcp_zone') -%>', description: 'The GCP project zone.') +snapshot = attribute('snapshot', default: <%= JSON.pretty_generate(grab_attributes(pwd)['snapshot']) -%>, description: 'Disk snapshot description') gcp_compute_disk_name = snapshot["disk_name"] gcp_compute_disk_image = snapshot["disk_image"] gcp_compute_disk_type = snapshot["disk_type"] \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_disk/google_compute_disks.erb b/templates/inspec/examples/google_compute_disk/google_compute_disks.erb index f09c940b9de2..5e2196b501a1 100644 --- a/templates/inspec/examples/google_compute_disk/google_compute_disks.erb +++ b/templates/inspec/examples/google_compute_disk/google_compute_disks.erb @@ -1,7 +1,7 @@ -<% snapshot = grab_attributes['snapshot'] -%> +<% snapshot = grab_attributes(pwd)['snapshot'] -%> <% gcp_compute_disk_image = "#{snapshot["disk_image"].gsub('\'', '')}" -%> most_recent_image = google_compute_image(project: <%= doc_generation ? "'#{gcp_compute_disk_image.split('/').first}'" : "gcp_compute_disk_image.split('/').first" -%>, name: <%= doc_generation ? "'#{gcp_compute_disk_image.split('/').last}'" : "gcp_compute_disk_image.split('/').last" -%>) -describe google_compute_disks(project: <%= "#{external_attribute('gcp_project_id', doc_generation)}" -%>, zone: <%= "#{external_attribute('gcp_zone', doc_generation)}" -%>) do +describe google_compute_disks(project: <%= "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%>, zone: <%= "#{external_attribute(pwd, 'gcp_zone', doc_generation)}" -%>) do it { should exist } its('names') { should include <%= doc_generation ? "'#{snapshot['disk_name']}'" : "snapshot['disk_name']" -%> } its('source_images') { should include most_recent_image.self_link } diff --git a/templates/inspec/examples/google_compute_firewall/google_compute_firewall.erb b/templates/inspec/examples/google_compute_firewall/google_compute_firewall.erb index 0b21ca50971a..000738d3b490 100644 --- a/templates/inspec/examples/google_compute_firewall/google_compute_firewall.erb +++ b/templates/inspec/examples/google_compute_firewall/google_compute_firewall.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% firewall = grab_attributes['firewall'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% firewall = grab_attributes(pwd)['firewall'] -%> describe google_compute_firewall(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{firewall['name']}'" : "firewall['name']" -%>) do its('direction') { should cmp 'INGRESS' } its('log_config_enabled?') { should be true } diff --git a/templates/inspec/examples/google_compute_firewall/google_compute_firewall_attributes.erb b/templates/inspec/examples/google_compute_firewall/google_compute_firewall_attributes.erb index 018e6e33fd4a..35324e120e66 100644 --- a/templates/inspec/examples/google_compute_firewall/google_compute_firewall_attributes.erb +++ b/templates/inspec/examples/google_compute_firewall/google_compute_firewall_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -firewall = attribute('firewall', default: <%= JSON.pretty_generate(grab_attributes['firewall']) -%>, description: 'Firewall rule definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +firewall = attribute('firewall', default: <%= JSON.pretty_generate(grab_attributes(pwd)['firewall']) -%>, description: 'Firewall rule definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_firewall/google_compute_firewalls.erb b/templates/inspec/examples/google_compute_firewall/google_compute_firewalls.erb index 32f52b6350e2..eaba7efcb441 100644 --- a/templates/inspec/examples/google_compute_firewall/google_compute_firewalls.erb +++ b/templates/inspec/examples/google_compute_firewall/google_compute_firewalls.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% firewall = grab_attributes['firewall'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% firewall = grab_attributes(pwd)['firewall'] -%> describe google_compute_firewalls(project: <%= gcp_project_id -%>) do its('count') { should be >= 1 } its('firewall_names') { should include <%= doc_generation ? "'#{firewall['name']}'" : "firewall['name']" -%> } diff --git a/templates/inspec/examples/google_compute_forwarding_rule/google_compute_forwarding_rule.erb b/templates/inspec/examples/google_compute_forwarding_rule/google_compute_forwarding_rule.erb index ff1bbd869e27..42b81d8dd856 100644 --- a/templates/inspec/examples/google_compute_forwarding_rule/google_compute_forwarding_rule.erb +++ b/templates/inspec/examples/google_compute_forwarding_rule/google_compute_forwarding_rule.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_lb_region = "#{external_attribute('gcp_lb_region', doc_generation)}" -%> -<% gcp_fr_udp_name = "#{external_attribute('gcp_fr_udp_name', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_lb_region = "#{external_attribute(pwd, 'gcp_lb_region', doc_generation)}" -%> +<% gcp_fr_udp_name = "#{external_attribute(pwd, 'gcp_fr_udp_name', doc_generation)}" -%> describe google_compute_forwarding_rule(project: <%= gcp_project_id -%>, region: <%= gcp_lb_region -%>, name: <%= doc_generation ? gcp_fr_udp_name : "\"\#{gcp_fr_udp_name}-500\"" -%>) do it { should exist } diff --git a/templates/inspec/examples/google_compute_forwarding_rule/google_compute_forwarding_rule_attributes.erb b/templates/inspec/examples/google_compute_forwarding_rule/google_compute_forwarding_rule_attributes.erb index d9f39a586f8d..e6aa0dab921f 100644 --- a/templates/inspec/examples/google_compute_forwarding_rule/google_compute_forwarding_rule_attributes.erb +++ b/templates/inspec/examples/google_compute_forwarding_rule/google_compute_forwarding_rule_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_lb_region = attribute(:gcp_lb_region, default: '<%= external_attribute('gcp_lb_region') -%>', description: 'The region used for the forwarding rule.') -gcp_fr_udp_name = attribute(:gcp_fr_udp_name, default: '<%= external_attribute('gcp_fr_udp_name') -%>', description: 'The forwarding rule name.') +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_lb_region = attribute(:gcp_lb_region, default: '<%= external_attribute(pwd, 'gcp_lb_region') -%>', description: 'The region used for the forwarding rule.') +gcp_fr_udp_name = attribute(:gcp_fr_udp_name, default: '<%= external_attribute(pwd, 'gcp_fr_udp_name') -%>', description: 'The forwarding rule name.') diff --git a/templates/inspec/examples/google_compute_forwarding_rule/google_compute_forwarding_rules.erb b/templates/inspec/examples/google_compute_forwarding_rule/google_compute_forwarding_rules.erb index 1054439a7ae1..4663581f0f5b 100644 --- a/templates/inspec/examples/google_compute_forwarding_rule/google_compute_forwarding_rules.erb +++ b/templates/inspec/examples/google_compute_forwarding_rule/google_compute_forwarding_rules.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_lb_region = "#{external_attribute('gcp_lb_region', doc_generation)}" -%> -<% gcp_fr_udp_name = "#{external_attribute('gcp_fr_udp_name', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_lb_region = "#{external_attribute(pwd, 'gcp_lb_region', doc_generation)}" -%> +<% gcp_fr_udp_name = "#{external_attribute(pwd, 'gcp_fr_udp_name', doc_generation)}" -%> describe google_compute_forwarding_rules(project: <%= gcp_project_id -%>, region: <%= gcp_lb_region -%>) do its('forwarding_rule_names') { should include <%= doc_generation ? gcp_fr_udp_name : "\"\#{gcp_fr_udp_name}-500\"" -%> } diff --git a/templates/inspec/examples/google_compute_global_address/google_compute_global_address.erb b/templates/inspec/examples/google_compute_global_address/google_compute_global_address.erb index 56ed5d7d1ea9..7be07c5888aa 100644 --- a/templates/inspec/examples/google_compute_global_address/google_compute_global_address.erb +++ b/templates/inspec/examples/google_compute_global_address/google_compute_global_address.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% global_address = grab_attributes['global_address'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% global_address = grab_attributes(pwd)['global_address'] -%> describe google_compute_global_address(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{global_address['name']}'" : "global_address['name']" -%>) do it { should exist } its('ip_version') { should eq <%= doc_generation ? "'#{global_address['ip_version']}'" : "global_address['ip_version']" -%> } diff --git a/templates/inspec/examples/google_compute_global_address/google_compute_global_address_attributes.erb b/templates/inspec/examples/google_compute_global_address/google_compute_global_address_attributes.erb index 6649541bc771..9f8b152276e7 100644 --- a/templates/inspec/examples/google_compute_global_address/google_compute_global_address_attributes.erb +++ b/templates/inspec/examples/google_compute_global_address/google_compute_global_address_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -global_address = attribute('global_address', default: <%= JSON.pretty_generate(grab_attributes['global_address']) -%>, description: 'Compute Global Address definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +global_address = attribute('global_address', default: <%= JSON.pretty_generate(grab_attributes(pwd)['global_address']) -%>, description: 'Compute Global Address definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_global_address/google_compute_global_addresses.erb b/templates/inspec/examples/google_compute_global_address/google_compute_global_addresses.erb index 9d2facd88721..b241e0f7e9f9 100644 --- a/templates/inspec/examples/google_compute_global_address/google_compute_global_addresses.erb +++ b/templates/inspec/examples/google_compute_global_address/google_compute_global_addresses.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% global_address = grab_attributes['global_address'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% global_address = grab_attributes(pwd)['global_address'] -%> describe google_compute_global_addresses(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{global_address['name']}'" : "global_address['name']" -%>) do its('count') { should be >= 1 } its('names') { should include <%= doc_generation ? "'#{global_address['name']}'" : "global_address['name']" -%> } diff --git a/templates/inspec/examples/google_compute_global_forwarding_rule/google_compute_global_forwarding_rule.erb b/templates/inspec/examples/google_compute_global_forwarding_rule/google_compute_global_forwarding_rule.erb index 451617be56bd..379e7ef49d02 100644 --- a/templates/inspec/examples/google_compute_global_forwarding_rule/google_compute_global_forwarding_rule.erb +++ b/templates/inspec/examples/google_compute_global_forwarding_rule/google_compute_global_forwarding_rule.erb @@ -1,9 +1,9 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% global_forwarding_rule = grab_attributes['global_forwarding_rule'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% global_forwarding_rule = grab_attributes(pwd)['global_forwarding_rule'] -%> describe google_compute_global_forwarding_rule(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, name: <%= doc_generation ? "'#{global_forwarding_rule['name']}'" : "global_forwarding_rule['name']" -%>) do it { should exist } its('port_range') { should eq <%= doc_generation ? "'#{global_forwarding_rule['port_range']}'" : "global_forwarding_rule['port_range']" -%> } - its('target') { should match /\/<%= "#{grab_attributes['http_proxy']['name']}" -%>$/ } + its('target') { should match /\/<%= "#{grab_attributes(pwd)['http_proxy']['name']}" -%>$/ } end describe google_compute_global_forwarding_rule(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, name: 'nonexistent') do diff --git a/templates/inspec/examples/google_compute_global_forwarding_rule/google_compute_global_forwarding_rule_attributes.erb b/templates/inspec/examples/google_compute_global_forwarding_rule/google_compute_global_forwarding_rule_attributes.erb index b28de737a3de..afb45a68c4c5 100644 --- a/templates/inspec/examples/google_compute_global_forwarding_rule/google_compute_global_forwarding_rule_attributes.erb +++ b/templates/inspec/examples/google_compute_global_forwarding_rule/google_compute_global_forwarding_rule_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -global_forwarding_rule = attribute('global_forwarding_rule', default: <%= JSON.pretty_generate(grab_attributes['global_forwarding_rule']) -%>, description: 'Compute global forwarding rule definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +global_forwarding_rule = attribute('global_forwarding_rule', default: <%= JSON.pretty_generate(grab_attributes(pwd)['global_forwarding_rule']) -%>, description: 'Compute global forwarding rule definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_global_forwarding_rule/google_compute_global_forwarding_rules.erb b/templates/inspec/examples/google_compute_global_forwarding_rule/google_compute_global_forwarding_rules.erb index 109c4857056a..a74d39ead5ee 100644 --- a/templates/inspec/examples/google_compute_global_forwarding_rule/google_compute_global_forwarding_rules.erb +++ b/templates/inspec/examples/google_compute_global_forwarding_rule/google_compute_global_forwarding_rules.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% global_forwarding_rule = grab_attributes['global_forwarding_rule'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% global_forwarding_rule = grab_attributes(pwd)['global_forwarding_rule'] -%> describe google_compute_global_forwarding_rules(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>) do its('count') { should be >= 1 } its('port_ranges') { should include <%= doc_generation ? "'#{global_forwarding_rule['port_range']}'" : "global_forwarding_rule['port_range']" -%> } diff --git a/templates/inspec/examples/google_compute_health_check/google_compute_health_check.erb b/templates/inspec/examples/google_compute_health_check/google_compute_health_check.erb index 30931f44ceca..562caa826e16 100644 --- a/templates/inspec/examples/google_compute_health_check/google_compute_health_check.erb +++ b/templates/inspec/examples/google_compute_health_check/google_compute_health_check.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% health_check = grab_attributes['health_check'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% health_check = grab_attributes(pwd)['health_check'] -%> describe google_compute_health_check(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, name: <%= doc_generation ? "'#{health_check['name']}'" : "health_check['name']" -%>) do it { should exist } its('timeout_sec') { should eq <%= doc_generation ? "'#{health_check['timeout_sec']}'" : "health_check['timeout_sec']" -%> } diff --git a/templates/inspec/examples/google_compute_health_check/google_compute_health_check_attributes.erb b/templates/inspec/examples/google_compute_health_check/google_compute_health_check_attributes.erb index 7b601264bd64..9a4940ad4fe0 100644 --- a/templates/inspec/examples/google_compute_health_check/google_compute_health_check_attributes.erb +++ b/templates/inspec/examples/google_compute_health_check/google_compute_health_check_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -health_check = attribute('health_check', default: <%= JSON.pretty_generate(grab_attributes['health_check']) -%>, description: 'Health check definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +health_check = attribute('health_check', default: <%= JSON.pretty_generate(grab_attributes(pwd)['health_check']) -%>, description: 'Health check definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_health_check/google_compute_health_checks.erb b/templates/inspec/examples/google_compute_health_check/google_compute_health_checks.erb index c367e583701c..1abe9f3c5b9d 100644 --- a/templates/inspec/examples/google_compute_health_check/google_compute_health_checks.erb +++ b/templates/inspec/examples/google_compute_health_check/google_compute_health_checks.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% health_check = grab_attributes['health_check'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% health_check = grab_attributes(pwd)['health_check'] -%> describe google_compute_health_checks(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>) do its('names') { should include <%= doc_generation ? "'#{health_check['name']}'" : "health_check['name']" -%> } its('timeout_secs') { should include <%= doc_generation ? "'#{health_check['timeout_sec']}'" : "health_check['timeout_sec']" -%> } diff --git a/templates/inspec/examples/google_compute_http_health_check/google_compute_http_health_check.erb b/templates/inspec/examples/google_compute_http_health_check/google_compute_http_health_check.erb index b8e7b5d6c652..fd8d25a2c163 100644 --- a/templates/inspec/examples/google_compute_http_health_check/google_compute_http_health_check.erb +++ b/templates/inspec/examples/google_compute_http_health_check/google_compute_http_health_check.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% http_health_check = grab_attributes['http_health_check'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% http_health_check = grab_attributes(pwd)['http_health_check'] -%> describe google_compute_http_health_check(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, name: <%= doc_generation ? "'#{http_health_check['name']}'" : "http_health_check['name']" -%>) do it { should exist } its('timeout_sec') { should eq <%= doc_generation ? "'#{http_health_check['timeout_sec']}'" : "http_health_check['timeout_sec']" -%> } diff --git a/templates/inspec/examples/google_compute_http_health_check/google_compute_http_health_check_attributes.erb b/templates/inspec/examples/google_compute_http_health_check/google_compute_http_health_check_attributes.erb index 80e5c6a6a9b8..3a8648e846aa 100644 --- a/templates/inspec/examples/google_compute_http_health_check/google_compute_http_health_check_attributes.erb +++ b/templates/inspec/examples/google_compute_http_health_check/google_compute_http_health_check_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -http_health_check = attribute('http_health_check', default: <%= JSON.pretty_generate(grab_attributes['http_health_check']) -%>, description: 'HTTP health check definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +http_health_check = attribute('http_health_check', default: <%= JSON.pretty_generate(grab_attributes(pwd)['http_health_check']) -%>, description: 'HTTP health check definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_http_health_check/google_compute_http_health_checks.erb b/templates/inspec/examples/google_compute_http_health_check/google_compute_http_health_checks.erb index 7e19b4f967e0..afc9f3f7cffe 100644 --- a/templates/inspec/examples/google_compute_http_health_check/google_compute_http_health_checks.erb +++ b/templates/inspec/examples/google_compute_http_health_check/google_compute_http_health_checks.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% http_health_check = grab_attributes['http_health_check'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% http_health_check = grab_attributes(pwd)['http_health_check'] -%> describe google_compute_http_health_checks(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>) do its('names') { should include <%= doc_generation ? "'#{http_health_check['name']}'" : "http_health_check['name']" -%> } its('timeout_secs') { should include <%= doc_generation ? "'#{http_health_check['timeout_sec']}'" : "http_health_check['timeout_sec']" -%> } diff --git a/templates/inspec/examples/google_compute_https_health_check/google_compute_https_health_check.erb b/templates/inspec/examples/google_compute_https_health_check/google_compute_https_health_check.erb index aa8a2440eb3c..d23793ace65c 100644 --- a/templates/inspec/examples/google_compute_https_health_check/google_compute_https_health_check.erb +++ b/templates/inspec/examples/google_compute_https_health_check/google_compute_https_health_check.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% https_health_check = grab_attributes['https_health_check'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% https_health_check = grab_attributes(pwd)['https_health_check'] -%> describe google_compute_https_health_check(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, name: <%= doc_generation ? "'#{https_health_check['name']}'" : "https_health_check['name']" -%>) do it { should exist } its('timeout_sec') { should eq <%= doc_generation ? "'#{https_health_check['timeout_sec']}'" : "https_health_check['timeout_sec']" -%> } diff --git a/templates/inspec/examples/google_compute_https_health_check/google_compute_https_health_check_attributes.erb b/templates/inspec/examples/google_compute_https_health_check/google_compute_https_health_check_attributes.erb index 45e945adfb91..515e2be4f1c9 100644 --- a/templates/inspec/examples/google_compute_https_health_check/google_compute_https_health_check_attributes.erb +++ b/templates/inspec/examples/google_compute_https_health_check/google_compute_https_health_check_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -https_health_check = attribute('https_health_check', default: <%= JSON.pretty_generate(grab_attributes['https_health_check']) -%>, description: 'HTTPS health check definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +https_health_check = attribute('https_health_check', default: <%= JSON.pretty_generate(grab_attributes(pwd)['https_health_check']) -%>, description: 'HTTPS health check definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_https_health_check/google_compute_https_health_checks.erb b/templates/inspec/examples/google_compute_https_health_check/google_compute_https_health_checks.erb index 3d88ada99330..2e034c04f66d 100644 --- a/templates/inspec/examples/google_compute_https_health_check/google_compute_https_health_checks.erb +++ b/templates/inspec/examples/google_compute_https_health_check/google_compute_https_health_checks.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% https_health_check = grab_attributes['https_health_check'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% https_health_check = grab_attributes(pwd)['https_health_check'] -%> describe google_compute_https_health_checks(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>) do its('names') { should include <%= doc_generation ? "'#{https_health_check['name']}'" : "https_health_check['name']" -%> } its('timeout_secs') { should include <%= doc_generation ? "'#{https_health_check['timeout_sec']}'" : "https_health_check['timeout_sec']" -%> } diff --git a/templates/inspec/examples/google_compute_image/google_compute_image.erb b/templates/inspec/examples/google_compute_image/google_compute_image.erb index 34a3d6fe7e83..93e3d1b2ae15 100644 --- a/templates/inspec/examples/google_compute_image/google_compute_image.erb +++ b/templates/inspec/examples/google_compute_image/google_compute_image.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% compute_image = grab_attributes['compute_image'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% compute_image = grab_attributes(pwd)['compute_image'] -%> describe google_compute_image(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{compute_image['name']}'" : "compute_image['name']" -%>) do it { should exist } its('disk_size_gb') { should cmp 3 } diff --git a/templates/inspec/examples/google_compute_image/google_compute_image_attributes.erb b/templates/inspec/examples/google_compute_image/google_compute_image_attributes.erb index 146c3fefc2a3..fb038a9af531 100644 --- a/templates/inspec/examples/google_compute_image/google_compute_image_attributes.erb +++ b/templates/inspec/examples/google_compute_image/google_compute_image_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -compute_image = attribute('compute_image', default: <%= JSON.pretty_generate(grab_attributes['compute_image']) -%>, description: 'Compute image description') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +compute_image = attribute('compute_image', default: <%= JSON.pretty_generate(grab_attributes(pwd)['compute_image']) -%>, description: 'Compute image description') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_instance/google_compute_instance.erb b/templates/inspec/examples/google_compute_instance/google_compute_instance.erb index 7344661529af..d5cd1612cc13 100644 --- a/templates/inspec/examples/google_compute_instance/google_compute_instance.erb +++ b/templates/inspec/examples/google_compute_instance/google_compute_instance.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_zone = "#{external_attribute('gcp_zone', doc_generation)}" %> -<% instance = grab_attributes['instance'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_zone = "#{external_attribute(pwd, 'gcp_zone', doc_generation)}" %> +<% instance = grab_attributes(pwd)['instance'] -%> describe google_compute_instance(project: <%= gcp_project_id -%>, zone: <%= gcp_zone -%>, name: <%= doc_generation ? "'#{instance['name']}'" : "instance['name']" -%>) do it { should exist } its('machine_type') { should match <%= doc_generation ? "'#{instance['machine_type']}'" : "instance['machine_type']" -%> } diff --git a/templates/inspec/examples/google_compute_instance/google_compute_instance_attributes.erb b/templates/inspec/examples/google_compute_instance/google_compute_instance_attributes.erb index 293e916a8baa..ff87256cf185 100644 --- a/templates/inspec/examples/google_compute_instance/google_compute_instance_attributes.erb +++ b/templates/inspec/examples/google_compute_instance/google_compute_instance_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_zone = attribute(:gcp_zone, default: '<%= external_attribute('gcp_zone') -%>', description: 'GCP zone name of the compute disk') -instance = attribute('instance', default: <%= JSON.pretty_generate(grab_attributes['instance']) -%>, description: 'Compute instance description') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_zone = attribute(:gcp_zone, default: '<%= external_attribute(pwd, 'gcp_zone') -%>', description: 'GCP zone name of the compute disk') +instance = attribute('instance', default: <%= JSON.pretty_generate(grab_attributes(pwd)['instance']) -%>, description: 'Compute instance description') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_instance/google_compute_instances.erb b/templates/inspec/examples/google_compute_instance/google_compute_instances.erb index cb05c7971485..7d2472b3e5ad 100644 --- a/templates/inspec/examples/google_compute_instance/google_compute_instances.erb +++ b/templates/inspec/examples/google_compute_instance/google_compute_instances.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_zone = "#{external_attribute('gcp_zone', doc_generation)}" %> -<% instance = grab_attributes['instance'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_zone = "#{external_attribute(pwd, 'gcp_zone', doc_generation)}" %> +<% instance = grab_attributes(pwd)['instance'] -%> describe google_compute_instances(project: <%= gcp_project_id -%>, zone: <%= gcp_zone -%>) do its('instance_names') { should include <%= doc_generation ? "'#{instance['name']}'" : "instance['name']" -%> } end \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_instance_group/google_compute_instance_group.erb b/templates/inspec/examples/google_compute_instance_group/google_compute_instance_group.erb index f8d2da23c6f5..e8624744dd93 100644 --- a/templates/inspec/examples/google_compute_instance_group/google_compute_instance_group.erb +++ b/templates/inspec/examples/google_compute_instance_group/google_compute_instance_group.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_zone = "#{external_attribute('gcp_zone', doc_generation)}" %> -<% instance_group = grab_attributes['instance_group'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_zone = "#{external_attribute(pwd, 'gcp_zone', doc_generation)}" %> +<% instance_group = grab_attributes(pwd)['instance_group'] -%> describe google_compute_instance_group(project: <%= gcp_project_id -%>, zone: <%= gcp_zone -%>, name: <%= doc_generation ? "'#{instance_group['name']}'" : "instance_group['name']" -%>) do it { should exist } its('description') { should cmp <%= doc_generation ? "'#{instance_group['description']}'" : "instance_group['description']" -%> } diff --git a/templates/inspec/examples/google_compute_instance_group/google_compute_instance_group_attributes.erb b/templates/inspec/examples/google_compute_instance_group/google_compute_instance_group_attributes.erb index 048964c15651..392989d3f94e 100644 --- a/templates/inspec/examples/google_compute_instance_group/google_compute_instance_group_attributes.erb +++ b/templates/inspec/examples/google_compute_instance_group/google_compute_instance_group_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_zone = attribute(:gcp_zone, default: '<%= external_attribute('gcp_zone') -%>', description: 'GCP zone name') -instance_group = attribute('instance_group', default: <%= JSON.pretty_generate(grab_attributes['instance_group']) -%>, description: 'Instance group') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_zone = attribute(:gcp_zone, default: '<%= external_attribute(pwd, 'gcp_zone') -%>', description: 'GCP zone name') +instance_group = attribute('instance_group', default: <%= JSON.pretty_generate(grab_attributes(pwd)['instance_group']) -%>, description: 'Instance group') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_instance_group/google_compute_instance_groups.erb b/templates/inspec/examples/google_compute_instance_group/google_compute_instance_groups.erb index c4340cfa99ce..e83fcf0d7e85 100644 --- a/templates/inspec/examples/google_compute_instance_group/google_compute_instance_groups.erb +++ b/templates/inspec/examples/google_compute_instance_group/google_compute_instance_groups.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_zone = "#{external_attribute('gcp_zone', doc_generation)}" %> -<% instance_group = grab_attributes['instance_group'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_zone = "#{external_attribute(pwd, 'gcp_zone', doc_generation)}" %> +<% instance_group = grab_attributes(pwd)['instance_group'] -%> describe google_compute_instance_groups(project: <%= gcp_project_id -%>, zone: <%= gcp_zone -%>) do its('instance_group_names') { should include <%= doc_generation ? "'#{instance_group['name']}'" : "instance_group['name']" -%> } end \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_instance_group_manager/google_compute_instance_group_manager.erb b/templates/inspec/examples/google_compute_instance_group_manager/google_compute_instance_group_manager.erb index e16516c1e30c..739979dbb39b 100644 --- a/templates/inspec/examples/google_compute_instance_group_manager/google_compute_instance_group_manager.erb +++ b/templates/inspec/examples/google_compute_instance_group_manager/google_compute_instance_group_manager.erb @@ -1,7 +1,7 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_zone = "#{external_attribute('gcp_zone', doc_generation)}" -%> -<% gcp_lb_mig1_name = "#{external_attribute('gcp_lb_mig1_name', doc_generation)}" -%> -<% instance_group_manager = grab_attributes['instance_group_manager'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_zone = "#{external_attribute(pwd, 'gcp_zone', doc_generation)}" -%> +<% gcp_lb_mig1_name = "#{external_attribute(pwd, 'gcp_lb_mig1_name', doc_generation)}" -%> +<% instance_group_manager = grab_attributes(pwd)['instance_group_manager'] -%> describe google_compute_instance_group_manager(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, zone: <%= doc_generation ? "#{gcp_zone}" : "gcp_zone" -%>, name: <%= doc_generation ? "'#{instance_group_manager['name']}'" : "instance_group_manager['name']" -%>) do it { should exist } diff --git a/templates/inspec/examples/google_compute_instance_group_manager/google_compute_instance_group_manager_attributes.erb b/templates/inspec/examples/google_compute_instance_group_manager/google_compute_instance_group_manager_attributes.erb index c69f8feb36af..7e7a7eee553e 100644 --- a/templates/inspec/examples/google_compute_instance_group_manager/google_compute_instance_group_manager_attributes.erb +++ b/templates/inspec/examples/google_compute_instance_group_manager/google_compute_instance_group_manager_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_zone = attribute(:gcp_zone, default: '<%= external_attribute('gcp_zone') -%>', description: 'The GCP project zone.') -instance_group_manager = attribute('instance_group_manager', default: <%= JSON.pretty_generate(grab_attributes['instance_group_manager']) -%>, description: 'Instance group manager definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_zone = attribute(:gcp_zone, default: '<%= external_attribute(pwd, 'gcp_zone') -%>', description: 'The GCP project zone.') +instance_group_manager = attribute('instance_group_manager', default: <%= JSON.pretty_generate(grab_attributes(pwd)['instance_group_manager']) -%>, description: 'Instance group manager definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_instance_group_manager/google_compute_instance_group_managers.erb b/templates/inspec/examples/google_compute_instance_group_manager/google_compute_instance_group_managers.erb index d774663ccec5..5ec0875ac2d5 100644 --- a/templates/inspec/examples/google_compute_instance_group_manager/google_compute_instance_group_managers.erb +++ b/templates/inspec/examples/google_compute_instance_group_manager/google_compute_instance_group_managers.erb @@ -1,7 +1,7 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_zone = "#{external_attribute('gcp_zone', doc_generation)}" -%> -<% gcp_lb_mig1_name = "#{external_attribute('gcp_lb_mig1_name', doc_generation)}" -%> -<% instance_group_manager = grab_attributes['instance_group_manager'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_zone = "#{external_attribute(pwd, 'gcp_zone', doc_generation)}" -%> +<% gcp_lb_mig1_name = "#{external_attribute(pwd, 'gcp_lb_mig1_name', doc_generation)}" -%> +<% instance_group_manager = grab_attributes(pwd)['instance_group_manager'] -%> describe google_compute_instance_group_managers(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, zone: <%= doc_generation ? "#{gcp_zone}" : "gcp_zone" -%>) do its('base_instance_names') { should include <%= doc_generation ? "'#{instance_group_manager['base_instance_name']}'" : "instance_group_manager['base_instance_name']" -%> } end \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_instance_template/google_compute_instance_template.erb b/templates/inspec/examples/google_compute_instance_template/google_compute_instance_template.erb index ad95cb041b4d..0dc861ba1e62 100644 --- a/templates/inspec/examples/google_compute_instance_template/google_compute_instance_template.erb +++ b/templates/inspec/examples/google_compute_instance_template/google_compute_instance_template.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% instance_template = grab_attributes['instance_template'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% instance_template = grab_attributes(pwd)['instance_template'] -%> describe google_compute_instance_template(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, name: <%= doc_generation ? "'#{instance_template['name']}'" : "instance_template['name']" -%>) do it { should exist } its('description') { should eq <%= doc_generation ? "'#{instance_template['description']}'" : "instance_template['description']" -%> } diff --git a/templates/inspec/examples/google_compute_instance_template/google_compute_instance_template_attributes.erb b/templates/inspec/examples/google_compute_instance_template/google_compute_instance_template_attributes.erb index ccc90bb07712..43ee62466cb8 100644 --- a/templates/inspec/examples/google_compute_instance_template/google_compute_instance_template_attributes.erb +++ b/templates/inspec/examples/google_compute_instance_template/google_compute_instance_template_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -instance_template = attribute('instance_template', default: <%= JSON.pretty_generate(grab_attributes['instance_template']) -%>, description: 'An instance template definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +instance_template = attribute('instance_template', default: <%= JSON.pretty_generate(grab_attributes(pwd)['instance_template']) -%>, description: 'An instance template definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_instance_template/google_compute_instance_templates.erb b/templates/inspec/examples/google_compute_instance_template/google_compute_instance_templates.erb index dd968bfbf06a..a6691a2c2661 100644 --- a/templates/inspec/examples/google_compute_instance_template/google_compute_instance_templates.erb +++ b/templates/inspec/examples/google_compute_instance_template/google_compute_instance_templates.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% instance_template = grab_attributes['instance_template'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% instance_template = grab_attributes(pwd)['instance_template'] -%> describe google_compute_instance_templates(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>) do its('names') { should include <%= doc_generation ? "'#{instance_template['name']}'" : "instance_template['name']" -%> } end \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_network/google_compute_network.erb b/templates/inspec/examples/google_compute_network/google_compute_network.erb index 66f9c910a0c4..b24f523a9cec 100644 --- a/templates/inspec/examples/google_compute_network/google_compute_network.erb +++ b/templates/inspec/examples/google_compute_network/google_compute_network.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% network = grab_attributes['network'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% network = grab_attributes(pwd)['network'] -%> describe google_compute_network(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{network['name']}'" : "network['name']" -%>) do it { should exist } its('routing_config.routing_mode') { should cmp <%= doc_generation ? "'#{network['routing_mode']}'" : "network['routing_mode']" -%> } diff --git a/templates/inspec/examples/google_compute_network/google_compute_network_attributes.erb b/templates/inspec/examples/google_compute_network/google_compute_network_attributes.erb index 205e68a34291..96f6dab07361 100644 --- a/templates/inspec/examples/google_compute_network/google_compute_network_attributes.erb +++ b/templates/inspec/examples/google_compute_network/google_compute_network_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -network = attribute('network', default: <%= JSON.pretty_generate(grab_attributes['network']) -%>, description: 'Network description') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +network = attribute('network', default: <%= JSON.pretty_generate(grab_attributes(pwd)['network']) -%>, description: 'Network description') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_network/google_compute_networks.erb b/templates/inspec/examples/google_compute_network/google_compute_networks.erb index ea617bf94aff..c77f9b4eefec 100644 --- a/templates/inspec/examples/google_compute_network/google_compute_networks.erb +++ b/templates/inspec/examples/google_compute_network/google_compute_networks.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% network = grab_attributes['network'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% network = grab_attributes(pwd)['network'] -%> describe google_compute_networks(project: <%= gcp_project_id -%>) do its('network_names') { should include <%= doc_generation ? "'#{network['name']}'" : "network['name']" -%> } end \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_network_endpoint_group/google_compute_network_endpoint_group.erb b/templates/inspec/examples/google_compute_network_endpoint_group/google_compute_network_endpoint_group.erb index 6034a69db465..dcd80daaa106 100644 --- a/templates/inspec/examples/google_compute_network_endpoint_group/google_compute_network_endpoint_group.erb +++ b/templates/inspec/examples/google_compute_network_endpoint_group/google_compute_network_endpoint_group.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% network_endpoint_group = grab_attributes['network_endpoint_group'] -%> -<% gcp_zone = "#{external_attribute('gcp_zone', doc_generation)}" %> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% network_endpoint_group = grab_attributes(pwd)['network_endpoint_group'] -%> +<% gcp_zone = "#{external_attribute(pwd, 'gcp_zone', doc_generation)}" %> describe google_compute_network_endpoint_group(project: <%= gcp_project_id -%>, zone: <%= gcp_zone -%>, name: <%= doc_generation ? "'#{network_endpoint_group['name']}'" : "network_endpoint_group['name']" -%>) do it { should exist } its('default_port') { should cmp <%= doc_generation ? "'#{network_endpoint_group['default_port']}'" : "network_endpoint_group['default_port']" -%> } diff --git a/templates/inspec/examples/google_compute_network_endpoint_group/google_compute_network_endpoint_group_attributes.erb b/templates/inspec/examples/google_compute_network_endpoint_group/google_compute_network_endpoint_group_attributes.erb index e6fe6011cafe..c2827e4a70a5 100644 --- a/templates/inspec/examples/google_compute_network_endpoint_group/google_compute_network_endpoint_group_attributes.erb +++ b/templates/inspec/examples/google_compute_network_endpoint_group/google_compute_network_endpoint_group_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -network_endpoint_group = attribute('network_endpoint_group', default: <%= JSON.pretty_generate(grab_attributes['network_endpoint_group']) -%>, description: 'Network endpoint group description') -gcp_zone = attribute(:gcp_zone, default: '<%= external_attribute('gcp_zone') -%>', description: 'GCP zone name') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +network_endpoint_group = attribute('network_endpoint_group', default: <%= JSON.pretty_generate(grab_attributes(pwd)['network_endpoint_group']) -%>, description: 'Network endpoint group description') +gcp_zone = attribute(:gcp_zone, default: '<%= external_attribute(pwd, 'gcp_zone') -%>', description: 'GCP zone name') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_network_endpoint_group/google_compute_network_endpoint_groups.erb b/templates/inspec/examples/google_compute_network_endpoint_group/google_compute_network_endpoint_groups.erb index b416a5075442..24ea8c229dc3 100644 --- a/templates/inspec/examples/google_compute_network_endpoint_group/google_compute_network_endpoint_groups.erb +++ b/templates/inspec/examples/google_compute_network_endpoint_group/google_compute_network_endpoint_groups.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% network_endpoint_group = grab_attributes['network_endpoint_group'] -%> -<% gcp_zone = "#{external_attribute('gcp_zone', doc_generation)}" %> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% network_endpoint_group = grab_attributes(pwd)['network_endpoint_group'] -%> +<% gcp_zone = "#{external_attribute(pwd, 'gcp_zone', doc_generation)}" %> describe google_compute_network_endpoint_groups(project: <%= gcp_project_id -%>, zone: <%= gcp_zone -%>) do its('default_ports') { should include <%= doc_generation ? "'#{network_endpoint_group['default_port']}'" : "network_endpoint_group['default_port']" -%> } its('names') { should include <%= doc_generation ? "'#{network_endpoint_group['name']}'" : "network_endpoint_group['name']" -%> } diff --git a/templates/inspec/examples/google_compute_node_group/google_compute_node_group.erb b/templates/inspec/examples/google_compute_node_group/google_compute_node_group.erb index a4567eaa3e9c..aa6a57057f64 100644 --- a/templates/inspec/examples/google_compute_node_group/google_compute_node_group.erb +++ b/templates/inspec/examples/google_compute_node_group/google_compute_node_group.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% node_group = grab_attributes['node_group'] -%> -<% gcp_zone = "#{external_attribute('gcp_zone', doc_generation)}" %> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% node_group = grab_attributes(pwd)['node_group'] -%> +<% gcp_zone = "#{external_attribute(pwd, 'gcp_zone', doc_generation)}" %> describe google_compute_node_group(project: <%= gcp_project_id -%>, zone: <%= gcp_zone -%>, name: <%= doc_generation ? "'#{node_group['name']}'" : "node_group['name']" -%>) do it { should exist } its('description') { should cmp <%= doc_generation ? "'#{node_group['description']}'" : "node_group['description']" -%> } diff --git a/templates/inspec/examples/google_compute_node_group/google_compute_node_group_attributes.erb b/templates/inspec/examples/google_compute_node_group/google_compute_node_group_attributes.erb index 5d11c86bc48e..5f8d7f99f5bc 100644 --- a/templates/inspec/examples/google_compute_node_group/google_compute_node_group_attributes.erb +++ b/templates/inspec/examples/google_compute_node_group/google_compute_node_group_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -node_group = attribute('node_group', default: <%= JSON.pretty_generate(grab_attributes['node_group']) -%>, description: 'Node group description') -gcp_zone = attribute(:gcp_zone, default: '<%= external_attribute('gcp_zone') -%>', description: 'GCP zone name') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +node_group = attribute('node_group', default: <%= JSON.pretty_generate(grab_attributes(pwd)['node_group']) -%>, description: 'Node group description') +gcp_zone = attribute(:gcp_zone, default: '<%= external_attribute(pwd, 'gcp_zone') -%>', description: 'GCP zone name') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_node_group/google_compute_node_groups.erb b/templates/inspec/examples/google_compute_node_group/google_compute_node_groups.erb index 4eea2831b019..a6f7c5352fa5 100644 --- a/templates/inspec/examples/google_compute_node_group/google_compute_node_groups.erb +++ b/templates/inspec/examples/google_compute_node_group/google_compute_node_groups.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% node_group = grab_attributes['node_group'] -%> -<% gcp_zone = "#{external_attribute('gcp_zone', doc_generation)}" %> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% node_group = grab_attributes(pwd)['node_group'] -%> +<% gcp_zone = "#{external_attribute(pwd, 'gcp_zone', doc_generation)}" %> describe google_compute_node_groups(project: <%= gcp_project_id -%>, zone: <%= gcp_zone -%>) do it { should exist } its('descriptions') { should include <%= doc_generation ? "'#{node_group['description']}'" : "node_group['description']" -%> } diff --git a/templates/inspec/examples/google_compute_node_template/google_compute_node_template.erb b/templates/inspec/examples/google_compute_node_template/google_compute_node_template.erb index 574227febdff..5fc714c79fc8 100644 --- a/templates/inspec/examples/google_compute_node_template/google_compute_node_template.erb +++ b/templates/inspec/examples/google_compute_node_template/google_compute_node_template.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% node_template = grab_attributes['node_template'] -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" %> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% node_template = grab_attributes(pwd)['node_template'] -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" %> describe google_compute_node_template(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>, name: <%= doc_generation ? "'#{node_template['name']}'" : "node_template['name']" -%>) do it { should exist } its('node_affinity_labels') { should include(<%= doc_generation ? "'#{node_template['label_key']}'" : "node_template['label_key']" -%> => <%= doc_generation ? "'#{node_template['label_value']}'" : "node_template['label_value']" -%>) } diff --git a/templates/inspec/examples/google_compute_node_template/google_compute_node_template_attributes.erb b/templates/inspec/examples/google_compute_node_template/google_compute_node_template_attributes.erb index 7ecffbee4933..9e4022c57d63 100644 --- a/templates/inspec/examples/google_compute_node_template/google_compute_node_template_attributes.erb +++ b/templates/inspec/examples/google_compute_node_template/google_compute_node_template_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'The GCP project region.') -node_template = attribute('node_template', default: <%= JSON.pretty_generate(grab_attributes['node_template']) -%>, description: 'Node template description') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_location = attribute(:gcp_location, default: '<%= external_attribute(pwd, 'gcp_location') -%>', description: 'The GCP project region.') +node_template = attribute('node_template', default: <%= JSON.pretty_generate(grab_attributes(pwd)['node_template']) -%>, description: 'Node template description') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_node_template/google_compute_node_templates.erb b/templates/inspec/examples/google_compute_node_template/google_compute_node_templates.erb index aaa36f94d300..9904f65a728c 100644 --- a/templates/inspec/examples/google_compute_node_template/google_compute_node_templates.erb +++ b/templates/inspec/examples/google_compute_node_template/google_compute_node_templates.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% node_template = grab_attributes['node_template'] -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" %> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% node_template = grab_attributes(pwd)['node_template'] -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" %> describe google_compute_node_templates(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>) do its('names') { should include <%= doc_generation ? "'#{node_template['name']}'" : "node_template['name']" -%> } end \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_project_info/google_compute_project_info.erb b/templates/inspec/examples/google_compute_project_info/google_compute_project_info.erb index f101eaf31e58..0bdc41f0eaec 100644 --- a/templates/inspec/examples/google_compute_project_info/google_compute_project_info.erb +++ b/templates/inspec/examples/google_compute_project_info/google_compute_project_info.erb @@ -1,4 +1,4 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> describe google_compute_project_info(project: <%= gcp_project_id -%>) do it { should exist } its('default_service_account') { should match "developer.gserviceaccount.com" } diff --git a/templates/inspec/examples/google_compute_project_info/google_compute_project_info_attributes.erb b/templates/inspec/examples/google_compute_project_info/google_compute_project_info_attributes.erb index a2863dfa3703..9e434667ef77 100644 --- a/templates/inspec/examples/google_compute_project_info/google_compute_project_info_attributes.erb +++ b/templates/inspec/examples/google_compute_project_info/google_compute_project_info_attributes.erb @@ -1 +1 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_region/google_compute_region.erb b/templates/inspec/examples/google_compute_region/google_compute_region.erb index 5ca45d827c3f..d47c7a9a551c 100644 --- a/templates/inspec/examples/google_compute_region/google_compute_region.erb +++ b/templates/inspec/examples/google_compute_region/google_compute_region.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> describe google_compute_region(project: <%= gcp_project_id -%>, name: <%= gcp_location -%>) do it { should exist } it { should be_up } diff --git a/templates/inspec/examples/google_compute_region/google_compute_region_attributes.erb b/templates/inspec/examples/google_compute_region/google_compute_region_attributes.erb index 8241a8af352d..7a694ac5cb22 100644 --- a/templates/inspec/examples/google_compute_region/google_compute_region_attributes.erb +++ b/templates/inspec/examples/google_compute_region/google_compute_region_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'The GCP project region.') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_location = attribute(:gcp_location, default: '<%= external_attribute(pwd, 'gcp_location') -%>', description: 'The GCP project region.') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_region/google_compute_regions.erb b/templates/inspec/examples/google_compute_region/google_compute_regions.erb index 05bf6392abd4..8c3193d9f05c 100644 --- a/templates/inspec/examples/google_compute_region/google_compute_regions.erb +++ b/templates/inspec/examples/google_compute_region/google_compute_regions.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> describe google_compute_regions(project: <%= gcp_project_id -%>) do its('count') { should be >= 1 } its('region_names') { should include "#{gcp_location}" } diff --git a/templates/inspec/examples/google_compute_region_backend_service/google_compute_region_backend_service.erb b/templates/inspec/examples/google_compute_region_backend_service/google_compute_region_backend_service.erb index 8ceca054d24c..064154375feb 100644 --- a/templates/inspec/examples/google_compute_region_backend_service/google_compute_region_backend_service.erb +++ b/templates/inspec/examples/google_compute_region_backend_service/google_compute_region_backend_service.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% region_backend_service = grab_attributes['region_backend_service'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% region_backend_service = grab_attributes(pwd)['region_backend_service'] -%> describe google_compute_region_backend_service(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>, name: <%= doc_generation ? "'#{region_backend_service['name']}'" : "region_backend_service['name']" -%>) do it { should exist } its('description') { should eq <%= doc_generation ? "'#{region_backend_service['description']}'" : "region_backend_service['description']" -%> } diff --git a/templates/inspec/examples/google_compute_region_backend_service/google_compute_region_backend_service_attributes.erb b/templates/inspec/examples/google_compute_region_backend_service/google_compute_region_backend_service_attributes.erb index 4b6866b7922d..298773c5f630 100644 --- a/templates/inspec/examples/google_compute_region_backend_service/google_compute_region_backend_service_attributes.erb +++ b/templates/inspec/examples/google_compute_region_backend_service/google_compute_region_backend_service_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'The GCP project region.') -region_backend_service = attribute('region_backend_service', default: <%= JSON.pretty_generate(grab_attributes['region_backend_service']) -%>, description: 'Backend service definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_location = attribute(:gcp_location, default: '<%= external_attribute(pwd, 'gcp_location') -%>', description: 'The GCP project region.') +region_backend_service = attribute('region_backend_service', default: <%= JSON.pretty_generate(grab_attributes(pwd)['region_backend_service']) -%>, description: 'Backend service definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_region_backend_service/google_compute_region_backend_services.erb b/templates/inspec/examples/google_compute_region_backend_service/google_compute_region_backend_services.erb index 3d6224dc4960..5707d919233a 100644 --- a/templates/inspec/examples/google_compute_region_backend_service/google_compute_region_backend_services.erb +++ b/templates/inspec/examples/google_compute_region_backend_service/google_compute_region_backend_services.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% region_backend_service = grab_attributes['region_backend_service'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% region_backend_service = grab_attributes(pwd)['region_backend_service'] -%> describe google_compute_region_backend_services(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>) do its('count') { should be >= 1 } its('names') { should include <%= doc_generation ? "'#{region_backend_service['name']}'" : "region_backend_service['name']" -%> } diff --git a/templates/inspec/examples/google_compute_region_instance_group_manager/google_compute_region_instance_group_manager.erb b/templates/inspec/examples/google_compute_region_instance_group_manager/google_compute_region_instance_group_manager.erb index 2231b0c0f0e8..4269de5aca53 100644 --- a/templates/inspec/examples/google_compute_region_instance_group_manager/google_compute_region_instance_group_manager.erb +++ b/templates/inspec/examples/google_compute_region_instance_group_manager/google_compute_region_instance_group_manager.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% rigm = grab_attributes['rigm'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% rigm = grab_attributes(pwd)['rigm'] -%> describe google_compute_region_instance_group_manager(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>, name: <%= doc_generation ? "'#{rigm['name']}'" : "rigm['name']" -%>) do it { should exist } its('base_instance_name') { should eq <%= doc_generation ? "'#{rigm['base_instance_name']}'" : "rigm['base_instance_name']" -%> } diff --git a/templates/inspec/examples/google_compute_region_instance_group_manager/google_compute_region_instance_group_manager_attributes.erb b/templates/inspec/examples/google_compute_region_instance_group_manager/google_compute_region_instance_group_manager_attributes.erb index 3d1f22a10758..5799971ab6b2 100644 --- a/templates/inspec/examples/google_compute_region_instance_group_manager/google_compute_region_instance_group_manager_attributes.erb +++ b/templates/inspec/examples/google_compute_region_instance_group_manager/google_compute_region_instance_group_manager_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'The GCP project region.') -rigm = attribute('rigm', default: <%= JSON.pretty_generate(grab_attributes['rigm']) -%>, description: 'Compute region instance group manager description') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_location = attribute(:gcp_location, default: '<%= external_attribute(pwd, 'gcp_location') -%>', description: 'The GCP project region.') +rigm = attribute('rigm', default: <%= JSON.pretty_generate(grab_attributes(pwd)['rigm']) -%>, description: 'Compute region instance group manager description') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_region_instance_group_manager/google_compute_region_instance_group_managers.erb b/templates/inspec/examples/google_compute_region_instance_group_manager/google_compute_region_instance_group_managers.erb index 318fc5b07199..be3faf38ac69 100644 --- a/templates/inspec/examples/google_compute_region_instance_group_manager/google_compute_region_instance_group_managers.erb +++ b/templates/inspec/examples/google_compute_region_instance_group_manager/google_compute_region_instance_group_managers.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% rigm = grab_attributes['rigm'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% rigm = grab_attributes(pwd)['rigm'] -%> describe google_compute_region_instance_group_managers(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>) do its('instance_group_manager_names') { should include <%= doc_generation ? "'#{rigm['name']}'" : "rigm['name']" -%> } its('base_instance_names') { should include <%= doc_generation ? "'#{rigm['base_instance_name']}'" : "rigm['base_instance_name']" -%> } diff --git a/templates/inspec/examples/google_compute_route/google_compute_route.erb b/templates/inspec/examples/google_compute_route/google_compute_route.erb index 2dfa1fed280c..61fd4cbea81f 100644 --- a/templates/inspec/examples/google_compute_route/google_compute_route.erb +++ b/templates/inspec/examples/google_compute_route/google_compute_route.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% route = grab_attributes['route'] -%> -<% gcp_network_name = "#{external_attribute('gcp_network_name', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% route = grab_attributes(pwd)['route'] -%> +<% gcp_network_name = "#{external_attribute(pwd, 'gcp_network_name', doc_generation)}" -%> describe google_compute_route(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{route['name']}'" : "route['name']" -%>) do it { should exist } its('dest_range') { should eq <%= doc_generation ? "'#{route['dest_range']}'" : "route['dest_range']" -%> } diff --git a/templates/inspec/examples/google_compute_route/google_compute_route_attributes.erb b/templates/inspec/examples/google_compute_route/google_compute_route_attributes.erb index 31eb5dbf7302..4912798bb9d8 100644 --- a/templates/inspec/examples/google_compute_route/google_compute_route_attributes.erb +++ b/templates/inspec/examples/google_compute_route/google_compute_route_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -route = attribute('route', default: <%= JSON.pretty_generate(grab_attributes['route']) -%>, description: 'Compute route description') -gcp_network_name = attribute(:gcp_network_name, default: '<%= external_attribute('gcp_network_name') -%>', description: 'GCP network name') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +route = attribute('route', default: <%= JSON.pretty_generate(grab_attributes(pwd)['route']) -%>, description: 'Compute route description') +gcp_network_name = attribute(:gcp_network_name, default: '<%= external_attribute(pwd, 'gcp_network_name') -%>', description: 'GCP network name') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_route/google_compute_routes.erb b/templates/inspec/examples/google_compute_route/google_compute_routes.erb index 0da181373ea7..413789b35fc2 100644 --- a/templates/inspec/examples/google_compute_route/google_compute_routes.erb +++ b/templates/inspec/examples/google_compute_route/google_compute_routes.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% route = grab_attributes['route'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% route = grab_attributes(pwd)['route'] -%> describe google_compute_routes(project: <%= gcp_project_id -%>) do its('count') { should be >= 1 } its('dest_ranges') { should include <%= doc_generation ? "'#{route['dest_range']}'" : "route['dest_range']" -%> } diff --git a/templates/inspec/examples/google_compute_router/google_compute_router.erb b/templates/inspec/examples/google_compute_router/google_compute_router.erb index b4f0467e637d..fecb0bcfcf67 100644 --- a/templates/inspec/examples/google_compute_router/google_compute_router.erb +++ b/templates/inspec/examples/google_compute_router/google_compute_router.erb @@ -1,7 +1,7 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% router = grab_attributes['router'] -%> -<% gcp_network_name = "#{external_attribute('gcp_network_name', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% router = grab_attributes(pwd)['router'] -%> +<% gcp_network_name = "#{external_attribute(pwd, 'gcp_network_name', doc_generation)}" -%> describe google_compute_router(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>, name: <%= doc_generation ? "'#{router['name']}'" : "router['name']" -%>) do it { should exist } its('bgp.asn') { should eq <%= doc_generation ? "'#{router['bgp_asn']}'" : "router['bgp_asn']" -%> } diff --git a/templates/inspec/examples/google_compute_router/google_compute_router_attributes.erb b/templates/inspec/examples/google_compute_router/google_compute_router_attributes.erb index 6319dea87fa0..9d7e97fc6da4 100644 --- a/templates/inspec/examples/google_compute_router/google_compute_router_attributes.erb +++ b/templates/inspec/examples/google_compute_router/google_compute_router_attributes.erb @@ -1,4 +1,4 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'The GCP project region.') -router = attribute('router', default: <%= JSON.pretty_generate(grab_attributes['router']) -%>, description: 'Compute router description') -gcp_network_name = attribute(:gcp_network_name, default: '<%= external_attribute('gcp_network_name') -%>', description: 'GCP network name') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_location = attribute(:gcp_location, default: '<%= external_attribute(pwd, 'gcp_location') -%>', description: 'The GCP project region.') +router = attribute('router', default: <%= JSON.pretty_generate(grab_attributes(pwd)['router']) -%>, description: 'Compute router description') +gcp_network_name = attribute(:gcp_network_name, default: '<%= external_attribute(pwd, 'gcp_network_name') -%>', description: 'GCP network name') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_router/google_compute_routers.erb b/templates/inspec/examples/google_compute_router/google_compute_routers.erb index 3adf63690476..9b02a8421407 100644 --- a/templates/inspec/examples/google_compute_router/google_compute_routers.erb +++ b/templates/inspec/examples/google_compute_router/google_compute_routers.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% router = grab_attributes['router'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% router = grab_attributes(pwd)['router'] -%> describe google_compute_routers(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>) do its('names') { should include <%= doc_generation ? "'#{router['name']}'" : "router['name']" -%> } end \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_router_nat/google_compute_router_nat.erb b/templates/inspec/examples/google_compute_router_nat/google_compute_router_nat.erb index 89f3a5539cd6..192462efbf7f 100644 --- a/templates/inspec/examples/google_compute_router_nat/google_compute_router_nat.erb +++ b/templates/inspec/examples/google_compute_router_nat/google_compute_router_nat.erb @@ -1,7 +1,7 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% router = grab_attributes['router'] -%> -<% router_nat = grab_attributes['router_nat'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% router = grab_attributes(pwd)['router'] -%> +<% router_nat = grab_attributes(pwd)['router_nat'] -%> describe google_compute_router_nat(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>, router: <%= doc_generation ? "'#{router['name']}'" : "router['name']" -%>, name: <%= doc_generation ? "'#{router_nat['name']}'" : "router_nat['name']" -%>) do it { should exist } its('nat_ip_allocate_option') { should cmp <%= doc_generation ? "'#{router_nat['nat_ip_allocate_option']}'" : "router_nat['nat_ip_allocate_option']" -%> } diff --git a/templates/inspec/examples/google_compute_router_nat/google_compute_router_nat_attributes.erb b/templates/inspec/examples/google_compute_router_nat/google_compute_router_nat_attributes.erb index bfada640e1dc..9316bb528181 100644 --- a/templates/inspec/examples/google_compute_router_nat/google_compute_router_nat_attributes.erb +++ b/templates/inspec/examples/google_compute_router_nat/google_compute_router_nat_attributes.erb @@ -1,4 +1,4 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'The GCP project region.') -router = attribute('router', default: <%= JSON.pretty_generate(grab_attributes['router']) -%>, description: 'Compute router description') -router_nat = attribute('router_nat', default: <%= JSON.pretty_generate(grab_attributes['router_nat']) -%>, description: 'Compute router NAT description') +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_location = attribute(:gcp_location, default: '<%= external_attribute(pwd, 'gcp_location') -%>', description: 'The GCP project region.') +router = attribute('router', default: <%= JSON.pretty_generate(grab_attributes(pwd)['router']) -%>, description: 'Compute router description') +router_nat = attribute('router_nat', default: <%= JSON.pretty_generate(grab_attributes(pwd)['router_nat']) -%>, description: 'Compute router NAT description') diff --git a/templates/inspec/examples/google_compute_router_nat/google_compute_router_nats.erb b/templates/inspec/examples/google_compute_router_nat/google_compute_router_nats.erb index 13e0e53ad843..e655821801df 100644 --- a/templates/inspec/examples/google_compute_router_nat/google_compute_router_nats.erb +++ b/templates/inspec/examples/google_compute_router_nat/google_compute_router_nats.erb @@ -1,7 +1,7 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% router = grab_attributes['router'] -%> -<% router_nat = grab_attributes['router_nat'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% router = grab_attributes(pwd)['router'] -%> +<% router_nat = grab_attributes(pwd)['router_nat'] -%> describe google_compute_router_nats(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>, router: <%= doc_generation ? "'#{router['name']}'" : "router['name']" -%>) do its('names') { should include <%= doc_generation ? "'#{router_nat['name']}'" : "router_nat['name']" -%> } end \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_security_policy/google_compute_security_policies.erb b/templates/inspec/examples/google_compute_security_policy/google_compute_security_policies.erb index 78b5a54c8993..54f336d392da 100644 --- a/templates/inspec/examples/google_compute_security_policy/google_compute_security_policies.erb +++ b/templates/inspec/examples/google_compute_security_policy/google_compute_security_policies.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% security_policy = grab_attributes['security_policy'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% security_policy = grab_attributes(pwd)['security_policy'] -%> describe google_compute_security_policies(project: <%= gcp_project_id -%>) do its('count') { should be >= 1 } its('names') { should include <%= doc_generation ? "'#{security_policy['name']}'" : "security_policy['name']" -%> } diff --git a/templates/inspec/examples/google_compute_security_policy/google_compute_security_policy.erb b/templates/inspec/examples/google_compute_security_policy/google_compute_security_policy.erb index 04d8337ab210..8487a9deb68f 100644 --- a/templates/inspec/examples/google_compute_security_policy/google_compute_security_policy.erb +++ b/templates/inspec/examples/google_compute_security_policy/google_compute_security_policy.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% security_policy = grab_attributes['security_policy'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% security_policy = grab_attributes(pwd)['security_policy'] -%> describe google_compute_security_policy(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{security_policy['name']}'" : "security_policy['name']" -%>) do it { should exist } its('rules.size') { should cmp 2 } diff --git a/templates/inspec/examples/google_compute_security_policy/google_compute_security_policy_attributes.erb b/templates/inspec/examples/google_compute_security_policy/google_compute_security_policy_attributes.erb index 2a6e3190ed84..ba9ba34bfce3 100644 --- a/templates/inspec/examples/google_compute_security_policy/google_compute_security_policy_attributes.erb +++ b/templates/inspec/examples/google_compute_security_policy/google_compute_security_policy_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -security_policy = attribute('security_policy', default: <%= JSON.pretty_generate(grab_attributes['security_policy']) -%>, description: 'Security Policy description') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +security_policy = attribute('security_policy', default: <%= JSON.pretty_generate(grab_attributes(pwd)['security_policy']) -%>, description: 'Security Policy description') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_snapshot/google_compute_snapshot.erb b/templates/inspec/examples/google_compute_snapshot/google_compute_snapshot.erb index 233f7f4e3b4a..8c74c1f1c34c 100644 --- a/templates/inspec/examples/google_compute_snapshot/google_compute_snapshot.erb +++ b/templates/inspec/examples/google_compute_snapshot/google_compute_snapshot.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% snapshot = grab_attributes['snapshot'] -%> -<% gcp_zone = "#{external_attribute('gcp_zone', doc_generation)}" %> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% snapshot = grab_attributes(pwd)['snapshot'] -%> +<% gcp_zone = "#{external_attribute(pwd, 'gcp_zone', doc_generation)}" %> describe google_compute_snapshot(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{snapshot['name']}'" : "snapshot['name']" -%>) do it { should exist } its('source_disk') { should match <%= doc_generation ? "'#{snapshot['disk_name']}'" : "snapshot['disk_name']" -%> } diff --git a/templates/inspec/examples/google_compute_snapshot/google_compute_snapshot_attributes.erb b/templates/inspec/examples/google_compute_snapshot/google_compute_snapshot_attributes.erb index 03a36fba93c1..4de08ded0b22 100644 --- a/templates/inspec/examples/google_compute_snapshot/google_compute_snapshot_attributes.erb +++ b/templates/inspec/examples/google_compute_snapshot/google_compute_snapshot_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_zone = attribute(:gcp_zone, default: '<%= external_attribute('gcp_zone') -%>', description: 'GCP zone name of the compute disk') -snapshot = attribute('snapshot', default: <%= JSON.pretty_generate(grab_attributes['snapshot']) -%>, description: 'Compute disk snapshot description') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_zone = attribute(:gcp_zone, default: '<%= external_attribute(pwd, 'gcp_zone') -%>', description: 'GCP zone name of the compute disk') +snapshot = attribute('snapshot', default: <%= JSON.pretty_generate(grab_attributes(pwd)['snapshot']) -%>, description: 'Compute disk snapshot description') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_snapshot/google_compute_snapshots.erb b/templates/inspec/examples/google_compute_snapshot/google_compute_snapshots.erb index a5e7f9c982c4..63aaef15581c 100644 --- a/templates/inspec/examples/google_compute_snapshot/google_compute_snapshots.erb +++ b/templates/inspec/examples/google_compute_snapshot/google_compute_snapshots.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% snapshot = grab_attributes['snapshot'] -%> -<% gcp_zone = "#{external_attribute('gcp_zone', doc_generation)}" %> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% snapshot = grab_attributes(pwd)['snapshot'] -%> +<% gcp_zone = "#{external_attribute(pwd, 'gcp_zone', doc_generation)}" %> describe google_compute_snapshots(project: <%= gcp_project_id -%>) do its('count') { should be >= 1 } end diff --git a/templates/inspec/examples/google_compute_ssl_certificate/google_compute_ssl_certificate.erb b/templates/inspec/examples/google_compute_ssl_certificate/google_compute_ssl_certificate.erb index 0ab4c66bfcba..cb20905fdefd 100644 --- a/templates/inspec/examples/google_compute_ssl_certificate/google_compute_ssl_certificate.erb +++ b/templates/inspec/examples/google_compute_ssl_certificate/google_compute_ssl_certificate.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% ssl_certificate = grab_attributes['ssl_certificate'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% ssl_certificate = grab_attributes(pwd)['ssl_certificate'] -%> describe google_compute_ssl_certificate(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{ssl_certificate['name']}'" : "ssl_certificate['name']" -%>) do it { should exist } its('description') { should eq <%= doc_generation ? "'#{ssl_certificate['description']}'" : "ssl_certificate['description']" -%> } diff --git a/templates/inspec/examples/google_compute_ssl_certificate/google_compute_ssl_certificate_attributes.erb b/templates/inspec/examples/google_compute_ssl_certificate/google_compute_ssl_certificate_attributes.erb index 469761ce7b14..33fffe66ec75 100644 --- a/templates/inspec/examples/google_compute_ssl_certificate/google_compute_ssl_certificate_attributes.erb +++ b/templates/inspec/examples/google_compute_ssl_certificate/google_compute_ssl_certificate_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -ssl_certificate = attribute('ssl_certificate', default: <%= JSON.pretty_generate(grab_attributes['ssl_certificate']) -%>, description: 'A GCP SSL certificate definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +ssl_certificate = attribute('ssl_certificate', default: <%= JSON.pretty_generate(grab_attributes(pwd)['ssl_certificate']) -%>, description: 'A GCP SSL certificate definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_ssl_certificate/google_compute_ssl_certificates.erb b/templates/inspec/examples/google_compute_ssl_certificate/google_compute_ssl_certificates.erb index fea38dd0962b..533f4f533fd6 100644 --- a/templates/inspec/examples/google_compute_ssl_certificate/google_compute_ssl_certificates.erb +++ b/templates/inspec/examples/google_compute_ssl_certificate/google_compute_ssl_certificates.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% ssl_certificate = grab_attributes['ssl_certificate'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% ssl_certificate = grab_attributes(pwd)['ssl_certificate'] -%> describe google_compute_ssl_certificates(project: <%= gcp_project_id -%>) do its('names') { should include <%= doc_generation ? "'#{ssl_certificate['name']}'" : "ssl_certificate['name']" -%> } diff --git a/templates/inspec/examples/google_compute_ssl_policy/google_compute_ssl_policies.erb b/templates/inspec/examples/google_compute_ssl_policy/google_compute_ssl_policies.erb index e37ae469ebd0..f34d533eda63 100644 --- a/templates/inspec/examples/google_compute_ssl_policy/google_compute_ssl_policies.erb +++ b/templates/inspec/examples/google_compute_ssl_policy/google_compute_ssl_policies.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% ssl_policy = grab_attributes['ssl_policy'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% ssl_policy = grab_attributes(pwd)['ssl_policy'] -%> describe google_compute_ssl_policies(project: <%= gcp_project_id -%>) do it { should exist } its('names') { should include <%= doc_generation ? "'#{ssl_policy['name']}'" : "ssl_policy['name']" -%> } diff --git a/templates/inspec/examples/google_compute_ssl_policy/google_compute_ssl_policy.erb b/templates/inspec/examples/google_compute_ssl_policy/google_compute_ssl_policy.erb index 1caa810b5c53..ccc5f477add0 100644 --- a/templates/inspec/examples/google_compute_ssl_policy/google_compute_ssl_policy.erb +++ b/templates/inspec/examples/google_compute_ssl_policy/google_compute_ssl_policy.erb @@ -1,5 +1,5 @@ -<% ssl_policy = grab_attributes['ssl_policy'] -%> -describe google_compute_ssl_policy(project: <%= "#{external_attribute('gcp_project_id', doc_generation)}" -%>, name: <%= doc_generation ? "'#{ssl_policy['name']}'" : "ssl_policy['name']" -%>) do +<% ssl_policy = grab_attributes(pwd)['ssl_policy'] -%> +describe google_compute_ssl_policy(project: <%= "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%>, name: <%= doc_generation ? "'#{ssl_policy['name']}'" : "ssl_policy['name']" -%>) do it { should exist } its('min_tls_version') { should eq <%= doc_generation ? "'#{ssl_policy['min_tls_version']}'" : "ssl_policy['min_tls_version']" -%> } its('profile') { should eq <%= doc_generation ? "'#{ssl_policy['profile']}'" : "ssl_policy['profile']" -%> } @@ -7,6 +7,6 @@ describe google_compute_ssl_policy(project: <%= "#{external_attribute('gcp_proje its('custom_features') { should include <%= doc_generation ? "'#{ssl_policy['custom_feature2']}'" : "ssl_policy['custom_feature2']" -%> } end -describe google_compute_ssl_policy(project: <%= "#{external_attribute('gcp_project_id', doc_generation)}" -%>, name: 'nonexistent') do +describe google_compute_ssl_policy(project: <%= "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%>, name: 'nonexistent') do it { should_not exist } end \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_ssl_policy/google_compute_ssl_policy_attributes.erb b/templates/inspec/examples/google_compute_ssl_policy/google_compute_ssl_policy_attributes.erb index 8d9d8728df95..c8766b09bae3 100644 --- a/templates/inspec/examples/google_compute_ssl_policy/google_compute_ssl_policy_attributes.erb +++ b/templates/inspec/examples/google_compute_ssl_policy/google_compute_ssl_policy_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -ssl_policy = attribute('ssl_policy', default: <%= JSON.pretty_generate(grab_attributes['ssl_policy']) -%>) \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +ssl_policy = attribute('ssl_policy', default: <%= JSON.pretty_generate(grab_attributes(pwd)['ssl_policy']) -%>) \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_subnetwork/google_compute_subnetwork.erb b/templates/inspec/examples/google_compute_subnetwork/google_compute_subnetwork.erb index b2de1f6a0924..849ae695ebb6 100644 --- a/templates/inspec/examples/google_compute_subnetwork/google_compute_subnetwork.erb +++ b/templates/inspec/examples/google_compute_subnetwork/google_compute_subnetwork.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% subnetwork = grab_attributes['subnetwork'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% subnetwork = grab_attributes(pwd)['subnetwork'] -%> describe google_compute_subnetwork(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>, name: <%= doc_generation ? "'#{subnetwork['name']}'" : "subnetwork['name']" -%>) do it { should exist } its('ip_cidr_range') { should eq <%= doc_generation ? "'#{subnetwork['ip_cidr_range']}'" : "subnetwork['ip_cidr_range']" -%> } diff --git a/templates/inspec/examples/google_compute_subnetwork/google_compute_subnetwork_attributes.erb b/templates/inspec/examples/google_compute_subnetwork/google_compute_subnetwork_attributes.erb index 0ab67d9c7a01..dd4489bdc090 100644 --- a/templates/inspec/examples/google_compute_subnetwork/google_compute_subnetwork_attributes.erb +++ b/templates/inspec/examples/google_compute_subnetwork/google_compute_subnetwork_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'The GCP project region.') -subnetwork = attribute('subnetwork', default: <%= JSON.pretty_generate(grab_attributes['subnetwork']) -%>, description: 'Compute subnetwork description') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_location = attribute(:gcp_location, default: '<%= external_attribute(pwd, 'gcp_location') -%>', description: 'The GCP project region.') +subnetwork = attribute('subnetwork', default: <%= JSON.pretty_generate(grab_attributes(pwd)['subnetwork']) -%>, description: 'Compute subnetwork description') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_subnetwork/google_compute_subnetworks.erb b/templates/inspec/examples/google_compute_subnetwork/google_compute_subnetworks.erb index 82adb03df3d9..5b53106795cb 100644 --- a/templates/inspec/examples/google_compute_subnetwork/google_compute_subnetworks.erb +++ b/templates/inspec/examples/google_compute_subnetwork/google_compute_subnetworks.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% subnetwork = grab_attributes['subnetwork'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% subnetwork = grab_attributes(pwd)['subnetwork'] -%> describe google_compute_subnetworks(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>) do its('ip_cidr_ranges') { should include <%= doc_generation ? "'#{subnetwork['ip_cidr_range']}'" : "subnetwork['ip_cidr_range']" -%> } its('subnetwork_names') { should include <%= doc_generation ? "'#{subnetwork['name']}'" : "subnetwork['name']" -%> } diff --git a/templates/inspec/examples/google_compute_target_http_proxy/google_compute_target_http_proxies.erb b/templates/inspec/examples/google_compute_target_http_proxy/google_compute_target_http_proxies.erb index c9827e42d975..cf7393d3c47f 100644 --- a/templates/inspec/examples/google_compute_target_http_proxy/google_compute_target_http_proxies.erb +++ b/templates/inspec/examples/google_compute_target_http_proxy/google_compute_target_http_proxies.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% http_proxy = grab_attributes['http_proxy'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% http_proxy = grab_attributes(pwd)['http_proxy'] -%> describe google_compute_target_http_proxies(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>) do its('names') { should include <%= doc_generation ? "'#{http_proxy['name']}'" : "http_proxy['name']" -%> } its('descriptions') { should include <%= doc_generation ? "'#{http_proxy['description']}'" : "http_proxy['description']" -%> } diff --git a/templates/inspec/examples/google_compute_target_http_proxy/google_compute_target_http_proxy.erb b/templates/inspec/examples/google_compute_target_http_proxy/google_compute_target_http_proxy.erb index dd58cf30094e..672e331eab85 100644 --- a/templates/inspec/examples/google_compute_target_http_proxy/google_compute_target_http_proxy.erb +++ b/templates/inspec/examples/google_compute_target_http_proxy/google_compute_target_http_proxy.erb @@ -1,9 +1,9 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% http_proxy = grab_attributes['http_proxy'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% http_proxy = grab_attributes(pwd)['http_proxy'] -%> describe google_compute_target_http_proxy(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, name: <%= doc_generation ? "'#{http_proxy['name']}'" : "http_proxy['name']" -%>) do it { should exist } its('description') { should eq <%= doc_generation ? "'#{http_proxy['description']}'" : "http_proxy['description']" -%> } - its('url_map') { should match /\/<%= "#{grab_attributes['url_map']['name']}" -%>$/ } + its('url_map') { should match /\/<%= "#{grab_attributes(pwd)['url_map']['name']}" -%>$/ } end describe google_compute_target_http_proxy(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, name: 'nonexistent') do diff --git a/templates/inspec/examples/google_compute_target_http_proxy/google_compute_target_http_proxy_attributes.erb b/templates/inspec/examples/google_compute_target_http_proxy/google_compute_target_http_proxy_attributes.erb index 0d67e44aad7e..c22a4ccdc5a9 100644 --- a/templates/inspec/examples/google_compute_target_http_proxy/google_compute_target_http_proxy_attributes.erb +++ b/templates/inspec/examples/google_compute_target_http_proxy/google_compute_target_http_proxy_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -http_proxy = attribute('http_proxy', default: <%= JSON.pretty_generate(grab_attributes['http_proxy']) -%>, description: 'Compute HTTP proxy definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +http_proxy = attribute('http_proxy', default: <%= JSON.pretty_generate(grab_attributes(pwd)['http_proxy']) -%>, description: 'Compute HTTP proxy definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_target_https_proxy/google_compute_target_https_proxies.erb b/templates/inspec/examples/google_compute_target_https_proxy/google_compute_target_https_proxies.erb index 9725d667a03a..c0fd2c13db94 100644 --- a/templates/inspec/examples/google_compute_target_https_proxy/google_compute_target_https_proxies.erb +++ b/templates/inspec/examples/google_compute_target_https_proxy/google_compute_target_https_proxies.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% https_proxy = grab_attributes['https_proxy'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% https_proxy = grab_attributes(pwd)['https_proxy'] -%> describe google_compute_target_https_proxies(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>) do its('names') { should include <%= doc_generation ? "'#{https_proxy['name']}'" : "https_proxy['name']" -%> } its('descriptions') { should include <%= doc_generation ? "'#{https_proxy['description']}'" : "https_proxy['description']" -%> } diff --git a/templates/inspec/examples/google_compute_target_https_proxy/google_compute_target_https_proxy.erb b/templates/inspec/examples/google_compute_target_https_proxy/google_compute_target_https_proxy.erb index 1c15594fd533..4d4314ac1a19 100644 --- a/templates/inspec/examples/google_compute_target_https_proxy/google_compute_target_https_proxy.erb +++ b/templates/inspec/examples/google_compute_target_https_proxy/google_compute_target_https_proxy.erb @@ -1,8 +1,8 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% https_proxy = grab_attributes['https_proxy'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% https_proxy = grab_attributes(pwd)['https_proxy'] -%> describe google_compute_target_https_proxy(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{https_proxy['name']}'" : "https_proxy['name']" -%>) do it { should exist } - its('url_map') { should match /\/<%= "#{grab_attributes['url_map']['name']}" -%>$/ } + its('url_map') { should match /\/<%= "#{grab_attributes(pwd)['url_map']['name']}" -%>$/ } its('description') { should eq <%= doc_generation ? "'#{https_proxy['description']}'" : "https_proxy['description']" -%> } end diff --git a/templates/inspec/examples/google_compute_target_https_proxy/google_compute_target_https_proxy_attributes.erb b/templates/inspec/examples/google_compute_target_https_proxy/google_compute_target_https_proxy_attributes.erb index db9531e0f747..6456f0f0171f 100644 --- a/templates/inspec/examples/google_compute_target_https_proxy/google_compute_target_https_proxy_attributes.erb +++ b/templates/inspec/examples/google_compute_target_https_proxy/google_compute_target_https_proxy_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -https_proxy = attribute('https_proxy', default: <%= JSON.pretty_generate(grab_attributes['https_proxy']) -%>, description: 'Compute HTTPS proxy definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +https_proxy = attribute('https_proxy', default: <%= JSON.pretty_generate(grab_attributes(pwd)['https_proxy']) -%>, description: 'Compute HTTPS proxy definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_target_pool/google_compute_target_pool.erb b/templates/inspec/examples/google_compute_target_pool/google_compute_target_pool.erb index 9a1de14a8043..bd45ee4c2deb 100644 --- a/templates/inspec/examples/google_compute_target_pool/google_compute_target_pool.erb +++ b/templates/inspec/examples/google_compute_target_pool/google_compute_target_pool.erb @@ -1,8 +1,8 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_ext_vm_name = "#{external_attribute('gcp_ext_vm_name', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% gcp_zone = "#{external_attribute('gcp_zone', doc_generation)}" -%> -<% target_pool = grab_attributes['target_pool'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_ext_vm_name = "#{external_attribute(pwd, 'gcp_ext_vm_name', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% gcp_zone = "#{external_attribute(pwd, 'gcp_zone', doc_generation)}" -%> +<% target_pool = grab_attributes(pwd)['target_pool'] -%> describe google_compute_target_pool(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>, name: <%= doc_generation ? "'#{target_pool['name']}'" : "target_pool['name']" -%>) do it { should exist } its('session_affinity') { should eq <%= doc_generation ? "'#{target_pool['session_affinity']}'" : "target_pool['session_affinity']" -%> } diff --git a/templates/inspec/examples/google_compute_target_pool/google_compute_target_pool_attributes.erb b/templates/inspec/examples/google_compute_target_pool/google_compute_target_pool_attributes.erb index d0a8f64fafd2..0a5c482b570e 100644 --- a/templates/inspec/examples/google_compute_target_pool/google_compute_target_pool_attributes.erb +++ b/templates/inspec/examples/google_compute_target_pool/google_compute_target_pool_attributes.erb @@ -1,5 +1,5 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'The GCP project region.') -gcp_ext_vm_name = attribute(:gcp_ext_vm_name, default: '<%= external_attribute('gcp_ext_vm_name') -%>', description: 'The name of a VM instance.') -target_pool = attribute('target_pool', default: <%= JSON.pretty_generate(grab_attributes['target_pool']) -%>, description: 'Target pool definition') -gcp_zone = attribute(:gcp_zone, default: '<%= external_attribute('gcp_zone') -%>', description: 'The GCP zone.') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_location = attribute(:gcp_location, default: '<%= external_attribute(pwd, 'gcp_location') -%>', description: 'The GCP project region.') +gcp_ext_vm_name = attribute(:gcp_ext_vm_name, default: '<%= external_attribute(pwd, 'gcp_ext_vm_name') -%>', description: 'The name of a VM instance.') +target_pool = attribute('target_pool', default: <%= JSON.pretty_generate(grab_attributes(pwd)['target_pool']) -%>, description: 'Target pool definition') +gcp_zone = attribute(:gcp_zone, default: '<%= external_attribute(pwd, 'gcp_zone') -%>', description: 'The GCP zone.') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_target_pool/google_compute_target_pools.erb b/templates/inspec/examples/google_compute_target_pool/google_compute_target_pools.erb index ab2f526f5bfa..c62ad3783d5c 100644 --- a/templates/inspec/examples/google_compute_target_pool/google_compute_target_pools.erb +++ b/templates/inspec/examples/google_compute_target_pool/google_compute_target_pools.erb @@ -1,7 +1,7 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_ext_vm_name = "#{external_attribute('gcp_ext_vm_name', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% target_pool = grab_attributes['target_pool'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_ext_vm_name = "#{external_attribute(pwd, 'gcp_ext_vm_name', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% target_pool = grab_attributes(pwd)['target_pool'] -%> describe google_compute_target_pools(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>) do its('names') { should include <%= doc_generation ? "'#{target_pool['name']}'" : "target_pool['name']" -%> } its('session_affinities') { should include <%= doc_generation ? "'#{target_pool['session_affinity']}'" : "target_pool['session_affinity']" -%> } diff --git a/templates/inspec/examples/google_compute_target_tcp_proxy/google_compute_target_tcp_proxies.erb b/templates/inspec/examples/google_compute_target_tcp_proxy/google_compute_target_tcp_proxies.erb index 8f7611821908..43d110e4ed2b 100644 --- a/templates/inspec/examples/google_compute_target_tcp_proxy/google_compute_target_tcp_proxies.erb +++ b/templates/inspec/examples/google_compute_target_tcp_proxy/google_compute_target_tcp_proxies.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% target_tcp_proxy = grab_attributes['target_tcp_proxy'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% target_tcp_proxy = grab_attributes(pwd)['target_tcp_proxy'] -%> describe google_compute_target_tcp_proxies(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>) do its('names') { should include <%= doc_generation ? "'#{target_tcp_proxy['name']}'" : "target_tcp_proxy['name']" -%> } its('proxy_headers') { should include <%= doc_generation ? "'#{target_tcp_proxy['proxy_header']}'" : "target_tcp_proxy['proxy_header']" -%> } diff --git a/templates/inspec/examples/google_compute_target_tcp_proxy/google_compute_target_tcp_proxy.erb b/templates/inspec/examples/google_compute_target_tcp_proxy/google_compute_target_tcp_proxy.erb index 83559e32eeec..778255958f68 100644 --- a/templates/inspec/examples/google_compute_target_tcp_proxy/google_compute_target_tcp_proxy.erb +++ b/templates/inspec/examples/google_compute_target_tcp_proxy/google_compute_target_tcp_proxy.erb @@ -1,9 +1,9 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% target_tcp_proxy = grab_attributes['target_tcp_proxy'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% target_tcp_proxy = grab_attributes(pwd)['target_tcp_proxy'] -%> describe google_compute_target_tcp_proxy(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, name: <%= doc_generation ? "'#{target_tcp_proxy['name']}'" : "target_tcp_proxy['name']" -%>) do it { should exist } its('proxy_header') { should eq <%= doc_generation ? "'#{target_tcp_proxy['proxy_header']}'" : "target_tcp_proxy['proxy_header']" -%> } - its('service') { should match /\/<%= "#{grab_attributes['target_tcp_proxy']['tcp_backend_service_name']}" -%>$/ } + its('service') { should match /\/<%= "#{grab_attributes(pwd)['target_tcp_proxy']['tcp_backend_service_name']}" -%>$/ } end describe google_compute_target_tcp_proxy(project: <%= doc_generation ? "#{gcp_project_id}" : "gcp_project_id" -%>, name: 'nonexistent') do diff --git a/templates/inspec/examples/google_compute_target_tcp_proxy/google_compute_target_tcp_proxy_attributes.erb b/templates/inspec/examples/google_compute_target_tcp_proxy/google_compute_target_tcp_proxy_attributes.erb index 549aba6f34d5..c1fc11c82636 100644 --- a/templates/inspec/examples/google_compute_target_tcp_proxy/google_compute_target_tcp_proxy_attributes.erb +++ b/templates/inspec/examples/google_compute_target_tcp_proxy/google_compute_target_tcp_proxy_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -target_tcp_proxy = attribute('target_tcp_proxy', default: <%= JSON.pretty_generate(grab_attributes['target_tcp_proxy']) -%>, description: 'Compute TCP proxy definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +target_tcp_proxy = attribute('target_tcp_proxy', default: <%= JSON.pretty_generate(grab_attributes(pwd)['target_tcp_proxy']) -%>, description: 'Compute TCP proxy definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_url_map/google_compute_url_map.erb b/templates/inspec/examples/google_compute_url_map/google_compute_url_map.erb index aa7bd6c24723..4e2a476964e6 100644 --- a/templates/inspec/examples/google_compute_url_map/google_compute_url_map.erb +++ b/templates/inspec/examples/google_compute_url_map/google_compute_url_map.erb @@ -1,14 +1,14 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% url_map = grab_attributes['url_map'] -%> -<% backend_service = grab_attributes['backend_service'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% url_map = grab_attributes(pwd)['url_map'] -%> +<% backend_service = grab_attributes(pwd)['backend_service'] -%> describe google_compute_url_map(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{url_map['name']}'" : "url_map['name']" -%>) do it { should exist } its('description') { should eq <%= doc_generation ? "'#{url_map['description']}'" : "url_map['description']" -%> } - its('default_service') { should match /\/<%= "#{grab_attributes['backend_service']['name']}" -%>$/ } + its('default_service') { should match /\/<%= "#{grab_attributes(pwd)['backend_service']['name']}" -%>$/ } its('host_rules.count') { should eq 1 } its('host_rules.first.hosts') { should include <%= doc_generation ? "'#{url_map['host_rule_host']}'" : "url_map['host_rule_host']" -%> } its('path_matchers.count') { should eq 1 } - its('path_matchers.first.default_service') { should match /\/<%= "#{grab_attributes['backend_service']['name']}" -%>$/ } + its('path_matchers.first.default_service') { should match /\/<%= "#{grab_attributes(pwd)['backend_service']['name']}" -%>$/ } its('tests.count') { should eq 1 } its('tests.first.host') { should eq <%= doc_generation ? "'#{url_map['test_host']}'" : "url_map['test_host']" -%> } its('tests.first.path') { should eq <%= doc_generation ? "'#{url_map['test_path']}'" : "url_map['test_path']" -%> } diff --git a/templates/inspec/examples/google_compute_url_map/google_compute_url_map_attributes.erb b/templates/inspec/examples/google_compute_url_map/google_compute_url_map_attributes.erb index 7af8bba0b9d3..eff3291ab96e 100644 --- a/templates/inspec/examples/google_compute_url_map/google_compute_url_map_attributes.erb +++ b/templates/inspec/examples/google_compute_url_map/google_compute_url_map_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -url_map = attribute('url_map', default: <%= JSON.pretty_generate(grab_attributes['url_map']) -%>, description: 'Compute URL map definition') -backend_service = attribute('backend_service', default: <%= JSON.pretty_generate(grab_attributes['backend_service']) -%>, description: 'Backend service definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +url_map = attribute('url_map', default: <%= JSON.pretty_generate(grab_attributes(pwd)['url_map']) -%>, description: 'Compute URL map definition') +backend_service = attribute('backend_service', default: <%= JSON.pretty_generate(grab_attributes(pwd)['backend_service']) -%>, description: 'Backend service definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_url_map/google_compute_url_maps.erb b/templates/inspec/examples/google_compute_url_map/google_compute_url_maps.erb index c62b0e148c0a..1bbae986c8bc 100644 --- a/templates/inspec/examples/google_compute_url_map/google_compute_url_maps.erb +++ b/templates/inspec/examples/google_compute_url_map/google_compute_url_maps.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% url_map = grab_attributes['url_map'] -%> -<% backend_service = grab_attributes['backend_service'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% url_map = grab_attributes(pwd)['url_map'] -%> +<% backend_service = grab_attributes(pwd)['backend_service'] -%> describe google_compute_url_maps(project: <%= gcp_project_id -%>) do its('names') { should include <%= doc_generation ? "'#{url_map['name']}'" : "url_map['name']" -%> } end \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_vpn_tunnel/google_compute_vpn_tunnel.erb b/templates/inspec/examples/google_compute_vpn_tunnel/google_compute_vpn_tunnel.erb index c143581ba957..d19d23bbba8d 100644 --- a/templates/inspec/examples/google_compute_vpn_tunnel/google_compute_vpn_tunnel.erb +++ b/templates/inspec/examples/google_compute_vpn_tunnel/google_compute_vpn_tunnel.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% vpn_tunnel = grab_attributes['vpn_tunnel'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% vpn_tunnel = grab_attributes(pwd)['vpn_tunnel'] -%> describe google_compute_vpn_tunnel(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>, name: <%= doc_generation ? "'#{vpn_tunnel['name']}'" : "vpn_tunnel['name']" -%>) do it { should exist } its('peer_ip') { should eq <%= doc_generation ? "'#{vpn_tunnel['peer_ip']}'" : "vpn_tunnel['peer_ip']" -%> } diff --git a/templates/inspec/examples/google_compute_vpn_tunnel/google_compute_vpn_tunnel_attributes.erb b/templates/inspec/examples/google_compute_vpn_tunnel/google_compute_vpn_tunnel_attributes.erb index e1bb650b7f1e..cb78252b3ae4 100644 --- a/templates/inspec/examples/google_compute_vpn_tunnel/google_compute_vpn_tunnel_attributes.erb +++ b/templates/inspec/examples/google_compute_vpn_tunnel/google_compute_vpn_tunnel_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'The GCP project region.') -vpn_tunnel = attribute('vpn_tunnel', default: <%= JSON.pretty_generate(grab_attributes['vpn_tunnel']) -%>, description: 'Compute VPN tunnel description') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_location = attribute(:gcp_location, default: '<%= external_attribute(pwd, 'gcp_location') -%>', description: 'The GCP project region.') +vpn_tunnel = attribute('vpn_tunnel', default: <%= JSON.pretty_generate(grab_attributes(pwd)['vpn_tunnel']) -%>, description: 'Compute VPN tunnel description') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_vpn_tunnel/google_compute_vpn_tunnels.erb b/templates/inspec/examples/google_compute_vpn_tunnel/google_compute_vpn_tunnels.erb index 51b4759aaccb..a7fced882e4f 100644 --- a/templates/inspec/examples/google_compute_vpn_tunnel/google_compute_vpn_tunnels.erb +++ b/templates/inspec/examples/google_compute_vpn_tunnel/google_compute_vpn_tunnels.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% vpn_tunnel = grab_attributes['vpn_tunnel'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% vpn_tunnel = grab_attributes(pwd)['vpn_tunnel'] -%> describe google_compute_vpn_tunnels(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>) do its('vpn_tunnel_names') { should include <%= doc_generation ? "'#{vpn_tunnel['name']}'" : "vpn_tunnel['name']" -%> } its('peer_ips') { should include <%= doc_generation ? "'#{vpn_tunnel['peer_ip']}'" : "vpn_tunnel['peer_ip']" -%> } diff --git a/templates/inspec/examples/google_compute_zone/google_compute_zone.erb b/templates/inspec/examples/google_compute_zone/google_compute_zone.erb index d9c1b73625d7..e28f451d9145 100644 --- a/templates/inspec/examples/google_compute_zone/google_compute_zone.erb +++ b/templates/inspec/examples/google_compute_zone/google_compute_zone.erb @@ -1,4 +1,4 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> describe google_compute_zone(project: <%= gcp_project_id -%>, name: "us-central1-a") do it { should exist } it { should be_up } diff --git a/templates/inspec/examples/google_compute_zone/google_compute_zone_attributes.erb b/templates/inspec/examples/google_compute_zone/google_compute_zone_attributes.erb index a2863dfa3703..9e434667ef77 100644 --- a/templates/inspec/examples/google_compute_zone/google_compute_zone_attributes.erb +++ b/templates/inspec/examples/google_compute_zone/google_compute_zone_attributes.erb @@ -1 +1 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') \ No newline at end of file diff --git a/templates/inspec/examples/google_compute_zone/google_compute_zones.erb b/templates/inspec/examples/google_compute_zone/google_compute_zones.erb index 3b0b0b5695bb..9c3187b81c81 100644 --- a/templates/inspec/examples/google_compute_zone/google_compute_zones.erb +++ b/templates/inspec/examples/google_compute_zone/google_compute_zones.erb @@ -1,4 +1,4 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> google_compute_zones(project: <%= gcp_project_id -%>).zone_names.each do |zone_name| describe google_compute_zone(project: <%= gcp_project_id -%>, name: zone_name) do it { should exist } diff --git a/templates/inspec/examples/google_container_cluster/google_container_cluster.erb b/templates/inspec/examples/google_container_cluster/google_container_cluster.erb index bbd98deaed4a..661f0d689f56 100644 --- a/templates/inspec/examples/google_container_cluster/google_container_cluster.erb +++ b/templates/inspec/examples/google_container_cluster/google_container_cluster.erb @@ -1,10 +1,10 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_kube_cluster_name = "#{external_attribute('gcp_kube_cluster_name', doc_generation)}" -%> -<% gcp_kube_cluster_zone = "#{external_attribute('gcp_kube_cluster_zone', doc_generation)}" -%> -<% gcp_kube_cluster_size = "#{external_attribute('gcp_kube_cluster_size', doc_generation)}" -%> -<% gcp_kube_cluster_zone_extra1 = "#{external_attribute('gcp_kube_cluster_zone_extra1', doc_generation)}" -%> -<% gcp_kube_cluster_zone_extra2 = "#{external_attribute('gcp_kube_cluster_zone_extra2', doc_generation)}" -%> -<% gcp_kube_cluster_master_user = "#{external_attribute('gcp_kube_cluster_master_user', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_kube_cluster_name = "#{external_attribute(pwd, 'gcp_kube_cluster_name', doc_generation)}" -%> +<% gcp_kube_cluster_zone = "#{external_attribute(pwd, 'gcp_kube_cluster_zone', doc_generation)}" -%> +<% gcp_kube_cluster_size = "#{external_attribute(pwd, 'gcp_kube_cluster_size', doc_generation)}" -%> +<% gcp_kube_cluster_zone_extra1 = "#{external_attribute(pwd, 'gcp_kube_cluster_zone_extra1', doc_generation)}" -%> +<% gcp_kube_cluster_zone_extra2 = "#{external_attribute(pwd, 'gcp_kube_cluster_zone_extra2', doc_generation)}" -%> +<% gcp_kube_cluster_master_user = "#{external_attribute(pwd, 'gcp_kube_cluster_master_user', doc_generation)}" -%> describe google_container_cluster(project: <%= gcp_project_id -%>, location: <%= gcp_kube_cluster_zone -%>, name: <%= gcp_kube_cluster_name -%>) do it { should exist } its('locations.sort'){ should cmp [ <%= gcp_kube_cluster_zone -%>, <%= gcp_kube_cluster_zone_extra1 -%>, <%= gcp_kube_cluster_zone_extra2 -%> ].sort } diff --git a/templates/inspec/examples/google_container_cluster/google_container_cluster_attributes.erb b/templates/inspec/examples/google_container_cluster/google_container_cluster_attributes.erb index c0a43756537c..2305faa0df95 100644 --- a/templates/inspec/examples/google_container_cluster/google_container_cluster_attributes.erb +++ b/templates/inspec/examples/google_container_cluster/google_container_cluster_attributes.erb @@ -1,7 +1,7 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_kube_cluster_name = attribute(:gcp_kube_cluster_name, default: '<%= external_attribute('gcp_kube_cluster_name') -%>', description: 'GCP container cluster name') -gcp_kube_cluster_zone = attribute(:gcp_kube_cluster_zone, default: '<%= external_attribute('gcp_kube_cluster_zone') -%>', description: 'GCP container cluster zone') -gcp_kube_cluster_size = attribute(:gcp_kube_cluster_size, default: '<%= external_attribute('gcp_kube_cluster_size') -%>', description: 'GCP container cluster size') -gcp_kube_cluster_zone_extra1 = attribute(:gcp_kube_cluster_zone_extra1, default: '<%= external_attribute('gcp_kube_cluster_zone_extra1') -%>', description: 'First extra zone for the cluster') -gcp_kube_cluster_zone_extra2 = attribute(:gcp_kube_cluster_zone_extra2, default: '<%= external_attribute('gcp_kube_cluster_zone_extra2') -%>', description: 'Second extra zone for the cluster') -gcp_kube_cluster_master_user = attribute(:gcp_kube_cluster_master_user, default: '<%= external_attribute('gcp_kube_cluster_master_user') -%>', description: 'GCP container cluster admin username') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_kube_cluster_name = attribute(:gcp_kube_cluster_name, default: '<%= external_attribute(pwd, 'gcp_kube_cluster_name') -%>', description: 'GCP container cluster name') +gcp_kube_cluster_zone = attribute(:gcp_kube_cluster_zone, default: '<%= external_attribute(pwd, 'gcp_kube_cluster_zone') -%>', description: 'GCP container cluster zone') +gcp_kube_cluster_size = attribute(:gcp_kube_cluster_size, default: '<%= external_attribute(pwd, 'gcp_kube_cluster_size') -%>', description: 'GCP container cluster size') +gcp_kube_cluster_zone_extra1 = attribute(:gcp_kube_cluster_zone_extra1, default: '<%= external_attribute(pwd, 'gcp_kube_cluster_zone_extra1') -%>', description: 'First extra zone for the cluster') +gcp_kube_cluster_zone_extra2 = attribute(:gcp_kube_cluster_zone_extra2, default: '<%= external_attribute(pwd, 'gcp_kube_cluster_zone_extra2') -%>', description: 'Second extra zone for the cluster') +gcp_kube_cluster_master_user = attribute(:gcp_kube_cluster_master_user, default: '<%= external_attribute(pwd, 'gcp_kube_cluster_master_user') -%>', description: 'GCP container cluster admin username') \ No newline at end of file diff --git a/templates/inspec/examples/google_container_cluster/google_container_clusters.erb b/templates/inspec/examples/google_container_cluster/google_container_clusters.erb index 0015fc63a5e9..0bdeb62af514 100644 --- a/templates/inspec/examples/google_container_cluster/google_container_clusters.erb +++ b/templates/inspec/examples/google_container_cluster/google_container_clusters.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_kube_cluster_name = "#{external_attribute('gcp_kube_cluster_name', doc_generation)}" -%> -<% gcp_kube_cluster_zone = "#{external_attribute('gcp_kube_cluster_zone', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_kube_cluster_name = "#{external_attribute(pwd, 'gcp_kube_cluster_name', doc_generation)}" -%> +<% gcp_kube_cluster_zone = "#{external_attribute(pwd, 'gcp_kube_cluster_zone', doc_generation)}" -%> describe google_container_clusters(project: <%= gcp_project_id -%>, location: <%= gcp_kube_cluster_zone -%>) do its('cluster_names') { should include <%= gcp_kube_cluster_name -%> } end \ No newline at end of file diff --git a/templates/inspec/examples/google_container_node_pool/google_container_node_pool.erb b/templates/inspec/examples/google_container_node_pool/google_container_node_pool.erb index 1696c4e039ee..92888408e356 100644 --- a/templates/inspec/examples/google_container_node_pool/google_container_node_pool.erb +++ b/templates/inspec/examples/google_container_node_pool/google_container_node_pool.erb @@ -1,7 +1,7 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_kube_cluster_zone = "#{external_attribute('gcp_kube_cluster_zone', doc_generation)}" -%> -<% gcp_kube_cluster_name = "#{external_attribute('gcp_kube_cluster_name', doc_generation)}" -%> -<% regional_node_pool = grab_attributes['regional_node_pool'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_kube_cluster_zone = "#{external_attribute(pwd, 'gcp_kube_cluster_zone', doc_generation)}" -%> +<% gcp_kube_cluster_name = "#{external_attribute(pwd, 'gcp_kube_cluster_name', doc_generation)}" -%> +<% regional_node_pool = grab_attributes(pwd)['regional_node_pool'] -%> describe google_container_node_pool(project: <%= gcp_project_id -%>, location: <%= gcp_kube_cluster_zone -%>, cluster_name: <%= gcp_kube_cluster_name -%>, nodepool_name: <%= doc_generation ? "'#{regional_node_pool['name']}'" : "regional_node_pool['name']" -%>) do it { should exist } its('initial_node_count') { should eq <%= doc_generation ? "'#{regional_node_pool['initial_node_count']}'" : "regional_node_pool['initial_node_count']" -%>} diff --git a/templates/inspec/examples/google_container_node_pool/google_container_node_pool_attributes.erb b/templates/inspec/examples/google_container_node_pool/google_container_node_pool_attributes.erb index c7f6605ecf02..9e87d0275330 100644 --- a/templates/inspec/examples/google_container_node_pool/google_container_node_pool_attributes.erb +++ b/templates/inspec/examples/google_container_node_pool/google_container_node_pool_attributes.erb @@ -1,4 +1,4 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_kube_cluster_zone = attribute(:gcp_kube_cluster_zone, default: '<%= external_attribute('gcp_kube_cluster_zone') -%>', description: 'The zone that the kube cluster resides in.') -gcp_kube_cluster_name = attribute(:gcp_kube_cluster_name, default: '<%= external_attribute('gcp_kube_cluster_name') -%>', description: 'The parent container clusters name.') -regional_node_pool = attribute('regional_node_pool', default: <%= JSON.pretty_generate(grab_attributes['regional_node_pool']) -%>, description: 'Regional Node Pool definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_kube_cluster_zone = attribute(:gcp_kube_cluster_zone, default: '<%= external_attribute(pwd, 'gcp_kube_cluster_zone') -%>', description: 'The zone that the kube cluster resides in.') +gcp_kube_cluster_name = attribute(:gcp_kube_cluster_name, default: '<%= external_attribute(pwd, 'gcp_kube_cluster_name') -%>', description: 'The parent container clusters name.') +regional_node_pool = attribute('regional_node_pool', default: <%= JSON.pretty_generate(grab_attributes(pwd)['regional_node_pool']) -%>, description: 'Regional Node Pool definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_container_node_pool/google_container_node_pools.erb b/templates/inspec/examples/google_container_node_pool/google_container_node_pools.erb index ee69dd74f731..143676e83699 100644 --- a/templates/inspec/examples/google_container_node_pool/google_container_node_pools.erb +++ b/templates/inspec/examples/google_container_node_pool/google_container_node_pools.erb @@ -1,7 +1,7 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_kube_cluster_zone = "#{external_attribute('gcp_kube_cluster_zone', doc_generation)}" -%> -<% gcp_kube_cluster_name = "#{external_attribute('gcp_kube_cluster_name', doc_generation)}" -%> -<% regional_node_pool = grab_attributes['regional_node_pool'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_kube_cluster_zone = "#{external_attribute(pwd, 'gcp_kube_cluster_zone', doc_generation)}" -%> +<% gcp_kube_cluster_name = "#{external_attribute(pwd, 'gcp_kube_cluster_name', doc_generation)}" -%> +<% regional_node_pool = grab_attributes(pwd)['regional_node_pool'] -%> describe google_container_node_pools(project: <%= gcp_project_id -%>, location: <%= gcp_kube_cluster_zone -%>, cluster_name: <%= gcp_kube_cluster_name -%>) do its('initial_node_counts') { should include <%= doc_generation ? "'#{regional_node_pool['initial_node_count']}'" : "regional_node_pool['initial_node_count']" -%>} end \ No newline at end of file diff --git a/templates/inspec/examples/google_dataproc_cluster/google_dataproc_cluster.erb b/templates/inspec/examples/google_dataproc_cluster/google_dataproc_cluster.erb index 2ca9b6559a6f..b0bc5f65c1b6 100644 --- a/templates/inspec/examples/google_dataproc_cluster/google_dataproc_cluster.erb +++ b/templates/inspec/examples/google_dataproc_cluster/google_dataproc_cluster.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% dataproc_cluster = grab_attributes['dataproc_cluster'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% dataproc_cluster = grab_attributes(pwd)['dataproc_cluster'] -%> describe google_dataproc_cluster(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>, cluster_name: <%= doc_generation ? "'#{dataproc_cluster['name']}'" : "dataproc_cluster['name']" -%>) do it { should exist } its('labels') { should include(<%= doc_generation ? "'#{dataproc_cluster['label_key']}'" : "dataproc_cluster['label_key']" -%> => <%= doc_generation ? "'#{dataproc_cluster['label_value']}'" : "dataproc_cluster['label_value']" -%>) } diff --git a/templates/inspec/examples/google_dataproc_cluster/google_dataproc_cluster_attributes.erb b/templates/inspec/examples/google_dataproc_cluster/google_dataproc_cluster_attributes.erb index be9eb6d44303..d264472ff326 100644 --- a/templates/inspec/examples/google_dataproc_cluster/google_dataproc_cluster_attributes.erb +++ b/templates/inspec/examples/google_dataproc_cluster/google_dataproc_cluster_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'The GCP project region.') -dataproc_cluster = attribute('dataproc_cluster', default: <%= JSON.pretty_generate(grab_attributes['dataproc_cluster']) -%>, description: 'Dataproc cluster definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_location = attribute(:gcp_location, default: '<%= external_attribute(pwd, 'gcp_location') -%>', description: 'The GCP project region.') +dataproc_cluster = attribute('dataproc_cluster', default: <%= JSON.pretty_generate(grab_attributes(pwd)['dataproc_cluster']) -%>, description: 'Dataproc cluster definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_dataproc_cluster/google_dataproc_clusters.erb b/templates/inspec/examples/google_dataproc_cluster/google_dataproc_clusters.erb index 72f6ded703dc..fd46d12cf017 100644 --- a/templates/inspec/examples/google_dataproc_cluster/google_dataproc_clusters.erb +++ b/templates/inspec/examples/google_dataproc_cluster/google_dataproc_clusters.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% dataproc_cluster = grab_attributes['dataproc_cluster'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% dataproc_cluster = grab_attributes(pwd)['dataproc_cluster'] -%> describe google_dataproc_clusters(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>) do its('count') { should be >= 1 } its('cluster_names') { should include <%= doc_generation ? "'#{dataproc_cluster['name']}'" : "dataproc_cluster['name']" -%> } diff --git a/templates/inspec/examples/google_dns_managed_zone/google_dns_managed_zone.erb b/templates/inspec/examples/google_dns_managed_zone/google_dns_managed_zone.erb index e8bfb724cc0e..fc3e0a0d34cc 100644 --- a/templates/inspec/examples/google_dns_managed_zone/google_dns_managed_zone.erb +++ b/templates/inspec/examples/google_dns_managed_zone/google_dns_managed_zone.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_dns_zone_name = "#{external_attribute('gcp_dns_zone_name', doc_generation)}" -%> -<% dns_managed_zone = grab_attributes['dns_managed_zone'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_dns_zone_name = "#{external_attribute(pwd, 'gcp_dns_zone_name', doc_generation)}" -%> +<% dns_managed_zone = grab_attributes(pwd)['dns_managed_zone'] -%> describe google_dns_managed_zone(project: <%= gcp_project_id -%>, zone: <%= doc_generation ? "'#{dns_managed_zone['name']}'" : "dns_managed_zone['name']" -%>) do it { should exist } its('dns_name') { should cmp <%= gcp_dns_zone_name -%> } diff --git a/templates/inspec/examples/google_dns_managed_zone/google_dns_managed_zone_attributes.erb b/templates/inspec/examples/google_dns_managed_zone/google_dns_managed_zone_attributes.erb index 880ff948b058..bcb68a6122d0 100644 --- a/templates/inspec/examples/google_dns_managed_zone/google_dns_managed_zone_attributes.erb +++ b/templates/inspec/examples/google_dns_managed_zone/google_dns_managed_zone_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_dns_zone_name = attribute(:gcp_dns_zone_name, default: '<%= external_attribute('gcp_dns_zone_name') -%>', description: 'The DNS name of the DNS zone.') -dns_managed_zone = attribute('dns_managed_zone', default: <%= grab_attributes['dns_managed_zone'] -%>) \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_dns_zone_name = attribute(:gcp_dns_zone_name, default: '<%= external_attribute(pwd, 'gcp_dns_zone_name') -%>', description: 'The DNS name of the DNS zone.') +dns_managed_zone = attribute('dns_managed_zone', default: <%= grab_attributes(pwd)['dns_managed_zone'] -%>) \ No newline at end of file diff --git a/templates/inspec/examples/google_dns_managed_zone/google_dns_managed_zones.erb b/templates/inspec/examples/google_dns_managed_zone/google_dns_managed_zones.erb index 81fbbaf38d5f..49413c899ee0 100644 --- a/templates/inspec/examples/google_dns_managed_zone/google_dns_managed_zones.erb +++ b/templates/inspec/examples/google_dns_managed_zone/google_dns_managed_zones.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_dns_zone_name = "#{external_attribute('gcp_dns_zone_name', doc_generation)}" -%> -<% dns_managed_zone = grab_attributes['dns_managed_zone'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_dns_zone_name = "#{external_attribute(pwd, 'gcp_dns_zone_name', doc_generation)}" -%> +<% dns_managed_zone = grab_attributes(pwd)['dns_managed_zone'] -%> describe google_dns_managed_zones(project: <%= gcp_project_id -%>) do it { should exist } its('zone_names') { should include <%= doc_generation ? "'#{dns_managed_zone['name']}'" : "dns_managed_zone['name']" -%> } diff --git a/templates/inspec/examples/google_dns_resource_record_set/google_dns_resource_record_set.erb b/templates/inspec/examples/google_dns_resource_record_set/google_dns_resource_record_set.erb index 2860e3877e03..6684b8a4dbb7 100644 --- a/templates/inspec/examples/google_dns_resource_record_set/google_dns_resource_record_set.erb +++ b/templates/inspec/examples/google_dns_resource_record_set/google_dns_resource_record_set.erb @@ -1,6 +1,6 @@ -<% record_set = grab_attributes['record_set'] -%> -<% managed_zone = grab_attributes['managed_zone'] -%> -describe google_dns_resource_record_set(project: <%= "#{external_attribute('gcp_project_id', doc_generation)}" -%>, name: <%= doc_generation ? "'#{record_set['name']}'" : "record_set['name']" -%>, type: <%= doc_generation ? "'#{record_set['type']}'" : "record_set['type']" -%>, managed_zone: <%= doc_generation ? "'#{managed_zone['name']}'" : "managed_zone['name']" -%>) do +<% record_set = grab_attributes(pwd)['record_set'] -%> +<% managed_zone = grab_attributes(pwd)['managed_zone'] -%> +describe google_dns_resource_record_set(project: <%= "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%>, name: <%= doc_generation ? "'#{record_set['name']}'" : "record_set['name']" -%>, type: <%= doc_generation ? "'#{record_set['type']}'" : "record_set['type']" -%>, managed_zone: <%= doc_generation ? "'#{managed_zone['name']}'" : "managed_zone['name']" -%>) do it { should exist } its('type') { should eq <%= doc_generation ? "'#{record_set['type']}'" : "record_set['type']" -%> } its('ttl') { should eq <%= doc_generation ? "'#{record_set['ttl']}'" : "record_set['ttl']" -%> } diff --git a/templates/inspec/examples/google_dns_resource_record_set/google_dns_resource_record_set_attributes.erb b/templates/inspec/examples/google_dns_resource_record_set/google_dns_resource_record_set_attributes.erb index ffd8dfb667a4..7813cc172a26 100644 --- a/templates/inspec/examples/google_dns_resource_record_set/google_dns_resource_record_set_attributes.erb +++ b/templates/inspec/examples/google_dns_resource_record_set/google_dns_resource_record_set_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -record_set = attribute('record_set', default: <%= JSON.pretty_generate(grab_attributes['record_set']) -%>) -managed_zone = attribute('managed_zone', default: <%= JSON.pretty_generate(grab_attributes['managed_zone']) -%>) \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +record_set = attribute('record_set', default: <%= JSON.pretty_generate(grab_attributes(pwd)['record_set']) -%>) +managed_zone = attribute('managed_zone', default: <%= JSON.pretty_generate(grab_attributes(pwd)['managed_zone']) -%>) \ No newline at end of file diff --git a/templates/inspec/examples/google_dns_resource_record_set/google_dns_resource_record_sets.erb b/templates/inspec/examples/google_dns_resource_record_set/google_dns_resource_record_sets.erb index cb2f186f4f4f..4a121c13165f 100644 --- a/templates/inspec/examples/google_dns_resource_record_set/google_dns_resource_record_sets.erb +++ b/templates/inspec/examples/google_dns_resource_record_set/google_dns_resource_record_sets.erb @@ -1,6 +1,6 @@ -<% record_set = grab_attributes['record_set'] -%> -<% managed_zone = grab_attributes['managed_zone'] -%> -describe google_dns_resource_record_sets(project: <%= "#{external_attribute('gcp_project_id', doc_generation)}" -%>, name: <%= doc_generation ? "'#{record_set['name']}'" : "record_set['name']" -%>, managed_zone: <%= doc_generation ? "'#{managed_zone['name']}'" : "managed_zone['name']" -%>) do +<% record_set = grab_attributes(pwd)['record_set'] -%> +<% managed_zone = grab_attributes(pwd)['managed_zone'] -%> +describe google_dns_resource_record_sets(project: <%= "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%>, name: <%= doc_generation ? "'#{record_set['name']}'" : "record_set['name']" -%>, managed_zone: <%= doc_generation ? "'#{managed_zone['name']}'" : "managed_zone['name']" -%>) do its('count') { should eq 3 } its('types') { should include <%= doc_generation ? "'#{record_set['type']}'" : "record_set['type']" -%> } its('ttls') { should include <%= doc_generation ? "'#{record_set['ttl']}'" : "record_set['ttl']" -%> } diff --git a/templates/inspec/examples/google_filestore_instance/google_filestore_instance.erb b/templates/inspec/examples/google_filestore_instance/google_filestore_instance.erb index 10a5a7c1d596..7c09bc70125d 100644 --- a/templates/inspec/examples/google_filestore_instance/google_filestore_instance.erb +++ b/templates/inspec/examples/google_filestore_instance/google_filestore_instance.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% filestore_instance = grab_attributes['filestore_instance'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% filestore_instance = grab_attributes(pwd)['filestore_instance'] -%> describe google_filestore_instance(project: <%= gcp_project_id -%>, zone: <%= doc_generation ? "'#{filestore_instance['zone']}'" : "filestore_instance['zone']" -%>, name: <%= doc_generation ? "'#{filestore_instance['name']}'" : "filestore_instance['name']" -%>) do it { should exist } its('tier') { should cmp <%= doc_generation ? "'#{filestore_instance['tier']}'" : "filestore_instance['tier']" -%> } diff --git a/templates/inspec/examples/google_filestore_instance/google_filestore_instance_attributes.erb b/templates/inspec/examples/google_filestore_instance/google_filestore_instance_attributes.erb index 455ff911c660..e2aa864df739 100644 --- a/templates/inspec/examples/google_filestore_instance/google_filestore_instance_attributes.erb +++ b/templates/inspec/examples/google_filestore_instance/google_filestore_instance_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -filestore_instance = attribute('filestore_instance', default: <%= grab_attributes['filestore_instance'] -%>) \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +filestore_instance = attribute('filestore_instance', default: <%= grab_attributes(pwd)['filestore_instance'] -%>) \ No newline at end of file diff --git a/templates/inspec/examples/google_filestore_instance/google_filestore_instances.erb b/templates/inspec/examples/google_filestore_instance/google_filestore_instances.erb index 2d0937151334..81a4fbe3e5b1 100644 --- a/templates/inspec/examples/google_filestore_instance/google_filestore_instances.erb +++ b/templates/inspec/examples/google_filestore_instance/google_filestore_instances.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% filestore_instance = grab_attributes['filestore_instance'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% filestore_instance = grab_attributes(pwd)['filestore_instance'] -%> describe google_filestore_instances(project: <%= gcp_project_id -%>, zone: <%= doc_generation ? "'#{filestore_instance['zone']}'" : "filestore_instance['zone']" -%>) do its('tiers') { should include <%= doc_generation ? "'#{filestore_instance['tier']}'" : "filestore_instance['tier']" -%> } end \ No newline at end of file diff --git a/templates/inspec/examples/google_iam_organization_custom_role/google_iam_organization_custom_role.erb b/templates/inspec/examples/google_iam_organization_custom_role/google_iam_organization_custom_role.erb index f22abe83d203..c3c1ff1eb05d 100644 --- a/templates/inspec/examples/google_iam_organization_custom_role/google_iam_organization_custom_role.erb +++ b/templates/inspec/examples/google_iam_organization_custom_role/google_iam_organization_custom_role.erb @@ -1,5 +1,5 @@ -<% gcp_organization_id = "#{external_attribute('gcp_organization_id', doc_generation)}" -%> -<% gcp_organization_iam_custom_role_id = "#{external_attribute('gcp_organization_iam_custom_role_id', doc_generation)}" -%> +<% gcp_organization_id = "#{external_attribute(pwd, 'gcp_organization_id', doc_generation)}" -%> +<% gcp_organization_iam_custom_role_id = "#{external_attribute(pwd, 'gcp_organization_iam_custom_role_id', doc_generation)}" -%> describe google_iam_organization_custom_role(org_id: <%= doc_generation ? "'12345'" : "gcp_organization_id" -%>, name: <%= gcp_organization_iam_custom_role_id -%>) do it { should exist } its('stage') { should eq 'GA' } diff --git a/templates/inspec/examples/google_iam_organization_custom_role/google_iam_organization_custom_role_attributes.erb b/templates/inspec/examples/google_iam_organization_custom_role/google_iam_organization_custom_role_attributes.erb index cf9ae4c17e6a..47bf93a86119 100644 --- a/templates/inspec/examples/google_iam_organization_custom_role/google_iam_organization_custom_role_attributes.erb +++ b/templates/inspec/examples/google_iam_organization_custom_role/google_iam_organization_custom_role_attributes.erb @@ -1,3 +1,3 @@ -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization that is the parent of the folder') -gcp_organization_iam_custom_role_id = attribute(:gcp_organization_iam_custom_role_id, default: '<%= external_attribute('gcp_organization_iam_custom_role_id') -%>', description: 'The IAM custom role identifier.') +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization that is the parent of the folder') +gcp_organization_iam_custom_role_id = attribute(:gcp_organization_iam_custom_role_id, default: '<%= external_attribute(pwd, 'gcp_organization_iam_custom_role_id') -%>', description: 'The IAM custom role identifier.') gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default:0, description:'Flag to enable privileged resources requiring elevated privileges in GCP.') \ No newline at end of file diff --git a/templates/inspec/examples/google_iam_organization_custom_role/google_iam_organization_custom_roles.erb b/templates/inspec/examples/google_iam_organization_custom_role/google_iam_organization_custom_roles.erb index 2cd25f40250d..743c59acbd7c 100644 --- a/templates/inspec/examples/google_iam_organization_custom_role/google_iam_organization_custom_roles.erb +++ b/templates/inspec/examples/google_iam_organization_custom_role/google_iam_organization_custom_roles.erb @@ -1,5 +1,5 @@ -<% gcp_organization_id = "#{external_attribute('gcp_organization_id', doc_generation)}" -%> -<% gcp_organization_iam_custom_role_id = "#{external_attribute('gcp_organization_iam_custom_role_id', doc_generation)}" -%> +<% gcp_organization_id = "#{external_attribute(pwd, 'gcp_organization_id', doc_generation)}" -%> +<% gcp_organization_iam_custom_role_id = "#{external_attribute(pwd, 'gcp_organization_iam_custom_role_id', doc_generation)}" -%> describe google_iam_organization_custom_roles(org_id: <%= gcp_organization_id -%>) do its('names') { should include "organizations/<%= doc_generation ? "123456" : "\#{gcp_organization_id}" -%>/roles/<%= doc_generation ? "role-id" : "\#{gcp_organization_iam_custom_role_id}" -%>" } end \ No newline at end of file diff --git a/templates/inspec/examples/google_kms_crypto_key/google_kms_crypto_key.erb b/templates/inspec/examples/google_kms_crypto_key/google_kms_crypto_key.erb index 900a5bd51281..55fd13a5474e 100644 --- a/templates/inspec/examples/google_kms_crypto_key/google_kms_crypto_key.erb +++ b/templates/inspec/examples/google_kms_crypto_key/google_kms_crypto_key.erb @@ -1,7 +1,7 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% gcp_kms_key_ring_policy_name = "#{external_attribute('gcp_kms_key_ring_policy_name', doc_generation)}" -%> -<% gcp_kms_crypto_key_name_policy = "#{external_attribute('gcp_kms_crypto_key_name_policy', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% gcp_kms_key_ring_policy_name = "#{external_attribute(pwd, 'gcp_kms_key_ring_policy_name', doc_generation)}" -%> +<% gcp_kms_crypto_key_name_policy = "#{external_attribute(pwd, 'gcp_kms_crypto_key_name_policy', doc_generation)}" -%> describe google_kms_crypto_key(project: <%= gcp_project_id -%>, location: <%= gcp_location -%>, key_ring_name: <%= gcp_kms_key_ring_policy_name -%>, name: <%= gcp_kms_crypto_key_name_policy -%>) do it { should exist } its('crypto_key_name') { should cmp <%= gcp_kms_crypto_key_name_policy -%> } diff --git a/templates/inspec/examples/google_kms_crypto_key/google_kms_crypto_key_attributes.erb b/templates/inspec/examples/google_kms_crypto_key/google_kms_crypto_key_attributes.erb index 1cb85513506e..3c3fd43f8123 100644 --- a/templates/inspec/examples/google_kms_crypto_key/google_kms_crypto_key_attributes.erb +++ b/templates/inspec/examples/google_kms_crypto_key/google_kms_crypto_key_attributes.erb @@ -1,6 +1,6 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'GCP location') -gcp_kms_key_ring_policy_name = attribute(:gcp_kms_key_ring_policy_name, default: '<%= external_attribute('gcp_kms_key_ring_policy_name') -%>', description: 'Key ring name') -gcp_kms_crypto_key_name_policy = attribute(:gcp_kms_crypto_key_name_policy, default: '<%= external_attribute('gcp_kms_crypto_key_name_policy') -%>', description: 'Key name') -gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default: '<%= external_attribute('gcp_enable_privileged_resources') -%>', description: 'If we are running tests with escalated permissions(required for this test)') -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_location = attribute(:gcp_location, default: '<%= external_attribute(pwd, 'gcp_location') -%>', description: 'GCP location') +gcp_kms_key_ring_policy_name = attribute(:gcp_kms_key_ring_policy_name, default: '<%= external_attribute(pwd, 'gcp_kms_key_ring_policy_name') -%>', description: 'Key ring name') +gcp_kms_crypto_key_name_policy = attribute(:gcp_kms_crypto_key_name_policy, default: '<%= external_attribute(pwd, 'gcp_kms_crypto_key_name_policy') -%>', description: 'Key name') +gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default: '<%= external_attribute(pwd, 'gcp_enable_privileged_resources') -%>', description: 'If we are running tests with escalated permissions(required for this test)') +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file diff --git a/templates/inspec/examples/google_kms_crypto_key/google_kms_crypto_keys.erb b/templates/inspec/examples/google_kms_crypto_key/google_kms_crypto_keys.erb index 97a25781bbaa..da66280eb1cd 100644 --- a/templates/inspec/examples/google_kms_crypto_key/google_kms_crypto_keys.erb +++ b/templates/inspec/examples/google_kms_crypto_key/google_kms_crypto_keys.erb @@ -1,7 +1,7 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% gcp_kms_key_ring_policy_name = "#{external_attribute('gcp_kms_key_ring_policy_name', doc_generation)}" -%> -<% gcp_kms_crypto_key_name_policy = "#{external_attribute('gcp_kms_crypto_key_name_policy', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% gcp_kms_key_ring_policy_name = "#{external_attribute(pwd, 'gcp_kms_key_ring_policy_name', doc_generation)}" -%> +<% gcp_kms_crypto_key_name_policy = "#{external_attribute(pwd, 'gcp_kms_crypto_key_name_policy', doc_generation)}" -%> describe google_kms_crypto_keys(project: <%= gcp_project_id -%>, location: <%= gcp_location -%>, key_ring_name: <%= gcp_kms_key_ring_policy_name -%>) do its('count') { should be >= 1 } its('crypto_key_names') { should include <%= gcp_kms_crypto_key_name_policy -%> } diff --git a/templates/inspec/examples/google_kms_key_ring/google_kms_key_ring.erb b/templates/inspec/examples/google_kms_key_ring/google_kms_key_ring.erb index 4648cbe70bfb..8667bc6d2e2a 100644 --- a/templates/inspec/examples/google_kms_key_ring/google_kms_key_ring.erb +++ b/templates/inspec/examples/google_kms_key_ring/google_kms_key_ring.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% gcp_kms_key_ring_policy_name = "#{external_attribute('gcp_kms_key_ring_policy_name', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% gcp_kms_key_ring_policy_name = "#{external_attribute(pwd, 'gcp_kms_key_ring_policy_name', doc_generation)}" -%> describe google_kms_key_ring(project: <%= gcp_project_id -%>, location: <%= gcp_location -%>, name: <%= gcp_kms_key_ring_policy_name -%>) do it { should exist } its('create_time') { should be > Time.now - 365*60*60*24*10 } diff --git a/templates/inspec/examples/google_kms_key_ring/google_kms_key_ring_attributes.erb b/templates/inspec/examples/google_kms_key_ring/google_kms_key_ring_attributes.erb index 13f1c1fd66c1..7dbcf06ad173 100644 --- a/templates/inspec/examples/google_kms_key_ring/google_kms_key_ring_attributes.erb +++ b/templates/inspec/examples/google_kms_key_ring/google_kms_key_ring_attributes.erb @@ -1,5 +1,5 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'GCP location') -gcp_kms_key_ring_policy_name = attribute(:gcp_kms_key_ring_policy_name, default: '<%= external_attribute('gcp_kms_key_ring_policy_name') -%>', description: 'Key ring name') -gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default: '<%= external_attribute('gcp_enable_privileged_resources') -%>', description: 'If we are running tests with escalated permissions(required for this test)') -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_location = attribute(:gcp_location, default: '<%= external_attribute(pwd, 'gcp_location') -%>', description: 'GCP location') +gcp_kms_key_ring_policy_name = attribute(:gcp_kms_key_ring_policy_name, default: '<%= external_attribute(pwd, 'gcp_kms_key_ring_policy_name') -%>', description: 'Key ring name') +gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default: '<%= external_attribute(pwd, 'gcp_enable_privileged_resources') -%>', description: 'If we are running tests with escalated permissions(required for this test)') +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file diff --git a/templates/inspec/examples/google_kms_key_ring/google_kms_key_rings.erb b/templates/inspec/examples/google_kms_key_ring/google_kms_key_rings.erb index 7c904825d9fb..fa4bfa94abf7 100644 --- a/templates/inspec/examples/google_kms_key_ring/google_kms_key_rings.erb +++ b/templates/inspec/examples/google_kms_key_ring/google_kms_key_rings.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% gcp_kms_key_ring_policy_name = "#{external_attribute('gcp_kms_key_ring_policy_name', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% gcp_kms_key_ring_policy_name = "#{external_attribute(pwd, 'gcp_kms_key_ring_policy_name', doc_generation)}" -%> describe google_kms_key_rings(project: <%= gcp_project_id -%>, location: <%= gcp_location -%>) do its('key_ring_names'){ should include <%= gcp_kms_key_ring_policy_name -%> } end diff --git a/templates/inspec/examples/google_logging_folder_exclusion/google_logging_folder_exclusion.erb b/templates/inspec/examples/google_logging_folder_exclusion/google_logging_folder_exclusion.erb index 8970222e1d72..2b729b2a3127 100644 --- a/templates/inspec/examples/google_logging_folder_exclusion/google_logging_folder_exclusion.erb +++ b/templates/inspec/examples/google_logging_folder_exclusion/google_logging_folder_exclusion.erb @@ -1,5 +1,5 @@ -<% gcp_organization_id = "#{external_attribute('gcp_organization_id', doc_generation)}" -%> -<% folder_exclusion = grab_attributes['folder_exclusion'] -%> +<% gcp_organization_id = "#{external_attribute(pwd, 'gcp_organization_id', doc_generation)}" -%> +<% folder_exclusion = grab_attributes(pwd)['folder_exclusion'] -%> # Getting folder exclusions is complicated due to the name being generated by the server. # This can be drastically simplified if you have the name when writing the test describe.one do diff --git a/templates/inspec/examples/google_logging_folder_exclusion/google_logging_folder_exclusion_attributes.erb b/templates/inspec/examples/google_logging_folder_exclusion/google_logging_folder_exclusion_attributes.erb index 0a91d7605666..4e5581f1b1c5 100644 --- a/templates/inspec/examples/google_logging_folder_exclusion/google_logging_folder_exclusion_attributes.erb +++ b/templates/inspec/examples/google_logging_folder_exclusion/google_logging_folder_exclusion_attributes.erb @@ -1,3 +1,3 @@ -folder_exclusion = attribute('folder_exclusion', default: <%= grab_attributes['folder_exclusion'] -%>) -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization that is the parent of the folder') +folder_exclusion = attribute('folder_exclusion', default: <%= grab_attributes(pwd)['folder_exclusion'] -%>) +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization that is the parent of the folder') gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default:0, description:'Flag to enable privileged resources requiring elevated privileges in GCP.') \ No newline at end of file diff --git a/templates/inspec/examples/google_logging_folder_exclusion/google_logging_folder_exclusions.erb b/templates/inspec/examples/google_logging_folder_exclusion/google_logging_folder_exclusions.erb index fed3a9f22d13..d90b0d09131d 100644 --- a/templates/inspec/examples/google_logging_folder_exclusion/google_logging_folder_exclusions.erb +++ b/templates/inspec/examples/google_logging_folder_exclusion/google_logging_folder_exclusions.erb @@ -1,5 +1,5 @@ -<% gcp_organization_id = "#{external_attribute('gcp_organization_id', doc_generation)}" -%> -<% folder_exclusion = grab_attributes['folder_exclusion'] -%> +<% gcp_organization_id = "#{external_attribute(pwd, 'gcp_organization_id', doc_generation)}" -%> +<% folder_exclusion = grab_attributes(pwd)['folder_exclusion'] -%> # Getting folder exclusions is complicated due to the name being generated by the server. # This can be drastically simplified if you have the name when writing the test describe.one do diff --git a/templates/inspec/examples/google_logging_folder_log_sink/google_logging_folder_log_sink.erb b/templates/inspec/examples/google_logging_folder_log_sink/google_logging_folder_log_sink.erb index cccb000e3c6f..7952632ccf2b 100644 --- a/templates/inspec/examples/google_logging_folder_log_sink/google_logging_folder_log_sink.erb +++ b/templates/inspec/examples/google_logging_folder_log_sink/google_logging_folder_log_sink.erb @@ -1,5 +1,5 @@ -<% gcp_organization_id = "#{external_attribute('gcp_organization_id', doc_generation)}" -%> -<% folder_sink = grab_attributes['folder_sink'] -%> +<% gcp_organization_id = "#{external_attribute(pwd, 'gcp_organization_id', doc_generation)}" -%> +<% folder_sink = grab_attributes(pwd)['folder_sink'] -%> # Getting folder sinks is complicated due to the name being generated by the server. # This can be drastically simplified if you have the folder name when writing the test describe.one do diff --git a/templates/inspec/examples/google_logging_folder_log_sink/google_logging_folder_log_sink_attributes.erb b/templates/inspec/examples/google_logging_folder_log_sink/google_logging_folder_log_sink_attributes.erb index 8d148423dd73..d0087bce3601 100644 --- a/templates/inspec/examples/google_logging_folder_log_sink/google_logging_folder_log_sink_attributes.erb +++ b/templates/inspec/examples/google_logging_folder_log_sink/google_logging_folder_log_sink_attributes.erb @@ -1,3 +1,3 @@ -folder_sink = attribute('folder_sink', default: <%= grab_attributes['folder_sink'] -%>) -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization that is the parent of the folder') +folder_sink = attribute('folder_sink', default: <%= grab_attributes(pwd)['folder_sink'] -%>) +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization that is the parent of the folder') gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default:0, description:'Flag to enable privileged resources requiring elevated privileges in GCP.') \ No newline at end of file diff --git a/templates/inspec/examples/google_logging_folder_log_sink/google_logging_folder_log_sinks.erb b/templates/inspec/examples/google_logging_folder_log_sink/google_logging_folder_log_sinks.erb index cd016eea01a3..e6a247bf46c9 100644 --- a/templates/inspec/examples/google_logging_folder_log_sink/google_logging_folder_log_sinks.erb +++ b/templates/inspec/examples/google_logging_folder_log_sink/google_logging_folder_log_sinks.erb @@ -1,5 +1,5 @@ -<% gcp_organization_id = "#{external_attribute('gcp_organization_id', doc_generation)}" -%> -<% folder_sink = grab_attributes['folder_sink'] -%> +<% gcp_organization_id = "#{external_attribute(pwd, 'gcp_organization_id', doc_generation)}" -%> +<% folder_sink = grab_attributes(pwd)['folder_sink'] -%> # Getting folder sinks is complicated due to the name being generated by the server. # This can be drastically simplified if you have the folder name when writing the test describe.one do diff --git a/templates/inspec/examples/google_logging_organization_log_sink/google_logging_organization_log_sink.erb b/templates/inspec/examples/google_logging_organization_log_sink/google_logging_organization_log_sink.erb index 0210d6976c93..1217591d71d1 100644 --- a/templates/inspec/examples/google_logging_organization_log_sink/google_logging_organization_log_sink.erb +++ b/templates/inspec/examples/google_logging_organization_log_sink/google_logging_organization_log_sink.erb @@ -1,5 +1,5 @@ -<% gcp_organization_id = "#{external_attribute('gcp_organization_id', doc_generation)}" -%> -<% org_sink = grab_attributes['org_sink'] -%> +<% gcp_organization_id = "#{external_attribute(pwd, 'gcp_organization_id', doc_generation)}" -%> +<% org_sink = grab_attributes(pwd)['org_sink'] -%> describe google_logging_organization_log_sink(organization: <%= gcp_organization_id -%>, name: <%= doc_generation ? "'#{org_sink['name']}'" : "org_sink['name']" -%>) do it { should exist } its('filter') { should cmp <%= doc_generation ? "'#{org_sink['filter']}'" : "org_sink['filter']" -%> } diff --git a/templates/inspec/examples/google_logging_organization_log_sink/google_logging_organization_log_sink_attributes.erb b/templates/inspec/examples/google_logging_organization_log_sink/google_logging_organization_log_sink_attributes.erb index 082ea57f55a3..d90fc842b908 100644 --- a/templates/inspec/examples/google_logging_organization_log_sink/google_logging_organization_log_sink_attributes.erb +++ b/templates/inspec/examples/google_logging_organization_log_sink/google_logging_organization_log_sink_attributes.erb @@ -1,3 +1,3 @@ -org_sink = attribute('org_sink', default: <%= grab_attributes['org_sink'] -%>) -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization that is the parent of this folder') +org_sink = attribute('org_sink', default: <%= grab_attributes(pwd)['org_sink'] -%>) +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization that is the parent of this folder') gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default:0, description:'Flag to enable privileged resources requiring elevated privileges in GCP.') \ No newline at end of file diff --git a/templates/inspec/examples/google_logging_organization_log_sink/google_logging_organization_log_sinks.erb b/templates/inspec/examples/google_logging_organization_log_sink/google_logging_organization_log_sinks.erb index d3d3c21ebd1a..7bb879a01b58 100644 --- a/templates/inspec/examples/google_logging_organization_log_sink/google_logging_organization_log_sinks.erb +++ b/templates/inspec/examples/google_logging_organization_log_sink/google_logging_organization_log_sinks.erb @@ -1,5 +1,5 @@ -<% gcp_organization_id = "#{external_attribute('gcp_organization_id', doc_generation)}" -%> -<% org_sink = grab_attributes['org_sink'] -%> +<% gcp_organization_id = "#{external_attribute(pwd, 'gcp_organization_id', doc_generation)}" -%> +<% org_sink = grab_attributes(pwd)['org_sink'] -%> describe google_logging_organization_log_sinks(organization: <%= gcp_organization_id -%>) do its('names') { should include <%= doc_generation ? "'#{org_sink['name']}'" : "org_sink['name']" -%> } end \ No newline at end of file diff --git a/templates/inspec/examples/google_logging_project_exclusion/google_logging_project_exclusion.erb b/templates/inspec/examples/google_logging_project_exclusion/google_logging_project_exclusion.erb index 6db10667dce5..6b8e23505f55 100644 --- a/templates/inspec/examples/google_logging_project_exclusion/google_logging_project_exclusion.erb +++ b/templates/inspec/examples/google_logging_project_exclusion/google_logging_project_exclusion.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% project_exclusion = grab_attributes['project_exclusion'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% project_exclusion = grab_attributes(pwd)['project_exclusion'] -%> describe google_logging_project_exclusion(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{project_exclusion['name']}'" : "project_exclusion['name']" -%>) do it { should exist } diff --git a/templates/inspec/examples/google_logging_project_exclusion/google_logging_project_exclusion_attributes.erb b/templates/inspec/examples/google_logging_project_exclusion/google_logging_project_exclusion_attributes.erb index 02c2fc6b43bb..4e5e29cb1c98 100644 --- a/templates/inspec/examples/google_logging_project_exclusion/google_logging_project_exclusion_attributes.erb +++ b/templates/inspec/examples/google_logging_project_exclusion/google_logging_project_exclusion_attributes.erb @@ -1,4 +1,4 @@ -project_exclusion = attribute('project_exclusion', default: <%= grab_attributes['project_exclusion'] -%>) -gcp_project_id = attribute(:gcp_project_id, default: <%= external_attribute('gcp_project_id') -%>, description: 'The project identifier') +project_exclusion = attribute('project_exclusion', default: <%= grab_attributes(pwd)['project_exclusion'] -%>) +gcp_project_id = attribute(:gcp_project_id, default: <%= external_attribute(pwd, 'gcp_project_id') -%>, description: 'The project identifier') gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default:0, description:'Flag to enable privileged resources requiring elevated privileges in GCP.') -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file diff --git a/templates/inspec/examples/google_logging_project_exclusion/google_logging_project_exclusions.erb b/templates/inspec/examples/google_logging_project_exclusion/google_logging_project_exclusions.erb index fe5a979a6c82..489a8c3e1e83 100644 --- a/templates/inspec/examples/google_logging_project_exclusion/google_logging_project_exclusions.erb +++ b/templates/inspec/examples/google_logging_project_exclusion/google_logging_project_exclusions.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% project_exclusion = grab_attributes['folder_exclusion'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% project_exclusion = grab_attributes(pwd)['folder_exclusion'] -%> describe google_logging_project_exclusions(project: <%= gcp_project_id -%>) do its('names'){ should include <%= doc_generation ? "'#{project_exclusion['name']}'" : "project_exclusion['name']" -%> } diff --git a/templates/inspec/examples/google_logging_project_sink/google_logging_project_sink.erb b/templates/inspec/examples/google_logging_project_sink/google_logging_project_sink.erb index 779931415c16..2d1cf7ad91fb 100644 --- a/templates/inspec/examples/google_logging_project_sink/google_logging_project_sink.erb +++ b/templates/inspec/examples/google_logging_project_sink/google_logging_project_sink.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% project_sink = grab_attributes['project_sink'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% project_sink = grab_attributes(pwd)['project_sink'] -%> describe google_logging_project_sink(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{project_sink['name']}'" : "project_sink['name']" -%>) do it { should exist } its('filter') { should cmp <%= doc_generation ? "'#{project_sink['filter']}'" : "project_sink['filter']" -%> } diff --git a/templates/inspec/examples/google_logging_project_sink/google_logging_project_sink_attributes.erb b/templates/inspec/examples/google_logging_project_sink/google_logging_project_sink_attributes.erb index 82457f0d454c..2361137989bf 100644 --- a/templates/inspec/examples/google_logging_project_sink/google_logging_project_sink_attributes.erb +++ b/templates/inspec/examples/google_logging_project_sink/google_logging_project_sink_attributes.erb @@ -1,4 +1,4 @@ -project_sink = attribute('project_sink', default: <%= grab_attributes['project_sink'] -%>) -gcp_project_id = attribute(:gcp_project_id, default: <%= external_attribute('gcp_project_id') -%>, description: 'The project id.') +project_sink = attribute('project_sink', default: <%= grab_attributes(pwd)['project_sink'] -%>) +gcp_project_id = attribute(:gcp_project_id, default: <%= external_attribute(pwd, 'gcp_project_id') -%>, description: 'The project id.') gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default:0, description:'Flag to enable privileged resources requiring elevated privileges in GCP.') -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file diff --git a/templates/inspec/examples/google_logging_project_sink/google_logging_project_sinks.erb b/templates/inspec/examples/google_logging_project_sink/google_logging_project_sinks.erb index e20bcb6d95b7..0aff061cd876 100644 --- a/templates/inspec/examples/google_logging_project_sink/google_logging_project_sinks.erb +++ b/templates/inspec/examples/google_logging_project_sink/google_logging_project_sinks.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% project_sink = grab_attributes['project_sink'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% project_sink = grab_attributes(pwd)['project_sink'] -%> describe google_logging_project_sinks(project: <%= gcp_project_id -%>) do its('names') { should include <%= doc_generation ? "'#{project_sink['name']}'" : "project_sink['name']" -%> } end \ No newline at end of file diff --git a/templates/inspec/examples/google_ml_engine_model/google_ml_engine_model.erb b/templates/inspec/examples/google_ml_engine_model/google_ml_engine_model.erb index bc42beafdc4e..c4f25f3477c9 100644 --- a/templates/inspec/examples/google_ml_engine_model/google_ml_engine_model.erb +++ b/templates/inspec/examples/google_ml_engine_model/google_ml_engine_model.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% ml_model = grab_attributes['ml_model'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% ml_model = grab_attributes(pwd)['ml_model'] -%> describe google_ml_engine_model(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{ml_model['name']}'" : "ml_model['name']" -%>) do it { should exist } its('description') { should cmp <%= doc_generation ? "'#{ml_model['description']}'" : "ml_model['description']" -%> } diff --git a/templates/inspec/examples/google_ml_engine_model/google_ml_engine_model_attributes.erb b/templates/inspec/examples/google_ml_engine_model/google_ml_engine_model_attributes.erb index bfbbdabf66e9..1020108510eb 100644 --- a/templates/inspec/examples/google_ml_engine_model/google_ml_engine_model_attributes.erb +++ b/templates/inspec/examples/google_ml_engine_model/google_ml_engine_model_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'The GCP project region.') -ml_model = attribute('ml_model', default: <%= JSON.pretty_generate(grab_attributes['ml_model']) -%>, description: 'Machine learning model definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_location = attribute(:gcp_location, default: '<%= external_attribute(pwd, 'gcp_location') -%>', description: 'The GCP project region.') +ml_model = attribute('ml_model', default: <%= JSON.pretty_generate(grab_attributes(pwd)['ml_model']) -%>, description: 'Machine learning model definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_ml_engine_model/google_ml_engine_models.erb b/templates/inspec/examples/google_ml_engine_model/google_ml_engine_models.erb index c1ff8750517c..41c01626400a 100644 --- a/templates/inspec/examples/google_ml_engine_model/google_ml_engine_models.erb +++ b/templates/inspec/examples/google_ml_engine_model/google_ml_engine_models.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% ml_model = grab_attributes['ml_model'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% ml_model = grab_attributes(pwd)['ml_model'] -%> describe google_ml_engine_models(project: <%= gcp_project_id -%>) do its('descriptions') { should include <%= doc_generation ? "'#{ml_model['description']}'" : "ml_model['description']" -%> } its('online_prediction_loggings') { should include <%= doc_generation ? "'#{ml_model['online_prediction_logging']}'" : "ml_model['online_prediction_logging']" -%> } diff --git a/templates/inspec/examples/google_organization/google_organization.erb b/templates/inspec/examples/google_organization/google_organization.erb index e47486ca67c8..8bf19875f501 100644 --- a/templates/inspec/examples/google_organization/google_organization.erb +++ b/templates/inspec/examples/google_organization/google_organization.erb @@ -1,4 +1,4 @@ -<% gcp_organization_id = "#{external_attribute('gcp_organization_id', doc_generation)}" -%> +<% gcp_organization_id = "#{external_attribute(pwd, 'gcp_organization_id', doc_generation)}" -%> describe google_organization(name: "organizations/<%= doc_generation ? '123456' : "\#{gcp_organization_id}" -%>") do its('name') { should eq "organizations/<%= doc_generation ? '123456' : "\#{gcp_organization_id}" -%>" } diff --git a/templates/inspec/examples/google_organization/google_organization_attributes.erb b/templates/inspec/examples/google_organization/google_organization_attributes.erb index 1d55f221dbde..8eca5f43aaf7 100644 --- a/templates/inspec/examples/google_organization/google_organization_attributes.erb +++ b/templates/inspec/examples/google_organization/google_organization_attributes.erb @@ -1,2 +1,2 @@ -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization that is the parent of this folder') +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization that is the parent of this folder') gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default:0, description:'Flag to enable privileged resources requiring elevated privileges in GCP.') \ No newline at end of file diff --git a/templates/inspec/examples/google_organization/google_organizations.erb b/templates/inspec/examples/google_organization/google_organizations.erb index ac1a89f2a7ec..9468ac1695a2 100644 --- a/templates/inspec/examples/google_organization/google_organizations.erb +++ b/templates/inspec/examples/google_organization/google_organizations.erb @@ -1,5 +1,5 @@ -<% gcp_organization_id = "#{external_attribute('gcp_organization_id', doc_generation)}" -%> -<% gcp_organization_display_name = "#{external_attribute('gcp_organization_display_name', doc_generation)}" -%> +<% gcp_organization_id = "#{external_attribute(pwd, 'gcp_organization_id', doc_generation)}" -%> +<% gcp_organization_display_name = "#{external_attribute(pwd, 'gcp_organization_display_name', doc_generation)}" -%> describe google_organizations do its('names') { should include "organizations/<%= doc_generation ? '123456' : "\#{gcp_organization_id}" -%>" } diff --git a/templates/inspec/examples/google_project/google_project.erb b/templates/inspec/examples/google_project/google_project.erb index 36aa988624e4..1066abd2a61f 100644 --- a/templates/inspec/examples/google_project/google_project.erb +++ b/templates/inspec/examples/google_project/google_project.erb @@ -1,4 +1,4 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> describe google_project(project: <%= gcp_project_id -%>) do it { should exist } its('project_id') { should cmp <%= gcp_project_id -%> } diff --git a/templates/inspec/examples/google_project/google_project_attributes.erb b/templates/inspec/examples/google_project/google_project_attributes.erb index a2863dfa3703..9e434667ef77 100644 --- a/templates/inspec/examples/google_project/google_project_attributes.erb +++ b/templates/inspec/examples/google_project/google_project_attributes.erb @@ -1 +1 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') \ No newline at end of file diff --git a/templates/inspec/examples/google_project/google_projects.erb b/templates/inspec/examples/google_project/google_projects.erb index 15a4a36bf583..e28d01579b35 100644 --- a/templates/inspec/examples/google_project/google_projects.erb +++ b/templates/inspec/examples/google_project/google_projects.erb @@ -1,4 +1,4 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> describe google_projects() do its('count') { should be >= 1 } its('project_ids') { should include <%= gcp_project_id -%> } diff --git a/templates/inspec/examples/google_project_alert_policy/google_project_alert_policies.erb b/templates/inspec/examples/google_project_alert_policy/google_project_alert_policies.erb index eeca2f996aa2..341771ebd46c 100644 --- a/templates/inspec/examples/google_project_alert_policy/google_project_alert_policies.erb +++ b/templates/inspec/examples/google_project_alert_policy/google_project_alert_policies.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% alert_policy = grab_attributes['alert_policy'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% alert_policy = grab_attributes(pwd)['alert_policy'] -%> describe google_project_alert_policies(project: <%= gcp_project_id -%>) do it { should exist } its('policy_display_names') { should include <%= doc_generation ? "'#{alert_policy['display_name']}'" : "alert_policy['display_name']" -%>} diff --git a/templates/inspec/examples/google_project_alert_policy/google_project_alert_policy.erb b/templates/inspec/examples/google_project_alert_policy/google_project_alert_policy.erb index 19ce1f0be671..c8e898daefc7 100644 --- a/templates/inspec/examples/google_project_alert_policy/google_project_alert_policy.erb +++ b/templates/inspec/examples/google_project_alert_policy/google_project_alert_policy.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% alert_policy = grab_attributes['alert_policy'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% alert_policy = grab_attributes(pwd)['alert_policy'] -%> describe.one do google_project_alert_policies(project: <%= gcp_project_id -%>).policy_names do |policy_name| describe google_project_alert_policy(project: <%= gcp_project_id -%>, name: policy_name) do diff --git a/templates/inspec/examples/google_project_alert_policy/google_project_alert_policy_attributes.erb b/templates/inspec/examples/google_project_alert_policy/google_project_alert_policy_attributes.erb index 4df0922e7a5b..d68387f2452b 100644 --- a/templates/inspec/examples/google_project_alert_policy/google_project_alert_policy_attributes.erb +++ b/templates/inspec/examples/google_project_alert_policy/google_project_alert_policy_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -alert_policy = attribute('alert_policy', default: <%= JSON.pretty_generate(grab_attributes['alert_policy']) -%>, description: 'Alert Policy description') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +alert_policy = attribute('alert_policy', default: <%= JSON.pretty_generate(grab_attributes(pwd)['alert_policy']) -%>, description: 'Alert Policy description') \ No newline at end of file diff --git a/templates/inspec/examples/google_project_iam_custom_role/google_project_iam_custom_role.erb b/templates/inspec/examples/google_project_iam_custom_role/google_project_iam_custom_role.erb index f5129ebaa952..8f523d0733b5 100644 --- a/templates/inspec/examples/google_project_iam_custom_role/google_project_iam_custom_role.erb +++ b/templates/inspec/examples/google_project_iam_custom_role/google_project_iam_custom_role.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_project_iam_custom_role_id = "#{external_attribute('gcp_project_iam_custom_role_id', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_project_iam_custom_role_id = "#{external_attribute(pwd, 'gcp_project_iam_custom_role_id', doc_generation)}" -%> describe google_project_iam_custom_role(project: <%= gcp_project_id -%>, name: <%= gcp_project_iam_custom_role_id -%>) do it { should exist } its('stage') { should eq 'GA' } diff --git a/templates/inspec/examples/google_project_iam_custom_role/google_project_iam_custom_role_attributes.erb b/templates/inspec/examples/google_project_iam_custom_role/google_project_iam_custom_role_attributes.erb index 3238df07fe9c..a27a02e66a28 100644 --- a/templates/inspec/examples/google_project_iam_custom_role/google_project_iam_custom_role_attributes.erb +++ b/templates/inspec/examples/google_project_iam_custom_role/google_project_iam_custom_role_attributes.erb @@ -1,4 +1,4 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_project_iam_custom_role_id = attribute(:gcp_project_iam_custom_role_id, default: '<%= external_attribute('gcp_project_iam_custom_role_id') -%>', description: 'The IAM custom role identifier.') +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_project_iam_custom_role_id = attribute(:gcp_project_iam_custom_role_id, default: '<%= external_attribute(pwd, 'gcp_project_iam_custom_role_id') -%>', description: 'The IAM custom role identifier.') gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default:0, description:'Flag to enable privileged resources requiring elevated privileges in GCP.') -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file diff --git a/templates/inspec/examples/google_project_iam_custom_role/google_project_iam_custom_roles.erb b/templates/inspec/examples/google_project_iam_custom_role/google_project_iam_custom_roles.erb index db14e31ea613..26f1fee6203f 100644 --- a/templates/inspec/examples/google_project_iam_custom_role/google_project_iam_custom_roles.erb +++ b/templates/inspec/examples/google_project_iam_custom_role/google_project_iam_custom_roles.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_project_iam_custom_role_id = "#{external_attribute('gcp_project_iam_custom_role_id', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_project_iam_custom_role_id = "#{external_attribute(pwd, 'gcp_project_iam_custom_role_id', doc_generation)}" -%> describe google_project_iam_custom_roles(project: <%= gcp_project_id -%>) do its('names') { should include "projects/<%= doc_generation ? "project-id" : "\#{gcp_project_id}" -%>/roles/<%= doc_generation ? "role-id" : "\#{gcp_project_iam_custom_role_id}" -%>" } end \ No newline at end of file diff --git a/templates/inspec/examples/google_project_metric/google_project_metric.erb b/templates/inspec/examples/google_project_metric/google_project_metric.erb index 24569fcfbc0e..a3bc78606f56 100644 --- a/templates/inspec/examples/google_project_metric/google_project_metric.erb +++ b/templates/inspec/examples/google_project_metric/google_project_metric.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% logging_metric = grab_attributes['logging_metric'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% logging_metric = grab_attributes(pwd)['logging_metric'] -%> describe google_project_metric(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{logging_metric['name']}'" : "logging_metric['name']" -%>) do it { should exist } its('filter') { should cmp <%= doc_generation ? "'#{logging_metric['filter']}'" : "logging_metric['filter']" -%> } diff --git a/templates/inspec/examples/google_project_metric/google_project_metric_attributes.erb b/templates/inspec/examples/google_project_metric/google_project_metric_attributes.erb index 22313211290d..74e822ad83a1 100644 --- a/templates/inspec/examples/google_project_metric/google_project_metric_attributes.erb +++ b/templates/inspec/examples/google_project_metric/google_project_metric_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -logging_metric = attribute('logging_metric', default: <%= JSON.pretty_generate(grab_attributes['logging_metric']) -%>, description: 'Logging metric definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +logging_metric = attribute('logging_metric', default: <%= JSON.pretty_generate(grab_attributes(pwd)['logging_metric']) -%>, description: 'Logging metric definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_project_metric/google_project_metrics.erb b/templates/inspec/examples/google_project_metric/google_project_metrics.erb index e00776c14c05..6f53f5ae9840 100644 --- a/templates/inspec/examples/google_project_metric/google_project_metrics.erb +++ b/templates/inspec/examples/google_project_metric/google_project_metrics.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% logging_metric = grab_attributes['logging_metric'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% logging_metric = grab_attributes(pwd)['logging_metric'] -%> describe google_project_metrics(project: <%= gcp_project_id -%>) do it { should exist } its('metric_filters') { should include <%= doc_generation ? "'#{logging_metric['filter']}'" : "logging_metric['filter']" -%> } diff --git a/templates/inspec/examples/google_project_service/google_project_service.erb b/templates/inspec/examples/google_project_service/google_project_service.erb index 7e5e67045fc1..f2a20336d408 100644 --- a/templates/inspec/examples/google_project_service/google_project_service.erb +++ b/templates/inspec/examples/google_project_service/google_project_service.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% service = grab_attributes['service'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% service = grab_attributes(pwd)['service'] -%> describe google_project_service(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{service['name']}'" : "service['name']" -%>) do it { should exist } its('state') { should cmp "ENABLED" } diff --git a/templates/inspec/examples/google_project_service/google_project_service_attributes.erb b/templates/inspec/examples/google_project_service/google_project_service_attributes.erb index f7b5ec33a865..a0fc0c587797 100644 --- a/templates/inspec/examples/google_project_service/google_project_service_attributes.erb +++ b/templates/inspec/examples/google_project_service/google_project_service_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -service = attribute('service', default: <%= JSON.pretty_generate(grab_attributes['service']) -%>, description: 'Service description') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +service = attribute('service', default: <%= JSON.pretty_generate(grab_attributes(pwd)['service']) -%>, description: 'Service description') \ No newline at end of file diff --git a/templates/inspec/examples/google_project_service/google_project_services.erb b/templates/inspec/examples/google_project_service/google_project_services.erb index 4494e84fc468..5eef0819ae9f 100644 --- a/templates/inspec/examples/google_project_service/google_project_services.erb +++ b/templates/inspec/examples/google_project_service/google_project_services.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% service = grab_attributes['service'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% service = grab_attributes(pwd)['service'] -%> describe.one do google_project_services(project: <%= gcp_project_id -%>).names.each do |name| describe name do diff --git a/templates/inspec/examples/google_pubsub_subscription/google_pubsub_subscription.erb b/templates/inspec/examples/google_pubsub_subscription/google_pubsub_subscription.erb index 8748a88cea45..e6f79dc05774 100644 --- a/templates/inspec/examples/google_pubsub_subscription/google_pubsub_subscription.erb +++ b/templates/inspec/examples/google_pubsub_subscription/google_pubsub_subscription.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% subscription = grab_attributes['subscription'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% subscription = grab_attributes(pwd)['subscription'] -%> describe google_pubsub_subscription(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{subscription['name']}'" : "subscription['name']" -%>) do it { should exist } end diff --git a/templates/inspec/examples/google_pubsub_subscription/google_pubsub_subscription_attributes.erb b/templates/inspec/examples/google_pubsub_subscription/google_pubsub_subscription_attributes.erb index a4fc9b29b37d..336577f3407c 100644 --- a/templates/inspec/examples/google_pubsub_subscription/google_pubsub_subscription_attributes.erb +++ b/templates/inspec/examples/google_pubsub_subscription/google_pubsub_subscription_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -subscription = attribute('subscription', default: <%= grab_attributes['subscription'] -%>) +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +subscription = attribute('subscription', default: <%= grab_attributes(pwd)['subscription'] -%>) diff --git a/templates/inspec/examples/google_pubsub_subscription/google_pubsub_subscriptions.erb b/templates/inspec/examples/google_pubsub_subscription/google_pubsub_subscriptions.erb index 3c062ba63735..a934744ac1e3 100644 --- a/templates/inspec/examples/google_pubsub_subscription/google_pubsub_subscriptions.erb +++ b/templates/inspec/examples/google_pubsub_subscription/google_pubsub_subscriptions.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% subscription = grab_attributes['subscription'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% subscription = grab_attributes(pwd)['subscription'] -%> describe google_pubsub_subscriptions(project: <%= gcp_project_id -%>) do its('count') { should be >= 1 } end diff --git a/templates/inspec/examples/google_pubsub_topic/google_pubsub_topic.erb b/templates/inspec/examples/google_pubsub_topic/google_pubsub_topic.erb index c3c761e71c81..b773b8ee83cf 100644 --- a/templates/inspec/examples/google_pubsub_topic/google_pubsub_topic.erb +++ b/templates/inspec/examples/google_pubsub_topic/google_pubsub_topic.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% topic = grab_attributes['topic'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% topic = grab_attributes(pwd)['topic'] -%> describe google_pubsub_topic(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{topic['name']}'" : "topic['name']" -%>) do it { should exist } end diff --git a/templates/inspec/examples/google_pubsub_topic/google_pubsub_topic_attributes.erb b/templates/inspec/examples/google_pubsub_topic/google_pubsub_topic_attributes.erb index f0628e0d3d22..961a6d248b72 100644 --- a/templates/inspec/examples/google_pubsub_topic/google_pubsub_topic_attributes.erb +++ b/templates/inspec/examples/google_pubsub_topic/google_pubsub_topic_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -topic = attribute('topic', default: <%= grab_attributes['topic'] -%>) +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +topic = attribute('topic', default: <%= grab_attributes(pwd)['topic'] -%>) diff --git a/templates/inspec/examples/google_pubsub_topic/google_pubsub_topics.erb b/templates/inspec/examples/google_pubsub_topic/google_pubsub_topics.erb index 0e722b93a536..ffa3b8d07497 100644 --- a/templates/inspec/examples/google_pubsub_topic/google_pubsub_topics.erb +++ b/templates/inspec/examples/google_pubsub_topic/google_pubsub_topics.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% topic = grab_attributes['topic'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% topic = grab_attributes(pwd)['topic'] -%> describe google_pubsub_topics(project: <%= gcp_project_id -%>) do it { should exist } its('names') { should include <%= doc_generation ? "'#{topic['name']}'" : "topic['name']" -%> } diff --git a/templates/inspec/examples/google_redis_instance/google_redis_instance.erb b/templates/inspec/examples/google_redis_instance/google_redis_instance.erb index 352b8fbbe600..3684e715611b 100644 --- a/templates/inspec/examples/google_redis_instance/google_redis_instance.erb +++ b/templates/inspec/examples/google_redis_instance/google_redis_instance.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% redis = grab_attributes['redis'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% redis = grab_attributes(pwd)['redis'] -%> describe google_redis_instance(project: <%= gcp_project_id -%>, region: <%= doc_generation ? "'#{redis['region']}'" : "redis['region']" -%>, name: <%= doc_generation ? "'#{redis['name']}'" : "redis['name']" -%>) do it { should exist } its('tier') { should cmp <%= doc_generation ? "'#{redis['tier']}'" : "redis['tier']" -%> } diff --git a/templates/inspec/examples/google_redis_instance/google_redis_instance_attributes.erb b/templates/inspec/examples/google_redis_instance/google_redis_instance_attributes.erb index 006e5a5d0593..47e7bd056295 100644 --- a/templates/inspec/examples/google_redis_instance/google_redis_instance_attributes.erb +++ b/templates/inspec/examples/google_redis_instance/google_redis_instance_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -redis = attribute('redis', default: <%= grab_attributes['redis'] -%>) +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +redis = attribute('redis', default: <%= grab_attributes(pwd)['redis'] -%>) diff --git a/templates/inspec/examples/google_redis_instance/google_redis_instances.erb b/templates/inspec/examples/google_redis_instance/google_redis_instances.erb index 549e71f7b8f9..21e6d5cd9186 100644 --- a/templates/inspec/examples/google_redis_instance/google_redis_instances.erb +++ b/templates/inspec/examples/google_redis_instance/google_redis_instances.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% redis = grab_attributes['redis'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% redis = grab_attributes(pwd)['redis'] -%> describe google_redis_instances(project: <%= gcp_project_id -%>, region: <%= doc_generation ? "'#{redis['region']}'" : "redis['region']" -%>) do its('tiers') { should include <%= doc_generation ? "'#{redis['tier']}'" : "redis['tier']" -%> } its('memory_size_gbs') { should include <%= doc_generation ? "'#{redis['memory_size_gb']}'" : "redis['memory_size_gb']" -%> } diff --git a/templates/inspec/examples/google_resourcemanager_folder/google_resourcemanager_folder.erb b/templates/inspec/examples/google_resourcemanager_folder/google_resourcemanager_folder.erb index 53e80492d88c..b24306bc65e5 100644 --- a/templates/inspec/examples/google_resourcemanager_folder/google_resourcemanager_folder.erb +++ b/templates/inspec/examples/google_resourcemanager_folder/google_resourcemanager_folder.erb @@ -1,4 +1,4 @@ -<% folder = grab_attributes['folder'] -%> +<% folder = grab_attributes(pwd)['folder'] -%> describe.one do google_resourcemanager_folders(parent: <%= doc_generation ? "'organizations/12345'" : "\"organizations/\#{gcp_organization_id}\"" -%>).names.each do |name| describe google_resourcemanager_folder(name: name) do diff --git a/templates/inspec/examples/google_resourcemanager_folder/google_resourcemanager_folder_attributes.erb b/templates/inspec/examples/google_resourcemanager_folder/google_resourcemanager_folder_attributes.erb index 2676d1ca4f6b..bb0eff2865fd 100644 --- a/templates/inspec/examples/google_resourcemanager_folder/google_resourcemanager_folder_attributes.erb +++ b/templates/inspec/examples/google_resourcemanager_folder/google_resourcemanager_folder_attributes.erb @@ -1,3 +1,3 @@ -folder = attribute('folder', default: <%= grab_attributes['folder'] -%>) -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization that is the parent of this folder') +folder = attribute('folder', default: <%= grab_attributes(pwd)['folder'] -%>) +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization that is the parent of this folder') gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default:0, description:'Flag to enable privileged resources requiring elevated privileges in GCP.') \ No newline at end of file diff --git a/templates/inspec/examples/google_resourcemanager_folder/google_resourcemanager_folders.erb b/templates/inspec/examples/google_resourcemanager_folder/google_resourcemanager_folders.erb index 7b7b4c9c8c4c..d0ce2596ddba 100644 --- a/templates/inspec/examples/google_resourcemanager_folder/google_resourcemanager_folders.erb +++ b/templates/inspec/examples/google_resourcemanager_folder/google_resourcemanager_folders.erb @@ -1,4 +1,4 @@ -<% folder = grab_attributes['folder'] -%> +<% folder = grab_attributes(pwd)['folder'] -%> describe.one do google_resourcemanager_folders(parent: <%= doc_generation ? "'organizations/12345'" : "\"organizations/\#{gcp_organization_id}\"" -%>).display_names.each do |display_name| describe display_name do diff --git a/templates/inspec/examples/google_runtime_config_config/google_runtime_config_config.erb b/templates/inspec/examples/google_runtime_config_config/google_runtime_config_config.erb index 1a51cf193be4..9be54812764d 100644 --- a/templates/inspec/examples/google_runtime_config_config/google_runtime_config_config.erb +++ b/templates/inspec/examples/google_runtime_config_config/google_runtime_config_config.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% runtimeconfig_config = grab_attributes['runtimeconfig_config'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% runtimeconfig_config = grab_attributes(pwd)['runtimeconfig_config'] -%> describe google_runtime_config_config(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{runtimeconfig_config['name']}'" : "runtimeconfig_config['name']" -%>) do it { should exist } its('description') { should cmp <%= doc_generation ? "'#{runtimeconfig_config['description']}'" : "runtimeconfig_config['description']" -%> } diff --git a/templates/inspec/examples/google_runtime_config_config/google_runtime_config_config_attributes.erb b/templates/inspec/examples/google_runtime_config_config/google_runtime_config_config_attributes.erb index 5e80fedc0e38..dd6c245f54b7 100644 --- a/templates/inspec/examples/google_runtime_config_config/google_runtime_config_config_attributes.erb +++ b/templates/inspec/examples/google_runtime_config_config/google_runtime_config_config_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -runtimeconfig_config = attribute('runtimeconfig_config', default: <%= grab_attributes['runtimeconfig_config'] -%>) +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +runtimeconfig_config = attribute('runtimeconfig_config', default: <%= grab_attributes(pwd)['runtimeconfig_config'] -%>) diff --git a/templates/inspec/examples/google_runtime_config_config/google_runtime_config_configs.erb b/templates/inspec/examples/google_runtime_config_config/google_runtime_config_configs.erb index 478c554a2b8f..7879479232d1 100644 --- a/templates/inspec/examples/google_runtime_config_config/google_runtime_config_configs.erb +++ b/templates/inspec/examples/google_runtime_config_config/google_runtime_config_configs.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% runtimeconfig_config = grab_attributes['runtimeconfig_config'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% runtimeconfig_config = grab_attributes(pwd)['runtimeconfig_config'] -%> describe google_runtime_config_configs(project: <%= gcp_project_id -%>) do its('descriptions') { should include <%= doc_generation ? "'#{runtimeconfig_config['description']}'" : "runtimeconfig_config['description']" -%> } end \ No newline at end of file diff --git a/templates/inspec/examples/google_runtime_config_variable/google_runtime_config_variable.erb b/templates/inspec/examples/google_runtime_config_variable/google_runtime_config_variable.erb index cdc396302d0a..d530f48413b3 100644 --- a/templates/inspec/examples/google_runtime_config_variable/google_runtime_config_variable.erb +++ b/templates/inspec/examples/google_runtime_config_variable/google_runtime_config_variable.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% runtimeconfig_config = grab_attributes['runtimeconfig_config'] -%> -<% runtimeconfig_variable = grab_attributes['runtimeconfig_variable'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% runtimeconfig_config = grab_attributes(pwd)['runtimeconfig_config'] -%> +<% runtimeconfig_variable = grab_attributes(pwd)['runtimeconfig_variable'] -%> describe google_runtime_config_variable(project: <%= gcp_project_id -%>, config: <%= doc_generation ? "'#{runtimeconfig_config['name']}'" : "runtimeconfig_config['name']" -%>, name: <%= doc_generation ? "'#{runtimeconfig_variable['name']}'" : "runtimeconfig_variable['name']" -%>) do it { should exist } its('text') { should cmp <%= doc_generation ? "'#{runtimeconfig_variable['text']}'" : "runtimeconfig_variable['text']" -%> } diff --git a/templates/inspec/examples/google_runtime_config_variable/google_runtime_config_variable_attributes.erb b/templates/inspec/examples/google_runtime_config_variable/google_runtime_config_variable_attributes.erb index eb4cf653d070..8fe1e21ecc0e 100644 --- a/templates/inspec/examples/google_runtime_config_variable/google_runtime_config_variable_attributes.erb +++ b/templates/inspec/examples/google_runtime_config_variable/google_runtime_config_variable_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -runtimeconfig_config = attribute('runtimeconfig_config', default: <%= grab_attributes['runtimeconfig_config'] -%>) -runtimeconfig_variable = attribute('runtimeconfig_variable', default: <%= grab_attributes['runtimeconfig_variable'] -%>) +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +runtimeconfig_config = attribute('runtimeconfig_config', default: <%= grab_attributes(pwd)['runtimeconfig_config'] -%>) +runtimeconfig_variable = attribute('runtimeconfig_variable', default: <%= grab_attributes(pwd)['runtimeconfig_variable'] -%>) diff --git a/templates/inspec/examples/google_runtime_config_variable/google_runtime_config_variables.erb b/templates/inspec/examples/google_runtime_config_variable/google_runtime_config_variables.erb index a34007a185f2..611d15a77f2d 100644 --- a/templates/inspec/examples/google_runtime_config_variable/google_runtime_config_variables.erb +++ b/templates/inspec/examples/google_runtime_config_variable/google_runtime_config_variables.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% runtimeconfig_config = grab_attributes['runtimeconfig_config'] -%> -<% runtimeconfig_variable = grab_attributes['runtimeconfig_variable'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% runtimeconfig_config = grab_attributes(pwd)['runtimeconfig_config'] -%> +<% runtimeconfig_variable = grab_attributes(pwd)['runtimeconfig_variable'] -%> describe google_runtime_config_variables(project: <%= gcp_project_id -%>, config: <%= doc_generation ? "'#{runtimeconfig_config['name']}'" : "runtimeconfig_config['name']" -%>) do its('texts') { should include <%= doc_generation ? "'#{runtimeconfig_variable['text']}'" : "runtimeconfig_variable['text']" -%> } end \ No newline at end of file diff --git a/templates/inspec/examples/google_service_account/google_service_account.erb b/templates/inspec/examples/google_service_account/google_service_account.erb index 724fa9bdf614..6027fde92248 100644 --- a/templates/inspec/examples/google_service_account/google_service_account.erb +++ b/templates/inspec/examples/google_service_account/google_service_account.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_service_account_display_name = "#{external_attribute('gcp_service_account_display_name', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_service_account_display_name = "#{external_attribute(pwd, 'gcp_service_account_display_name', doc_generation)}" -%> describe google_service_account(project: <%= gcp_project_id -%>, name: "<%= doc_generation ? "display-name" : "\#{gcp_service_account_display_name}" -%>@<%= doc_generation ? "project-id" : "\#{gcp_project_id}" -%>.iam.gserviceaccount.com") do it { should exist } its('display_name') { should cmp <%= gcp_service_account_display_name -%> } diff --git a/templates/inspec/examples/google_service_account/google_service_account_attributes.erb b/templates/inspec/examples/google_service_account/google_service_account_attributes.erb index ea7e09771830..0ec35cfa0e64 100644 --- a/templates/inspec/examples/google_service_account/google_service_account_attributes.erb +++ b/templates/inspec/examples/google_service_account/google_service_account_attributes.erb @@ -1,4 +1,4 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_service_account_display_name = attribute(:gcp_service_account_display_name, default: '<%= external_attribute('gcp_service_account_display_name') -%>', description: 'The IAM service account display name.') +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_service_account_display_name = attribute(:gcp_service_account_display_name, default: '<%= external_attribute(pwd, 'gcp_service_account_display_name') -%>', description: 'The IAM service account display name.') gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default:0, description:'Flag to enable privileged resources requiring elevated privileges in GCP.') -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file diff --git a/templates/inspec/examples/google_service_account/google_service_accounts.erb b/templates/inspec/examples/google_service_account/google_service_accounts.erb index a882be63d2ed..72ff1a464f85 100644 --- a/templates/inspec/examples/google_service_account/google_service_accounts.erb +++ b/templates/inspec/examples/google_service_account/google_service_accounts.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_service_account_display_name = "#{external_attribute('gcp_service_account_display_name', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_service_account_display_name = "#{external_attribute(pwd, 'gcp_service_account_display_name', doc_generation)}" -%> describe google_service_accounts(project: <%= gcp_project_id -%>, name: "<%= doc_generation ? "display-name" : "\#{gcp_service_account_display_name}" -%>@<%= doc_generation ? "project-id" : "\#{gcp_project_id}" -%>.iam.gserviceaccount.com") do its('service_account_emails') { should include "<%= doc_generation ? "display-name" : "\#{gcp_service_account_display_name}" -%>@<%= doc_generation ? "project-id" : "\#{gcp_project_id}" -%>.iam.gserviceaccount.com" } its('count') { should be <= 1000 } diff --git a/templates/inspec/examples/google_service_account_key/google_service_account_key.erb b/templates/inspec/examples/google_service_account_key/google_service_account_key.erb index 7452ea9def4e..fc5b5c137f93 100644 --- a/templates/inspec/examples/google_service_account_key/google_service_account_key.erb +++ b/templates/inspec/examples/google_service_account_key/google_service_account_key.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_service_account_display_name = "#{external_attribute('gcp_service_account_display_name', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_service_account_display_name = "#{external_attribute(pwd, 'gcp_service_account_display_name', doc_generation)}" -%> google_service_account_keys(project: <%= gcp_project_id -%>, service_account: "<%= doc_generation ? "display-name" : "\#{gcp_service_account_display_name}" -%>@<%= doc_generation ? "project-id" : "\#{gcp_project_id}" -%>.iam.gserviceaccount.com").key_names.each do |sa_key_name| describe google_service_account_key(project: <%= gcp_project_id -%>, service_account: "<%= doc_generation ? "display-name" : "\#{gcp_service_account_display_name}" -%>@<%= doc_generation ? "project-id" : "\#{gcp_project_id}" -%>.iam.gserviceaccount.com", name: sa_key_name.split('/').last) do it { should exist } diff --git a/templates/inspec/examples/google_service_account_key/google_service_account_key_attributes.erb b/templates/inspec/examples/google_service_account_key/google_service_account_key_attributes.erb index ea7e09771830..0ec35cfa0e64 100644 --- a/templates/inspec/examples/google_service_account_key/google_service_account_key_attributes.erb +++ b/templates/inspec/examples/google_service_account_key/google_service_account_key_attributes.erb @@ -1,4 +1,4 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_service_account_display_name = attribute(:gcp_service_account_display_name, default: '<%= external_attribute('gcp_service_account_display_name') -%>', description: 'The IAM service account display name.') +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_service_account_display_name = attribute(:gcp_service_account_display_name, default: '<%= external_attribute(pwd, 'gcp_service_account_display_name') -%>', description: 'The IAM service account display name.') gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default:0, description:'Flag to enable privileged resources requiring elevated privileges in GCP.') -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file diff --git a/templates/inspec/examples/google_service_account_key/google_service_account_keys.erb b/templates/inspec/examples/google_service_account_key/google_service_account_keys.erb index 4e957a975e01..052d62f3ee30 100644 --- a/templates/inspec/examples/google_service_account_key/google_service_account_keys.erb +++ b/templates/inspec/examples/google_service_account_key/google_service_account_keys.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_service_account_display_name = "#{external_attribute('gcp_service_account_display_name', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_service_account_display_name = "#{external_attribute(pwd, 'gcp_service_account_display_name', doc_generation)}" -%> describe google_service_account_keys(project: <%= gcp_project_id -%>, service_account: "<%= doc_generation ? "display-name" : "\#{gcp_service_account_display_name}" -%>@<%= doc_generation ? "project-id" : "\#{gcp_project_id}" -%>.iam.gserviceaccount.com") do its('count') { should be <= 1000 } its('key_types') { should_not include 'USER_MANAGED' } diff --git a/templates/inspec/examples/google_sourcerepo_repository/google_sourcerepo_repositories.erb b/templates/inspec/examples/google_sourcerepo_repository/google_sourcerepo_repositories.erb index 2f85226d9ad3..0c3e3adf3f99 100644 --- a/templates/inspec/examples/google_sourcerepo_repository/google_sourcerepo_repositories.erb +++ b/templates/inspec/examples/google_sourcerepo_repository/google_sourcerepo_repositories.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% repository = grab_attributes['repository'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% repository = grab_attributes(pwd)['repository'] -%> repo_name = <%= doc_generation ? "'#{repository['name']}'" : "repository['name']" %> describe.one do google_sourcerepo_repositories(project: <%= gcp_project_id -%>).names.each do |name| diff --git a/templates/inspec/examples/google_sourcerepo_repository/google_sourcerepo_repository.erb b/templates/inspec/examples/google_sourcerepo_repository/google_sourcerepo_repository.erb index b4c9bbc6193f..469e77755211 100644 --- a/templates/inspec/examples/google_sourcerepo_repository/google_sourcerepo_repository.erb +++ b/templates/inspec/examples/google_sourcerepo_repository/google_sourcerepo_repository.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% repository = grab_attributes['repository'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% repository = grab_attributes(pwd)['repository'] -%> describe google_sourcerepo_repository(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{repository['name']}'" : "repository['name']" -%>) do it { should exist } end diff --git a/templates/inspec/examples/google_sourcerepo_repository/google_sourcerepo_repository_attributes.erb b/templates/inspec/examples/google_sourcerepo_repository/google_sourcerepo_repository_attributes.erb index eb1280931aee..027498314e4d 100644 --- a/templates/inspec/examples/google_sourcerepo_repository/google_sourcerepo_repository_attributes.erb +++ b/templates/inspec/examples/google_sourcerepo_repository/google_sourcerepo_repository_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -repository = attribute('repository', default: <%= JSON.pretty_generate(grab_attributes['repository']) -%>, description: 'Source Repository definition') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +repository = attribute('repository', default: <%= JSON.pretty_generate(grab_attributes(pwd)['repository']) -%>, description: 'Source Repository definition') \ No newline at end of file diff --git a/templates/inspec/examples/google_spanner_database/google_spanner_database.erb b/templates/inspec/examples/google_spanner_database/google_spanner_database.erb index 487ce68cc262..62db1c769db2 100644 --- a/templates/inspec/examples/google_spanner_database/google_spanner_database.erb +++ b/templates/inspec/examples/google_spanner_database/google_spanner_database.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% spannerdatabase = grab_attributes['spannerdatabase'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% spannerdatabase = grab_attributes(pwd)['spannerdatabase'] -%> describe google_spanner_database(project: <%= gcp_project_id -%>, instance: <%= doc_generation ? "'#{spannerdatabase['instance']}'" : "spannerdatabase['instance']" -%>, name: <%= doc_generation ? "'#{spannerdatabase['name']}'" : "spannerdatabase['name']" -%>) do it { should exist } diff --git a/templates/inspec/examples/google_spanner_database/google_spanner_database_attributes.erb b/templates/inspec/examples/google_spanner_database/google_spanner_database_attributes.erb index 93a24ba09df1..a31c01b02921 100644 --- a/templates/inspec/examples/google_spanner_database/google_spanner_database_attributes.erb +++ b/templates/inspec/examples/google_spanner_database/google_spanner_database_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -spannerdatabase = attribute('spannerdatabase', default: <%= JSON.pretty_generate(grab_attributes['spannerdatabase']) -%>, description: 'Cloud Spanner definition') +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +spannerdatabase = attribute('spannerdatabase', default: <%= JSON.pretty_generate(grab_attributes(pwd)['spannerdatabase']) -%>, description: 'Cloud Spanner definition') diff --git a/templates/inspec/examples/google_spanner_database/google_spanner_databases.erb b/templates/inspec/examples/google_spanner_database/google_spanner_databases.erb index c29f3cb3c7ab..064ec0622361 100644 --- a/templates/inspec/examples/google_spanner_database/google_spanner_databases.erb +++ b/templates/inspec/examples/google_spanner_database/google_spanner_databases.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% spannerdatabase = grab_attributes['spannerdatabase'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% spannerdatabase = grab_attributes(pwd)['spannerdatabase'] -%> describe.one do google_spanner_databases(project: <%= gcp_project_id -%>, instance: <%= doc_generation ? "'#{spannerdatabase['instance']}'" : "spannerdatabase['instance']" -%>).names.each do |name| diff --git a/templates/inspec/examples/google_spanner_instance/google_spanner_instance.erb b/templates/inspec/examples/google_spanner_instance/google_spanner_instance.erb index bb488d5eaee0..714f04240248 100644 --- a/templates/inspec/examples/google_spanner_instance/google_spanner_instance.erb +++ b/templates/inspec/examples/google_spanner_instance/google_spanner_instance.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% spannerinstance = grab_attributes['spannerinstance'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% spannerinstance = grab_attributes(pwd)['spannerinstance'] -%> describe google_spanner_instance(project: <%= gcp_project_id -%>, name: <%= doc_generation ? "'#{spannerinstance['name']}'" : "spannerinstance['name']" -%>, config: <%= doc_generation ? "'#{spannerinstance['config']}'" : "spannerinstance['config']" -%>) do it { should exist } diff --git a/templates/inspec/examples/google_spanner_instance/google_spanner_instance_attributes.erb b/templates/inspec/examples/google_spanner_instance/google_spanner_instance_attributes.erb index ba0396d56f0e..1c8ab339e0c8 100644 --- a/templates/inspec/examples/google_spanner_instance/google_spanner_instance_attributes.erb +++ b/templates/inspec/examples/google_spanner_instance/google_spanner_instance_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -spannerinstance = attribute('spannerinstance', default: <%= JSON.pretty_generate(grab_attributes['spannerinstance']) -%>, description: 'Cloud Spanner definition') +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +spannerinstance = attribute('spannerinstance', default: <%= JSON.pretty_generate(grab_attributes(pwd)['spannerinstance']) -%>, description: 'Cloud Spanner definition') diff --git a/templates/inspec/examples/google_spanner_instance/google_spanner_instances.erb b/templates/inspec/examples/google_spanner_instance/google_spanner_instances.erb index 3ddaa51ab622..0b11a9afddca 100644 --- a/templates/inspec/examples/google_spanner_instance/google_spanner_instances.erb +++ b/templates/inspec/examples/google_spanner_instance/google_spanner_instances.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% spannerinstance = grab_attributes['spannerinstance'] -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% spannerinstance = grab_attributes(pwd)['spannerinstance'] -%> describe.one do google_spanner_instances(project: <%= gcp_project_id -%>, config: <%= doc_generation ? "'#{spannerinstance['config']}'" : "spannerinstance['config']" -%>).configs.each do |config| diff --git a/templates/inspec/examples/google_sql_database_instance/google_sql_database_instance.erb b/templates/inspec/examples/google_sql_database_instance/google_sql_database_instance.erb index f2e28abcf105..728842daa274 100644 --- a/templates/inspec/examples/google_sql_database_instance/google_sql_database_instance.erb +++ b/templates/inspec/examples/google_sql_database_instance/google_sql_database_instance.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% gcp_db_instance_name = "#{external_attribute('gcp_db_instance_name', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% gcp_db_instance_name = "#{external_attribute(pwd, 'gcp_db_instance_name', doc_generation)}" -%> describe google_sql_database_instance(project: <%= gcp_project_id -%>, database: <%= gcp_db_instance_name -%>) do it { should exist } diff --git a/templates/inspec/examples/google_sql_database_instance/google_sql_database_instance_attributes.erb b/templates/inspec/examples/google_sql_database_instance/google_sql_database_instance_attributes.erb index a1a3b190f72e..d5b9382713c6 100644 --- a/templates/inspec/examples/google_sql_database_instance/google_sql_database_instance_attributes.erb +++ b/templates/inspec/examples/google_sql_database_instance/google_sql_database_instance_attributes.erb @@ -1,3 +1,3 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'The GCP project location.') -gcp_db_instance_name = attribute(:gcp_db_instance_name, default: '<%= external_attribute('gcp_db_instance_name') -%>', description: 'Database instance name.') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_location = attribute(:gcp_location, default: '<%= external_attribute(pwd, 'gcp_location') -%>', description: 'The GCP project location.') +gcp_db_instance_name = attribute(:gcp_db_instance_name, default: '<%= external_attribute(pwd, 'gcp_db_instance_name') -%>', description: 'Database instance name.') \ No newline at end of file diff --git a/templates/inspec/examples/google_sql_database_instance/google_sql_database_instances.erb b/templates/inspec/examples/google_sql_database_instance/google_sql_database_instances.erb index e67dc17344e9..6d9fd569ef8a 100644 --- a/templates/inspec/examples/google_sql_database_instance/google_sql_database_instances.erb +++ b/templates/inspec/examples/google_sql_database_instance/google_sql_database_instances.erb @@ -1,6 +1,6 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% gcp_db_instance_name = "#{external_attribute('gcp_db_instance_name', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% gcp_db_instance_name = "#{external_attribute(pwd, 'gcp_db_instance_name', doc_generation)}" -%> describe google_sql_database_instances(project: <%= gcp_project_id -%>) do its('instance_states') { should include 'RUNNABLE' } diff --git a/templates/inspec/examples/google_sql_user/google_sql_user.erb b/templates/inspec/examples/google_sql_user/google_sql_user.erb index cb5fff46f9e5..df867ff15c8e 100644 --- a/templates/inspec/examples/google_sql_user/google_sql_user.erb +++ b/templates/inspec/examples/google_sql_user/google_sql_user.erb @@ -1,7 +1,7 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% gcp_db_instance_name = "#{external_attribute('gcp_db_instance_name', doc_generation)}" -%> -<% gcp_db_user_name = "#{external_attribute('gcp_db_user_name', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% gcp_db_instance_name = "#{external_attribute(pwd, 'gcp_db_instance_name', doc_generation)}" -%> +<% gcp_db_user_name = "#{external_attribute(pwd, 'gcp_db_user_name', doc_generation)}" -%> describe google_sql_user(project: <%= gcp_project_id -%>, database: <%= gcp_db_instance_name -%>, name: <%= gcp_db_user_name -%>, host: "example.com") do it { should exist } diff --git a/templates/inspec/examples/google_sql_user/google_sql_user_attributes.erb b/templates/inspec/examples/google_sql_user/google_sql_user_attributes.erb index 0586a7363233..58477507e9a1 100644 --- a/templates/inspec/examples/google_sql_user/google_sql_user_attributes.erb +++ b/templates/inspec/examples/google_sql_user/google_sql_user_attributes.erb @@ -1,4 +1,4 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'The GCP project location.') -gcp_db_instance_name = attribute(:gcp_db_instance_name, default: '<%= external_attribute('gcp_db_instance_name') -%>', description: 'Database instance name.') -gcp_db_user_name = attribute(:gcp_db_user_name, default: '<%= external_attribute('gcp_db_user_name') -%>', description: 'SQL database user name.') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_location = attribute(:gcp_location, default: '<%= external_attribute(pwd, 'gcp_location') -%>', description: 'The GCP project location.') +gcp_db_instance_name = attribute(:gcp_db_instance_name, default: '<%= external_attribute(pwd, 'gcp_db_instance_name') -%>', description: 'Database instance name.') +gcp_db_user_name = attribute(:gcp_db_user_name, default: '<%= external_attribute(pwd, 'gcp_db_user_name') -%>', description: 'SQL database user name.') \ No newline at end of file diff --git a/templates/inspec/examples/google_sql_user/google_sql_users.erb b/templates/inspec/examples/google_sql_user/google_sql_users.erb index 004c03fbce49..b5c3dad3ffdb 100644 --- a/templates/inspec/examples/google_sql_user/google_sql_users.erb +++ b/templates/inspec/examples/google_sql_user/google_sql_users.erb @@ -1,7 +1,7 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> -<% gcp_db_instance_name = "#{external_attribute('gcp_db_instance_name', doc_generation)}" -%> -<% gcp_db_user_name = "#{external_attribute('gcp_db_user_name', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> +<% gcp_db_instance_name = "#{external_attribute(pwd, 'gcp_db_instance_name', doc_generation)}" -%> +<% gcp_db_user_name = "#{external_attribute(pwd, 'gcp_db_user_name', doc_generation)}" -%> describe google_sql_users(project: <%= gcp_project_id -%>, database: <%= gcp_db_instance_name -%>) do its('user_names') { should include <%= gcp_db_user_name -%> } diff --git a/templates/inspec/examples/google_storage_bucket/google_storage_bucket.erb b/templates/inspec/examples/google_storage_bucket/google_storage_bucket.erb index d17b5d6403a7..5cb98f6ee78b 100644 --- a/templates/inspec/examples/google_storage_bucket/google_storage_bucket.erb +++ b/templates/inspec/examples/google_storage_bucket/google_storage_bucket.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> describe google_storage_bucket(name: <%= doc_generation ? "bucket-name" : "\"inspec-gcp-static-\#{gcp_project_id}\"" -%>) do it { should exist } its('location') { should cmp <%= gcp_location -%>.upcase } diff --git a/templates/inspec/examples/google_storage_bucket/google_storage_bucket_attributes.erb b/templates/inspec/examples/google_storage_bucket/google_storage_bucket_attributes.erb index fab87fb26e8a..447e1ec7dbf9 100644 --- a/templates/inspec/examples/google_storage_bucket/google_storage_bucket_attributes.erb +++ b/templates/inspec/examples/google_storage_bucket/google_storage_bucket_attributes.erb @@ -1,2 +1,2 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'GCP location') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_location = attribute(:gcp_location, default: '<%= external_attribute(pwd, 'gcp_location') -%>', description: 'GCP location') \ No newline at end of file diff --git a/templates/inspec/examples/google_storage_bucket/google_storage_buckets.erb b/templates/inspec/examples/google_storage_bucket/google_storage_buckets.erb index 234d7f8a1760..b3dba11223f5 100644 --- a/templates/inspec/examples/google_storage_bucket/google_storage_buckets.erb +++ b/templates/inspec/examples/google_storage_bucket/google_storage_buckets.erb @@ -1,5 +1,5 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_location = "#{external_attribute(pwd, 'gcp_location', doc_generation)}" -%> describe google_storage_buckets(project: <%= gcp_project_id -%>) do its('bucket_names') { should include <%= doc_generation ? "bucket-name" : "\"inspec-gcp-static-\#{gcp_project_id}\"" -%> } end \ No newline at end of file diff --git a/templates/inspec/examples/google_storage_bucket_acl/google_storage_bucket_acl.erb b/templates/inspec/examples/google_storage_bucket_acl/google_storage_bucket_acl.erb index 00bf6af334e9..699ba5f199b1 100644 --- a/templates/inspec/examples/google_storage_bucket_acl/google_storage_bucket_acl.erb +++ b/templates/inspec/examples/google_storage_bucket_acl/google_storage_bucket_acl.erb @@ -1,7 +1,7 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_storage_bucket_acl = "#{external_attribute('gcp_storage_bucket_acl', doc_generation)}" -%> -<% gcp_service_account_display_name = "#{external_attribute('gcp_service_account_display_name', doc_generation)}" -%> -<% gcp_enable_privileged_resources = "#{external_attribute('gcp_enable_privileged_resources', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_storage_bucket_acl = "#{external_attribute(pwd, 'gcp_storage_bucket_acl', doc_generation)}" -%> +<% gcp_service_account_display_name = "#{external_attribute(pwd, 'gcp_service_account_display_name', doc_generation)}" -%> +<% gcp_enable_privileged_resources = "#{external_attribute(pwd, 'gcp_enable_privileged_resources', doc_generation)}" -%> describe google_storage_bucket_acl(bucket: <%= gcp_storage_bucket_acl -%>, entity: <%= doc_generation ? "user-email" : "\"user-\#{gcp_service_account_display_name}@\#{gcp_project_id}.iam.gserviceaccount.com\"" -%>) do it { should exist } its('role') { should cmp "OWNER" } diff --git a/templates/inspec/examples/google_storage_bucket_acl/google_storage_bucket_acl_attributes.erb b/templates/inspec/examples/google_storage_bucket_acl/google_storage_bucket_acl_attributes.erb index 9067ed2710b6..deaa5d4869ae 100644 --- a/templates/inspec/examples/google_storage_bucket_acl/google_storage_bucket_acl_attributes.erb +++ b/templates/inspec/examples/google_storage_bucket_acl/google_storage_bucket_acl_attributes.erb @@ -1,5 +1,5 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_storage_bucket_acl = attribute(:gcp_storage_bucket_acl, default: '<%= external_attribute('gcp_storage_bucket_acl') -%>', description: 'The name of the storage bucket with ACLs attached') -gcp_service_account_display_name = attribute(:gcp_service_account_display_name, default: '<%= external_attribute('gcp_service_account_display_name') -%>', description: 'The name of the service account assigned permissions') -gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default: '<%= external_attribute('gcp_enable_privileged_resources') -%>', description: 'If we are running tests with escalated permissions(required for this test)') -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_storage_bucket_acl = attribute(:gcp_storage_bucket_acl, default: '<%= external_attribute(pwd, 'gcp_storage_bucket_acl') -%>', description: 'The name of the storage bucket with ACLs attached') +gcp_service_account_display_name = attribute(:gcp_service_account_display_name, default: '<%= external_attribute(pwd, 'gcp_service_account_display_name') -%>', description: 'The name of the service account assigned permissions') +gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default: '<%= external_attribute(pwd, 'gcp_enable_privileged_resources') -%>', description: 'If we are running tests with escalated permissions(required for this test)') +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file diff --git a/templates/inspec/examples/google_storage_bucket_object/google_storage_bucket_object.erb b/templates/inspec/examples/google_storage_bucket_object/google_storage_bucket_object.erb index 54c7b928837e..56ee2223cae4 100644 --- a/templates/inspec/examples/google_storage_bucket_object/google_storage_bucket_object.erb +++ b/templates/inspec/examples/google_storage_bucket_object/google_storage_bucket_object.erb @@ -1,8 +1,8 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_storage_bucket_object = "#{external_attribute('gcp_storage_bucket_object', doc_generation)}" -%> -<% gcp_service_account_display_name = "#{external_attribute('gcp_service_account_display_name', doc_generation)}" -%> -<% gcp_storage_bucket_object_name = "#{external_attribute('gcp_storage_bucket_object_name', doc_generation)}" -%> -<% gcp_enable_privileged_resources = "#{external_attribute('gcp_enable_privileged_resources', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_storage_bucket_object = "#{external_attribute(pwd, 'gcp_storage_bucket_object', doc_generation)}" -%> +<% gcp_service_account_display_name = "#{external_attribute(pwd, 'gcp_service_account_display_name', doc_generation)}" -%> +<% gcp_storage_bucket_object_name = "#{external_attribute(pwd, 'gcp_storage_bucket_object_name', doc_generation)}" -%> +<% gcp_enable_privileged_resources = "#{external_attribute(pwd, 'gcp_enable_privileged_resources', doc_generation)}" -%> describe google_storage_bucket_object(bucket: <%= gcp_storage_bucket_object -%>, object: <%= gcp_storage_bucket_object_name -%>) do it { should exist } its('size.to_i') { should be > 0 } diff --git a/templates/inspec/examples/google_storage_bucket_object/google_storage_bucket_object_attributes.erb b/templates/inspec/examples/google_storage_bucket_object/google_storage_bucket_object_attributes.erb index 325d3112c7d7..1a74e108fac9 100644 --- a/templates/inspec/examples/google_storage_bucket_object/google_storage_bucket_object_attributes.erb +++ b/templates/inspec/examples/google_storage_bucket_object/google_storage_bucket_object_attributes.erb @@ -1,6 +1,6 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_storage_bucket_object = attribute(:gcp_storage_bucket_object, default: '<%= external_attribute('gcp_storage_bucket_object') -%>', description: 'The name of the storage bucket with an object') -gcp_service_account_display_name = attribute(:gcp_service_account_display_name, default: '<%= external_attribute('gcp_service_account_display_name') -%>', description: 'The name of the service account assigned permissions') -gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default: '<%= external_attribute('gcp_enable_privileged_resources') -%>', description: 'If we are running tests with escalated permissions(required for this test)') -gcp_storage_bucket_object_name = attribute(:gcp_storage_bucket_object_name, default: '<%= external_attribute('gcp_storage_bucket_object_name') -%>', description: 'The name of the object') -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_storage_bucket_object = attribute(:gcp_storage_bucket_object, default: '<%= external_attribute(pwd, 'gcp_storage_bucket_object') -%>', description: 'The name of the storage bucket with an object') +gcp_service_account_display_name = attribute(:gcp_service_account_display_name, default: '<%= external_attribute(pwd, 'gcp_service_account_display_name') -%>', description: 'The name of the service account assigned permissions') +gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default: '<%= external_attribute(pwd, 'gcp_enable_privileged_resources') -%>', description: 'If we are running tests with escalated permissions(required for this test)') +gcp_storage_bucket_object_name = attribute(:gcp_storage_bucket_object_name, default: '<%= external_attribute(pwd, 'gcp_storage_bucket_object_name') -%>', description: 'The name of the object') +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file diff --git a/templates/inspec/examples/google_storage_bucket_object/google_storage_bucket_objects.erb b/templates/inspec/examples/google_storage_bucket_object/google_storage_bucket_objects.erb index b64afeba2b2a..24721f9a0139 100644 --- a/templates/inspec/examples/google_storage_bucket_object/google_storage_bucket_objects.erb +++ b/templates/inspec/examples/google_storage_bucket_object/google_storage_bucket_objects.erb @@ -1,8 +1,8 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_storage_bucket_object = "#{external_attribute('gcp_storage_bucket_object', doc_generation)}" -%> -<% gcp_service_account_display_name = "#{external_attribute('gcp_service_account_display_name', doc_generation)}" -%> -<% gcp_storage_bucket_object_name = "#{external_attribute('gcp_storage_bucket_object_name', doc_generation)}" -%> -<% gcp_enable_privileged_resources = "#{external_attribute('gcp_enable_privileged_resources', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_storage_bucket_object = "#{external_attribute(pwd, 'gcp_storage_bucket_object', doc_generation)}" -%> +<% gcp_service_account_display_name = "#{external_attribute(pwd, 'gcp_service_account_display_name', doc_generation)}" -%> +<% gcp_storage_bucket_object_name = "#{external_attribute(pwd, 'gcp_storage_bucket_object_name', doc_generation)}" -%> +<% gcp_enable_privileged_resources = "#{external_attribute(pwd, 'gcp_enable_privileged_resources', doc_generation)}" -%> describe google_storage_bucket_objects(bucket: <%= gcp_storage_bucket_object -%>) do its('object_names') { should include <%= gcp_storage_bucket_object_name -%> } its('count') { should be <= 10 } diff --git a/templates/inspec/examples/google_storage_default_object_acl/google_storage_default_object_acl.erb b/templates/inspec/examples/google_storage_default_object_acl/google_storage_default_object_acl.erb index ff8e0785d1d3..87340b7b0642 100644 --- a/templates/inspec/examples/google_storage_default_object_acl/google_storage_default_object_acl.erb +++ b/templates/inspec/examples/google_storage_default_object_acl/google_storage_default_object_acl.erb @@ -1,7 +1,7 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_storage_bucket_name = "#{external_attribute('gcp_storage_bucket_name', doc_generation)}" -%> -<% gcp_service_account_display_name = "#{external_attribute('gcp_service_account_display_name', doc_generation)}" -%> -<% gcp_enable_privileged_resources = "#{external_attribute('gcp_enable_privileged_resources', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_storage_bucket_name = "#{external_attribute(pwd, 'gcp_storage_bucket_name', doc_generation)}" -%> +<% gcp_service_account_display_name = "#{external_attribute(pwd, 'gcp_service_account_display_name', doc_generation)}" -%> +<% gcp_enable_privileged_resources = "#{external_attribute(pwd, 'gcp_enable_privileged_resources', doc_generation)}" -%> describe google_storage_default_object_acl(bucket: <%= gcp_storage_bucket_name -%>, entity: <%= doc_generation ? "user-email" : "\"user-\#{gcp_service_account_display_name}@\#{gcp_project_id}.iam.gserviceaccount.com\"" -%>) do it { should exist } its('role') { should cmp "OWNER" } diff --git a/templates/inspec/examples/google_storage_default_object_acl/google_storage_default_object_acl_attributes.erb b/templates/inspec/examples/google_storage_default_object_acl/google_storage_default_object_acl_attributes.erb index beaea827ad37..dc05a00799a1 100644 --- a/templates/inspec/examples/google_storage_default_object_acl/google_storage_default_object_acl_attributes.erb +++ b/templates/inspec/examples/google_storage_default_object_acl/google_storage_default_object_acl_attributes.erb @@ -1,5 +1,5 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_storage_bucket_name = attribute(:gcp_storage_bucket_name, default: '<%= external_attribute('gcp_storage_bucket_name') -%>', description: 'The name of the storage bucket with the default object ACL') -gcp_service_account_display_name = attribute(:gcp_service_account_display_name, default: '<%= external_attribute('gcp_service_account_display_name') -%>', description: 'The name of the service account assigned permissions') -gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default: '<%= external_attribute('gcp_enable_privileged_resources') -%>', description: 'If we are running tests with escalated permissions(required for this test)') -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_storage_bucket_name = attribute(:gcp_storage_bucket_name, default: '<%= external_attribute(pwd, 'gcp_storage_bucket_name') -%>', description: 'The name of the storage bucket with the default object ACL') +gcp_service_account_display_name = attribute(:gcp_service_account_display_name, default: '<%= external_attribute(pwd, 'gcp_service_account_display_name') -%>', description: 'The name of the service account assigned permissions') +gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default: '<%= external_attribute(pwd, 'gcp_enable_privileged_resources') -%>', description: 'If we are running tests with escalated permissions(required for this test)') +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file diff --git a/templates/inspec/examples/google_storage_object_acl/google_storage_object_acl.erb b/templates/inspec/examples/google_storage_object_acl/google_storage_object_acl.erb index 1a183f728e93..8642e26fc994 100644 --- a/templates/inspec/examples/google_storage_object_acl/google_storage_object_acl.erb +++ b/templates/inspec/examples/google_storage_object_acl/google_storage_object_acl.erb @@ -1,8 +1,8 @@ -<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> -<% gcp_storage_bucket_object = "#{external_attribute('gcp_storage_bucket_object', doc_generation)}" -%> -<% gcp_service_account_display_name = "#{external_attribute('gcp_service_account_display_name', doc_generation)}" -%> -<% gcp_storage_bucket_object_name = "#{external_attribute('gcp_storage_bucket_object_name', doc_generation)}" -%> -<% gcp_enable_privileged_resources = "#{external_attribute('gcp_enable_privileged_resources', doc_generation)}" -%> +<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%> +<% gcp_storage_bucket_object = "#{external_attribute(pwd, 'gcp_storage_bucket_object', doc_generation)}" -%> +<% gcp_service_account_display_name = "#{external_attribute(pwd, 'gcp_service_account_display_name', doc_generation)}" -%> +<% gcp_storage_bucket_object_name = "#{external_attribute(pwd, 'gcp_storage_bucket_object_name', doc_generation)}" -%> +<% gcp_enable_privileged_resources = "#{external_attribute(pwd, 'gcp_enable_privileged_resources', doc_generation)}" -%> describe google_storage_object_acl(bucket: <%= gcp_storage_bucket_object -%>, object: <%= gcp_storage_bucket_object_name -%>, entity: <%= doc_generation ? "user-email" : "\"user-\#{gcp_service_account_display_name}@\#{gcp_project_id}.iam.gserviceaccount.com\"" -%>) do it { should exist } its('role') { should cmp "OWNER" } diff --git a/templates/inspec/examples/google_storage_object_acl/google_storage_object_acl_attributes.erb b/templates/inspec/examples/google_storage_object_acl/google_storage_object_acl_attributes.erb index 3e738dbe025e..410358a1f54a 100644 --- a/templates/inspec/examples/google_storage_object_acl/google_storage_object_acl_attributes.erb +++ b/templates/inspec/examples/google_storage_object_acl/google_storage_object_acl_attributes.erb @@ -1,6 +1,6 @@ -gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') -gcp_storage_bucket_object = attribute(:gcp_storage_bucket_object, default: '<%= external_attribute('gcp_storage_bucket_object') -%>', description: 'The name of the storage bucket with ACLs attached') -gcp_service_account_display_name = attribute(:gcp_service_account_display_name, default: '<%= external_attribute('gcp_service_account_display_name') -%>', description: 'The name of the service account assigned permissions') -gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default: '<%= external_attribute('gcp_enable_privileged_resources') -%>', description: 'If we are running tests with escalated permissions(required for this test)') -gcp_storage_bucket_object_name = attribute(:gcp_storage_bucket_object_name, default: '<%= external_attribute('gcp_storage_bucket_object_name') -%>', description: 'The name of the object with ACLs') -gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file +gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.') +gcp_storage_bucket_object = attribute(:gcp_storage_bucket_object, default: '<%= external_attribute(pwd, 'gcp_storage_bucket_object') -%>', description: 'The name of the storage bucket with ACLs attached') +gcp_service_account_display_name = attribute(:gcp_service_account_display_name, default: '<%= external_attribute(pwd, 'gcp_service_account_display_name') -%>', description: 'The name of the service account assigned permissions') +gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default: '<%= external_attribute(pwd, 'gcp_enable_privileged_resources') -%>', description: 'If we are running tests with escalated permissions(required for this test)') +gcp_storage_bucket_object_name = attribute(:gcp_storage_bucket_object_name, default: '<%= external_attribute(pwd, 'gcp_storage_bucket_object_name') -%>', description: 'The name of the object with ACLs') +gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute(pwd, 'gcp_organization_id') -%>, description: 'The identifier of the organization') \ No newline at end of file diff --git a/templates/inspec/iam_binding/iam_binding.erb b/templates/inspec/iam_binding/iam_binding.erb index 0858dbc4d1af..bf22e29ac5fa 100644 --- a/templates/inspec/iam_binding/iam_binding.erb +++ b/templates/inspec/iam_binding/iam_binding.erb @@ -1,6 +1,6 @@ # frozen_string_literal: false -<%= lines(autogen_notice :ruby) -%> +<%= lines(autogen_notice(:ruby,pwd)) -%> require 'gcp_backend' require 'google/iam/property/iam_policy_bindings' diff --git a/templates/inspec/iam_policy/iam_policy.erb b/templates/inspec/iam_policy/iam_policy.erb index feb283999a7b..62e249de1295 100644 --- a/templates/inspec/iam_policy/iam_policy.erb +++ b/templates/inspec/iam_policy/iam_policy.erb @@ -1,6 +1,6 @@ # frozen_string_literal: false -<%= lines(autogen_notice :ruby) -%> +<%= lines(autogen_notice(:ruby,pwd)) -%> require 'gcp_backend' require 'google/iam/property/iam_policy_audit_configs' require 'google/iam/property/iam_policy_bindings' diff --git a/templates/inspec/integration_test_template.erb b/templates/inspec/integration_test_template.erb index 1646ca707468..06209f1229d7 100644 --- a/templates/inspec/integration_test_template.erb +++ b/templates/inspec/integration_test_template.erb @@ -1,4 +1,4 @@ -<%= lines(autogen_notice :ruby) -%> +<%= lines(autogen_notice(:ruby, pwd)) -%> <% vcr_mode = ENV['VCR_MODE'] -%> <% raise "Bad VCR_MODE environment variable set. Should be nil, 'none' or 'all'" unless vcr_mode.nil? || vcr_mode == 'all' || vcr_mode == 'none' -%> <% if vcr_mode -%> @@ -8,7 +8,7 @@ title 'Test GCP <%= name -%> resource.' -<%= compile("templates/inspec/examples/#{attribute_file_name}/#{attribute_file_name}_attributes.erb") -%> +<%= compile(pwd + "/templates/inspec/examples/#{attribute_file_name}/#{attribute_file_name}_attributes.erb") -%> control '<%= name -%>-1.0' do impact 1.0 @@ -20,7 +20,7 @@ control '<%= name -%>-1.0' do <% if vcr_mode -%> VCR.use_cassette('<%= name -%>', :record => :<%= vcr_mode -%>) do <% end # if vcr_mode -%> -<%= indent(compile("templates/inspec/examples/#{attribute_file_name}/#{name}.erb"), vcr_mode ? 4 : 2) %> +<%= indent(compile(pwd + "/templates/inspec/examples/#{attribute_file_name}/#{name}.erb"), vcr_mode ? 4 : 2) %> <% if vcr_mode -%> end <% end # if vcr_mode -%> diff --git a/templates/inspec/nested_object.erb b/templates/inspec/nested_object.erb index 4a3d3e48eb55..05a4382b2e05 100644 --- a/templates/inspec/nested_object.erb +++ b/templates/inspec/nested_object.erb @@ -24,7 +24,7 @@ -%> # frozen_string_literal: false -<%= lines(autogen_notice :ruby) -%> +<%= lines(autogen_notice(:ruby, pwd)) -%> <% requires = generate_requires(nested_property.nested_properties) -%> diff --git a/templates/inspec/plural_resource.erb b/templates/inspec/plural_resource.erb index 9d764db159b5..a067301ea831 100644 --- a/templates/inspec/plural_resource.erb +++ b/templates/inspec/plural_resource.erb @@ -14,7 +14,7 @@ -%> # frozen_string_literal: false -<%= lines(autogen_notice :ruby) -%> +<%= lines(autogen_notice(:ruby, pwd)) -%> require 'gcp_backend' class <%= object.__product.name.camelize(:upper) -%><%= object.name -%>s < GcpResourceBase <% @@ -64,7 +64,7 @@ link_query_items = object&.nested_query&.keys&.first || object.collection_url_ke hash_with_symbols[name] = value end <% if object.plural_custom_logic -%> -<%= lines(indent(compile(object.plural_custom_logic), 8)) -%> +<%= lines(indent(compile(pwd + '/' + object.plural_custom_logic), 8)) -%> <% end -%> converted.push(hash_with_symbols) end @@ -96,7 +96,7 @@ link_query_items = object&.nested_query&.keys&.first || object.collection_url_ke private -<%= compile('templates/inspec/product_url.erb') -%> +<%= compile(pwd + '/templates/inspec/product_url.erb') -%> def resource_base_url '<%= object.base_url %>' diff --git a/templates/inspec/singular_resource.erb b/templates/inspec/singular_resource.erb index 8b79a3226eea..2283382f4cda 100644 --- a/templates/inspec/singular_resource.erb +++ b/templates/inspec/singular_resource.erb @@ -14,9 +14,9 @@ -%> # frozen_string_literal: false -<%= lines(autogen_notice :ruby) -%> +<%= lines(autogen_notice(:ruby, pwd)) -%> <% - require 'google/string_utils' + require pwd + '/google/string_utils' inside_indent = 8 @@ -39,7 +39,7 @@ class <%= object.__product.name.camelize(:upper) -%><%= object.name -%> < GcpRes <% end -%> <% if !object.singular_custom_constructor.nil? -%> -<%= indent(compile(object.singular_custom_constructor), 2) -%> +<%= indent(compile(pwd + '/' + object.singular_custom_constructor), 2) -%> <% elsif object.nested_query.nil? -%> def initialize(params) @@ -100,12 +100,12 @@ best_guess_identifier = extract_identifiers(individual_url).last end <% unless object&.additional_functions.nil? -%> -<%= lines(indent(compile(object.additional_functions), 2)) -%> +<%= lines(indent(compile(pwd + '/' + object.additional_functions), 2)) -%> <% end -%> private -<%= compile('templates/inspec/product_url.erb') -%> +<%= compile(pwd + '/templates/inspec/product_url.erb') -%> <% url = object.self_link || object.base_url + '/{{name}}' -%> <% url_params = extract_identifiers(individual_url) -%> diff --git a/templates/terraform/custom_expand/compute_full_url.erb b/templates/terraform/custom_expand/compute_full_url.erb index 32dbb4da8be5..637528d1adf8 100644 --- a/templates/terraform/custom_expand/compute_full_url.erb +++ b/templates/terraform/custom_expand/compute_full_url.erb @@ -16,7 +16,7 @@ func expand<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d T if v == nil || v.(string) == "" { return "", nil } - f, err := <%= build_expand_resource_ref('v.(string)', property) %> + f, err := <%= build_expand_resource_ref('v.(string)', property, pwd) %> if err != nil { return nil, fmt.Errorf("Invalid value for <%= property.name.underscore -%>: %s", err) } diff --git a/templates/terraform/examples/base_configs/example_file.tf.erb b/templates/terraform/examples/base_configs/example_file.tf.erb index 5d2155f0173b..bad51ff17c74 100644 --- a/templates/terraform/examples/base_configs/example_file.tf.erb +++ b/templates/terraform/examples/base_configs/example_file.tf.erb @@ -1,2 +1,2 @@ <% autogen_exception -%> -<%= example.config_example -%> +<%= example.config_example(pwd) -%> diff --git a/templates/terraform/examples/base_configs/iam_test_file.go.erb b/templates/terraform/examples/base_configs/iam_test_file.go.erb index 818fb94c4191..10ddb6f9f72f 100644 --- a/templates/terraform/examples/base_configs/iam_test_file.go.erb +++ b/templates/terraform/examples/base_configs/iam_test_file.go.erb @@ -1,4 +1,4 @@ -<%= lines(autogen_notice :go) -%> +<%= lines(autogen_notice(:go, pwd)) -%> package google @@ -52,7 +52,7 @@ import_url = import_format.gsub(/({{)(\w+)(}})/, '%s').gsub(object.__product.bas func TestAcc<%= resource_name -%>IamBindingGenerated(t *testing.T) { t.Parallel() -<%= lines(compile('templates/terraform/iam/iam_context.go.erb')) -%> +<%= lines(compile(pwd + '/templates/terraform/iam/iam_context.go.erb')) -%> vcrTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -92,7 +92,7 @@ func TestAcc<%= resource_name -%>IamBindingGenerated(t *testing.T) { func TestAcc<%= resource_name -%>IamMemberGenerated(t *testing.T) { t.Parallel() -<%= lines(compile('templates/terraform/iam/iam_context.go.erb')) -%> +<%= lines(compile(pwd + '/templates/terraform/iam/iam_context.go.erb')) -%> vcrTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -121,7 +121,7 @@ func TestAcc<%= resource_name -%>IamMemberGenerated(t *testing.T) { func TestAcc<%= resource_name -%>IamPolicyGenerated(t *testing.T) { t.Parallel() -<%= lines(compile('templates/terraform/iam/iam_context.go.erb')) -%> +<%= lines(compile(pwd + '/templates/terraform/iam/iam_context.go.erb')) -%> <% unless object.iam_policy.admin_iam_role.nil? -%> context["service_account"] = getTestServiceAccountFromEnv(t) <% end -%> @@ -164,7 +164,7 @@ func TestAcc<%= resource_name -%>IamPolicyGenerated(t *testing.T) { func TestAcc<%= resource_name -%>IamBindingGenerated_withCondition(t *testing.T) { t.Parallel() -<%= lines(compile('templates/terraform/iam/iam_context.go.erb')) -%> +<%= lines(compile(pwd + '/templates/terraform/iam/iam_context.go.erb')) -%> vcrTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -192,7 +192,7 @@ func TestAcc<%= resource_name -%>IamBindingGenerated_withCondition(t *testing.T) func TestAcc<%= resource_name -%>IamBindingGenerated_withAndWithoutCondition(t *testing.T) { t.Parallel() -<%= lines(compile('templates/terraform/iam/iam_context.go.erb')) -%> +<%= lines(compile(pwd + '/templates/terraform/iam/iam_context.go.erb')) -%> vcrTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -228,7 +228,7 @@ func TestAcc<%= resource_name -%>IamBindingGenerated_withAndWithoutCondition(t * func TestAcc<%= resource_name -%>IamMemberGenerated_withCondition(t *testing.T) { t.Parallel() -<%= lines(compile('templates/terraform/iam/iam_context.go.erb')) -%> +<%= lines(compile(pwd + '/templates/terraform/iam/iam_context.go.erb')) -%> vcrTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -256,7 +256,7 @@ func TestAcc<%= resource_name -%>IamMemberGenerated_withCondition(t *testing.T) func TestAcc<%= resource_name -%>IamMemberGenerated_withAndWithoutCondition(t *testing.T) { t.Parallel() -<%= lines(compile('templates/terraform/iam/iam_context.go.erb')) -%> +<%= lines(compile(pwd + '/templates/terraform/iam/iam_context.go.erb')) -%> vcrTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -292,7 +292,7 @@ func TestAcc<%= resource_name -%>IamMemberGenerated_withAndWithoutCondition(t *t func TestAcc<%= resource_name -%>IamPolicyGenerated_withCondition(t *testing.T) { t.Parallel() -<%= lines(compile('templates/terraform/iam/iam_context.go.erb')) -%> +<%= lines(compile(pwd + '/templates/terraform/iam/iam_context.go.erb')) -%> <% unless object.iam_policy.admin_iam_role.nil? -%> context["service_account"] = getTestServiceAccountFromEnv(t) <% end -%> @@ -323,13 +323,13 @@ func TestAcc<%= resource_name -%>IamPolicyGenerated_withCondition(t *testing.T) func testAcc<%= resource_name -%>IamMember_basicGenerated(context map[string]interface{}) string { return Nprintf(` -<%= example.config_test_body -%> +<%= example.config_test_body(pwd) -%> resource "<%= resource_ns_iam -%>_member" "foo" { <% unless object.min_version.name == "ga" -%> provider = google-beta <% end -%> -<%= lines(compile(object.iam_policy.example_config_body)) -%> +<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> role = "%{role}" member = "user:admin@hashicorptest.com" } @@ -338,7 +338,7 @@ resource "<%= resource_ns_iam -%>_member" "foo" { func testAcc<%= resource_name -%>IamPolicy_basicGenerated(context map[string]interface{}) string { return Nprintf(` -<%= example.config_test_body -%> +<%= example.config_test_body(pwd) -%> data "google_iam_policy" "foo" { <% unless object.min_version.name == "ga" -%> @@ -360,7 +360,7 @@ resource "<%= resource_ns_iam -%>_policy" "foo" { <% unless object.min_version.name == "ga" -%> provider = google-beta <% end -%> -<%= lines(compile(object.iam_policy.example_config_body)) -%> +<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> policy_data = data.google_iam_policy.foo.policy_data } `, context) @@ -368,7 +368,7 @@ resource "<%= resource_ns_iam -%>_policy" "foo" { func testAcc<%= resource_name -%>IamPolicy_emptyBinding(context map[string]interface{}) string { return Nprintf(` -<%= example.config_test_body -%> +<%= example.config_test_body(pwd) -%> data "google_iam_policy" "foo" { <% unless object.min_version.name == "ga" -%> @@ -380,7 +380,7 @@ resource "<%= resource_ns_iam -%>_policy" "foo" { <% unless object.min_version.name == "ga" -%> provider = google-beta <% end -%> -<%= lines(compile(object.iam_policy.example_config_body)) -%> +<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> policy_data = data.google_iam_policy.foo.policy_data } `, context) @@ -388,13 +388,13 @@ resource "<%= resource_ns_iam -%>_policy" "foo" { func testAcc<%= resource_name -%>IamBinding_basicGenerated(context map[string]interface{}) string { return Nprintf(` -<%= example.config_test_body -%> +<%= example.config_test_body(pwd) -%> resource "<%= resource_ns_iam -%>_binding" "foo" { <% unless object.min_version.name == "ga" -%> provider = google-beta <% end -%> -<%= lines(compile(object.iam_policy.example_config_body)) -%> +<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> role = "%{role}" members = ["user:admin@hashicorptest.com"] } @@ -403,13 +403,13 @@ resource "<%= resource_ns_iam -%>_binding" "foo" { func testAcc<%= resource_name -%>IamBinding_updateGenerated(context map[string]interface{}) string { return Nprintf(` -<%= example.config_test_body -%> +<%= example.config_test_body(pwd) -%> resource "<%= resource_ns_iam -%>_binding" "foo" { <% unless object.min_version.name == "ga" -%> provider = google-beta <% end -%> -<%= lines(compile(object.iam_policy.example_config_body)) -%> +<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> role = "%{role}" members = ["user:admin@hashicorptest.com", "user:paddy@hashicorp.com"] } @@ -419,13 +419,13 @@ resource "<%= resource_ns_iam -%>_binding" "foo" { <% unless version == 'ga' || object.iam_policy.iam_conditions_request_type.nil? -%> func testAcc<%= resource_name -%>IamBinding_withConditionGenerated(context map[string]interface{}) string { return Nprintf(` -<%= example.config_test_body -%> +<%= example.config_test_body(pwd) -%> resource "<%= resource_ns_iam -%>_binding" "foo" { <% unless object.min_version.name == "ga" -%> provider = google-beta <% end -%> -<%= lines(compile(object.iam_policy.example_config_body)) -%> +<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> role = "%{role}" members = ["user:admin@hashicorptest.com"] condition { @@ -439,13 +439,13 @@ resource "<%= resource_ns_iam -%>_binding" "foo" { func testAcc<%= resource_name -%>IamBinding_withAndWithoutConditionGenerated(context map[string]interface{}) string { return Nprintf(` -<%= example.config_test_body -%> +<%= example.config_test_body(pwd) -%> resource "<%= resource_ns_iam -%>_binding" "foo" { <% unless object.min_version.name == "ga" -%> provider = google-beta <% end -%> -<%= lines(compile(object.iam_policy.example_config_body)) -%> +<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> role = "%{role}" members = ["user:admin@hashicorptest.com"] } @@ -454,7 +454,7 @@ resource "<%= resource_ns_iam -%>_binding" "foo2" { <% unless object.min_version.name == "ga" -%> provider = google-beta <% end -%> -<%= lines(compile(object.iam_policy.example_config_body)) -%> +<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> role = "%{role}" members = ["user:admin@hashicorptest.com"] condition { @@ -468,13 +468,13 @@ resource "<%= resource_ns_iam -%>_binding" "foo2" { func testAcc<%= resource_name -%>IamMember_withConditionGenerated(context map[string]interface{}) string { return Nprintf(` -<%= example.config_test_body -%> +<%= example.config_test_body(pwd) -%> resource "<%= resource_ns_iam -%>_member" "foo" { <% unless object.min_version.name == "ga" -%> provider = google-beta <% end -%> -<%= lines(compile(object.iam_policy.example_config_body)) -%> +<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> role = "%{role}" member = "user:admin@hashicorptest.com" condition { @@ -488,13 +488,13 @@ resource "<%= resource_ns_iam -%>_member" "foo" { func testAcc<%= resource_name -%>IamMember_withAndWithoutConditionGenerated(context map[string]interface{}) string { return Nprintf(` -<%= example.config_test_body -%> +<%= example.config_test_body(pwd) -%> resource "<%= resource_ns_iam -%>_member" "foo" { <% unless object.min_version.name == "ga" -%> provider = google-beta <% end -%> -<%= lines(compile(object.iam_policy.example_config_body)) -%> +<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> role = "%{role}" member = "user:admin@hashicorptest.com" } @@ -503,7 +503,7 @@ resource "<%= resource_ns_iam -%>_member" "foo2" { <% unless object.min_version.name == "ga" -%> provider = google-beta <% end -%> -<%= lines(compile(object.iam_policy.example_config_body)) -%> +<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> role = "%{role}" member = "user:admin@hashicorptest.com" condition { @@ -517,7 +517,7 @@ resource "<%= resource_ns_iam -%>_member" "foo2" { func testAcc<%= resource_name -%>IamPolicy_withConditionGenerated(context map[string]interface{}) string { return Nprintf(` -<%= example.config_test_body -%> +<%= example.config_test_body(pwd) -%> data "google_iam_policy" "foo" { <% unless object.min_version.name == "ga" -%> @@ -544,7 +544,7 @@ resource "<%= resource_ns_iam -%>_policy" "foo" { <% unless object.min_version.name == "ga" -%> provider = google-beta <% end -%> -<%= lines(compile(object.iam_policy.example_config_body)) -%> +<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> policy_data = data.google_iam_policy.foo.policy_data } `, context) diff --git a/templates/terraform/examples/base_configs/test_file.go.erb b/templates/terraform/examples/base_configs/test_file.go.erb index 02e0f5f7f7a4..8a883b5978fb 100644 --- a/templates/terraform/examples/base_configs/test_file.go.erb +++ b/templates/terraform/examples/base_configs/test_file.go.erb @@ -1,4 +1,4 @@ -<%= lines(autogen_notice :go) -%> +<%= lines(autogen_notice(:go, pwd)) -%> package google @@ -42,7 +42,7 @@ func TestAcc<%= test_slug -%>(t *testing.T) { t.Parallel() context := map[string]interface{} { -<%= lines(indent(compile('templates/terraform/env_var_context.go.erb'), 4)) -%> +<%= lines(indent(compile(pwd + '/templates/terraform/env_var_context.go.erb'), 4)) -%> <% unless example.test_vars_overrides.nil? -%> <% example.test_vars_overrides.each do |var_name, override| -%> "<%= var_name %>": <%= override %>, @@ -82,7 +82,7 @@ func TestAcc<%= test_slug -%>(t *testing.T) { } func testAcc<%= test_slug -%>(context map[string]interface{}) string { -<%= example.config_test -%> +<%= example.config_test(pwd) -%> } <%- end %> @@ -98,7 +98,7 @@ func testAccCheck<%= resource_name -%>DestroyProducer(t *testing.T) func(s *terr } <% if object.custom_code.test_check_destroy -%> - <%= lines(compile(object.custom_code.test_check_destroy)) -%> + <%= lines(compile(pwd + '/' + object.custom_code.test_check_destroy)) -%> <% else -%> config := googleProviderConfig(t) diff --git a/templates/terraform/expand_property_method.erb b/templates/terraform/expand_property_method.erb index f1169861172d..a1953ea8133c 100644 --- a/templates/terraform/expand_property_method.erb +++ b/templates/terraform/expand_property_method.erb @@ -13,10 +13,11 @@ # limitations under the License. -%> <% if property.custom_expand -%> -<%= lines(compile_template(property.custom_expand, +<%= lines(compile_template(pwd + '/' + property.custom_expand, prefix: prefix, property: property, - object: object)) -%> + object: object, + pwd: pwd)) -%> <% else -%> <%# Generate expanders for Maps %> @@ -150,7 +151,7 @@ func expand<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d T if raw == nil { return nil, fmt.Errorf("Invalid value for <%= property.name.underscore -%>: nil") } - f, err := <%= build_expand_resource_ref('raw.(string)', property.item_type) %> + f, err := <%= build_expand_resource_ref('raw.(string)', property.item_type, pwd) %> if err != nil { return nil, fmt.Errorf("Invalid value for <%= property.name.underscore -%>: %s", err) } @@ -160,7 +161,7 @@ func expand<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d T } <% else -%> <% if property.is_a?(Api::Type::ResourceRef) -%> - f, err := <%= build_expand_resource_ref('v.(string)', property) %> + f, err := <%= build_expand_resource_ref('v.(string)', property, pwd) %> if err != nil { return nil, fmt.Errorf("Invalid value for <%= property.name.underscore -%>: %s", err) } @@ -180,7 +181,7 @@ func expand<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d T <% property.nested_properties.each do |prop| -%> <%# Map is a map from {key -> object} in the API, but Terraform can't represent that so we treat the key as a property of the object in Terraform schema. %> -<%= lines(build_expand_method(prefix + titlelize_property(property), prop, object), 1) -%> +<%= lines(build_expand_method(prefix + titlelize_property(property), prop, object, pwd), 1) -%> <% end -%> <% end -%> diff --git a/templates/terraform/flatten_property_method.erb b/templates/terraform/flatten_property_method.erb index f3258bd2ddda..05b2460cc742 100644 --- a/templates/terraform/flatten_property_method.erb +++ b/templates/terraform/flatten_property_method.erb @@ -13,7 +13,7 @@ # limitations under the License. -%> <% if property.custom_flatten -%> -<%= lines(compile_template(property.custom_flatten, +<%= lines(compile_template(pwd + '/' + property.custom_flatten, prefix: prefix, property: property)) -%> <% else -%> @@ -132,7 +132,7 @@ func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d } <% if property.nested_properties? -%> <% property.nested_properties.each do |prop| -%> - <%= lines(build_flatten_method(prefix + titlelize_property(property), prop, object), 1) -%> + <%= lines(build_flatten_method(prefix + titlelize_property(property), prop, object, pwd), 1) -%> <% end -%> <% end -%> <% else -%> diff --git a/templates/terraform/iam/iam_context.go.erb b/templates/terraform/iam/iam_context.go.erb index 6e0a90ee8236..55bafd393547 100644 --- a/templates/terraform/iam/iam_context.go.erb +++ b/templates/terraform/iam/iam_context.go.erb @@ -7,7 +7,7 @@ context := map[string]interface{}{ <% unless object.iam_policy.test_project_name.nil? -%> "project_id" : fmt.Sprintf("<%= object.iam_policy.test_project_name -%>%s", randString(t, 10)), <% end -%> -<%= lines(compile('templates/terraform/env_var_context.go.erb')) -%> +<%= lines(compile(pwd + '/templates/terraform/env_var_context.go.erb')) -%> <% unless example.test_vars_overrides.nil? -%> <% example.test_vars_overrides.each do |var_name, override| -%> "<%= var_name %>": <%= override %>, diff --git a/templates/terraform/iam_policy.go.erb b/templates/terraform/iam_policy.go.erb index 546534926f9e..3ea2a255365b 100644 --- a/templates/terraform/iam_policy.go.erb +++ b/templates/terraform/iam_policy.go.erb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -%> -<%= lines(autogen_notice :go) -%> +<%= lines(autogen_notice(:go, pwd)) -%> package google import ( @@ -57,7 +57,7 @@ var <%= resource_name -%>IamSchema = map[string]*schema.Schema{ } <% unless object.iam_policy.custom_diff_suppress.nil? -%> -<%= lines(compile(object.iam_policy.custom_diff_suppress)) -%> +<%= lines(compile(pwd + '/' + object.iam_policy.custom_diff_suppress)) -%> <% end -%> type <%= resource_name -%>IamUpdater struct { diff --git a/templates/terraform/nested_property_documentation.erb b/templates/terraform/nested_property_documentation.erb index f52def3caa49..50c53b8efeba 100644 --- a/templates/terraform/nested_property_documentation.erb +++ b/templates/terraform/nested_property_documentation.erb @@ -1,7 +1,7 @@ <% if property.flatten_object -%> <% property.nested_properties.each do |prop| -%> -<%= lines(build_nested_property_documentation(prop)) -%> +<%= lines(build_nested_property_documentation(prop, pwd)) -%> <% end -%> <% elsif property.nested_properties? @@ -11,10 +11,10 @@ The `<%= property.name.underscore -%>` block <%= if property.output then "contai * `<%= property.key_name.underscore -%>` - (Required) The identifier for this object. Format specified above. <% end -%> <% property.nested_properties.each do |prop| -%> -<%= lines(build_property_documentation(prop)) -%> +<%= lines(build_property_documentation(prop, pwd)) -%> <% end -%> <% property.nested_properties.each do |prop| -%> -<%= lines(build_nested_property_documentation(prop)) -%> +<%= lines(build_nested_property_documentation(prop, pwd)) -%> <% end -%> <% end -%> diff --git a/templates/terraform/objectlib/base.go.erb b/templates/terraform/objectlib/base.go.erb index 917fecc91388..192bf3171d1e 100644 --- a/templates/terraform/objectlib/base.go.erb +++ b/templates/terraform/objectlib/base.go.erb @@ -1,4 +1,4 @@ -<%= lines(autogen_notice :go) -%> +<%= lines(autogen_notice(:go, pwd)) -%> package google @@ -10,7 +10,7 @@ package google asset_name_template = '//' + product_ns.downcase + '.googleapis.com/' + (!object.self_link.nil? && !object.self_link.empty? ? object.self_link : object.base_url + '/{{name}}') %> -<%= lines(compile(object.custom_code.constants)) if object.custom_code.constants -%> +<%= lines(compile(pwd + '/' + object.custom_code.constants)) if object.custom_code.constants -%> func Get<%= resource_name -%>CaiObject(d TerraformResourceData, config *Config) (Asset, error) { name, err := assetName(d, config, "<%= asset_name_template -%>") @@ -61,11 +61,11 @@ func Get<%= resource_name -%>ApiObject(d TerraformResourceData, config *Config) <% if object.custom_code.encoder -%> func resource<%= resource_name -%>Encoder(d TerraformResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { -<%= lines(compile(object.custom_code.encoder)) -%> +<%= lines(compile(pwd + '/' + object.custom_code.encoder)) -%> } <% end -%> <% object.settable_properties.each do |prop| -%> -<%= lines(build_expand_method(resource_name, prop, object), 1) -%> +<%= lines(build_expand_method(resource_name, prop, object, pwd), 1) -%> <% end -%> diff --git a/templates/terraform/operation.go.erb b/templates/terraform/operation.go.erb index 8396525abf12..c5c92d51fdb7 100644 --- a/templates/terraform/operation.go.erb +++ b/templates/terraform/operation.go.erb @@ -2,7 +2,7 @@ product_name = object.__product.name has_project = object.base_url.include?("{{project}}") -%> -<%= lines(autogen_notice :go) -%> +<%= lines(autogen_notice(:go, pwd)) -%> package google import ( diff --git a/templates/terraform/resource.erb b/templates/terraform/resource.erb index 41280abaaa11..55942b9bdf67 100644 --- a/templates/terraform/resource.erb +++ b/templates/terraform/resource.erb @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -%> -<%= lines(autogen_notice :go) -%> +<%= lines(autogen_notice(:go, pwd)) -%> package google -<%= lines(compile(object.custom_code.constants)) if object.custom_code.constants -%> +<%= lines(compile(pwd + '/' + object.custom_code.constants)) if object.custom_code.constants -%> <% resource_name = product_ns + object.name @@ -82,11 +82,11 @@ func resource<%= resource_name -%>() *schema.Resource { <% end -%> <% end -%> -<%= lines(compile(object.custom_code.resource_definition)) if object.custom_code.resource_definition -%> +<%= lines(compile(pwd + '/' + object.custom_code.resource_definition)) if object.custom_code.resource_definition -%> Schema: map[string]*schema.Schema{ <% order_properties(properties).each do |prop| -%> -<%= lines(build_schema_property(prop, object)) -%> +<%= lines(build_schema_property(prop, object, pwd)) -%> <% end -%> <%- unless object.virtual_fields.empty? -%> <%- object.virtual_fields.each do |field| -%> @@ -97,7 +97,7 @@ func resource<%= resource_name -%>() *schema.Resource { }, <% end -%> <% end -%> -<%= lines(compile(object.custom_code.extra_schema_entry)) if object.custom_code.extra_schema_entry -%> +<%= lines(compile(pwd + '/' + object.custom_code.extra_schema_entry)) if object.custom_code.extra_schema_entry -%> <% if has_project -%> "project": { Type: schema.TypeString, @@ -117,13 +117,13 @@ func resource<%= resource_name -%>() *schema.Resource { } <% properties.each do |prop| -%> -<%= lines(build_subresource_schema(prop, object), 1) -%> +<%= lines(build_subresource_schema(prop, object, pwd), 1) -%> <% end -%> <% object.settable_properties.select {|p| p.unordered_list}.each do |prop| -%> func resource<%= resource_name -%><%= prop.name.camelize(:upper) -%>SetStyleDiff(diff *schema.ResourceDiff, meta interface{}) error { <%= - compile_template('templates/terraform/unordered_list_customize_diff.erb', + compile_template(pwd + '/templates/terraform/unordered_list_customize_diff.erb', prop: prop, resource_name: resource_name) -%> @@ -132,7 +132,7 @@ func resource<%= resource_name -%><%= prop.name.camelize(:upper) -%>SetStyleDiff func resource<%= resource_name -%>Create(d *schema.ResourceData, meta interface{}) error { <% if object.custom_code.custom_create -%> - <%= lines(compile(object.custom_code.custom_create)) -%> + <%= lines(compile(pwd + '/' + object.custom_code.custom_create)) -%> <% else -%> config := meta.(*Config) @@ -315,7 +315,7 @@ func resource<%= resource_name -%>Create(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished creating <%= object.name -%> %q: %#v", d.Id(), res) -<%= lines(compile(object.custom_code.post_create)) if object.custom_code.post_create -%> +<%= lines(compile(pwd + '/' + object.custom_code.post_create)) if object.custom_code.post_create -%> return resource<%= resource_name -%>Read(d, meta) <% end # if custom_create -%> @@ -325,7 +325,7 @@ func resource<%= resource_name -%>Create(d *schema.ResourceData, meta interface{ func resource<%= resource_name -%>PollRead(d *schema.ResourceData, meta interface{}) PollReadFunc { return func() (map[string]interface{}, error) { <% if object.async.custom_poll_read -%> -<%= lines(compile(object.async.custom_poll_read)) -%> +<%= lines(compile(pwd + '/' + object.async.custom_poll_read)) -%> <% else -%> config := meta.(*Config) @@ -681,8 +681,8 @@ if <%= props.map { |prop| "d.HasChange(\"#{prop.name.underscore}\")" }.join ' || } log.Printf("[DEBUG] Updating <%= object.name -%> %q: %#v", d.Id(), obj) -<%= lines(compile('templates/terraform/update_mask.erb')) if object.update_mask -%> -<%= lines(compile(object.custom_code.pre_update)) if object.custom_code.pre_update -%> +<%= lines(compile(pwd + '/templates/terraform/update_mask.erb')) if object.update_mask -%> +<%= lines(compile(pwd + '/' + object.custom_code.pre_update)) if object.custom_code.pre_update -%> <% if object.nested_query&.modify_by_patch -%> <%# Keep this after mutex - patch request data relies on current resource state %> obj, err = resource<%= resource_name -%>PatchUpdateEncoder(d, meta, obj) @@ -728,7 +728,7 @@ if <%= props.map { |prop| "d.HasChange(\"#{prop.name.underscore}\")" }.join ' || <% end -%> <% end # if object.input -%> -<%= lines(compile(object.custom_code.post_update)) if object.custom_code.post_update -%> +<%= lines(compile(pwd + '/' + object.custom_code.post_update)) if object.custom_code.post_update -%> return resource<%= resource_name -%>Read(d, meta) } <% end # if updatable? -%> @@ -742,7 +742,7 @@ func resource<%= resource_name -%>Delete(d *schema.ResourceData, meta interface{ return nil <% elsif object.custom_code.custom_delete -%> -<%= lines(compile(object.custom_code.custom_delete)) -%> +<%= lines(compile(pwd + '/' + object.custom_code.custom_delete)) -%> <% else -%> config := meta.(*Config) @@ -769,7 +769,7 @@ func resource<%= resource_name -%>Delete(d *schema.ResourceData, meta interface{ <%# If the deletion of the object requires sending a request body, the custom code will set 'obj' -%> var obj map[string]interface{} -<%= lines(compile(object.custom_code.pre_delete)) if object.custom_code.pre_delete -%> +<%= lines(compile(pwd + '/' + object.custom_code.pre_delete)) if object.custom_code.pre_delete -%> <% if object.nested_query&.modify_by_patch -%> <%# Keep this after mutex - patch request data relies on current resource state %> obj, err = resource<%= resource_name -%>PatchDeleteEncoder(d, meta, obj) @@ -815,7 +815,7 @@ func resource<%= resource_name -%>Delete(d *schema.ResourceData, meta interface{ <% unless object.exclude_import -%> func resource<%= resource_name -%>Import(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { <% if object.custom_code.custom_import -%> -<%= lines(compile(object.custom_code.custom_import)) -%> +<%= lines(compile(pwd + '/' + object.custom_code.custom_import)) -%> <% else -%> config := meta.(*Config) if err := parseImportId([]string{ @@ -839,7 +839,7 @@ func resource<%= resource_name -%>Import(d *schema.ResourceData, meta interface{ d.Set("<%= field.name %>", <%= go_literal(field.default_value) -%>) <% end -%> <% end -%> -<%= lines(compile(object.custom_code.post_import)) if object.custom_code.post_import -%> +<%= lines(compile(pwd + '/' + object.custom_code.post_import)) if object.custom_code.post_import -%> return []*schema.ResourceData{d}, nil <% end -%> @@ -848,27 +848,27 @@ func resource<%= resource_name -%>Import(d *schema.ResourceData, meta interface{ <%- nested_prefix = object.nested_query ? "Nested" : "" -%> <% object.gettable_properties.reject(&:ignore_read).each do |prop| -%> -<%= lines(build_flatten_method(nested_prefix+resource_name, prop, object), 1) -%> +<%= lines(build_flatten_method(nested_prefix+resource_name, prop, object, pwd), 1) -%> <% end -%> <% object.settable_properties.each do |prop| -%> -<%= lines(build_expand_method(nested_prefix+resource_name, prop, object), 1) -%> +<%= lines(build_expand_method(nested_prefix+resource_name, prop, object, pwd), 1) -%> <% end -%> <% if object.custom_code.encoder -%> func resource<%= resource_name -%>Encoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { -<%= lines(compile(object.custom_code.encoder)) -%> +<%= lines(compile(pwd + '/' + object.custom_code.encoder)) -%> } <% end -%> <% if object.custom_code.update_encoder-%> func resource<%= resource_name -%>UpdateEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { -<%= lines(compile(object.custom_code.update_encoder)) -%> +<%= lines(compile(pwd + '/' + object.custom_code.update_encoder)) -%> } <% end -%> <% if object.nested_query -%> -<%= compile_template('templates/terraform/nested_query.go.erb', +<%= compile_template(pwd + '/templates/terraform/nested_query.go.erb', object: object, settable_properties: object.settable_properties, resource_name: resource_name) -%> @@ -876,17 +876,17 @@ func resource<%= resource_name -%>UpdateEncoder(d *schema.ResourceData, meta int <% if object.custom_code.decoder -%> func resource<%= resource_name -%>Decoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) { -<%= lines(compile(object.custom_code.decoder)) -%> +<%= lines(compile(pwd + '/' + object.custom_code.decoder)) -%> } <% end -%> <% if object.custom_code.post_create_failure -%> func resource<%= resource_name -%>PostCreateFailure(d *schema.ResourceData, meta interface{}) { -<%= lines(compile(object.custom_code.post_create_failure)) -%> +<%= lines(compile(pwd + '/' + object.custom_code.post_create_failure)) -%> } <% end -%> <% if object.schema_version -%> -<%= lines(compile("templates/terraform/state_migrations/#{product_ns.underscore}_#{object.name.underscore}.go.erb")) -%> +<%= lines(compile(pwd + "/templates/terraform/state_migrations/#{product_ns.underscore}_#{object.name.underscore}.go.erb")) -%> <% end -%> diff --git a/templates/terraform/resource.html.markdown.erb b/templates/terraform/resource.html.markdown.erb index 5b525ba0bea2..542613600b83 100644 --- a/templates/terraform/resource.html.markdown.erb +++ b/templates/terraform/resource.html.markdown.erb @@ -48,7 +48,7 @@ timeouts ||= Api::Timeouts.new -%> --- -<%= lines(autogen_notice :yaml) -%> +<%= lines(autogen_notice(:yaml, pwd)) -%> subcategory: "<%= tf_subcategory -%>" layout: "google" page_title: "Google: <%= terraform_name -%>" @@ -106,7 +106,7 @@ state as plain-text. [Read more about sensitive data in state](/docs/state/sensi ## Example Usage - <%= example.name.camelize(:upper).titleize %> -<%= example.config_documentation -%> +<%= example.config_documentation(pwd) -%> <%- end %> <%- end -%> ## Argument Reference @@ -114,11 +114,11 @@ state as plain-text. [Read more about sensitive data in state](/docs/state/sensi The following arguments are supported: <% object.root_properties.select(&:required).each do |prop| -%> -<%= lines(build_property_documentation(prop)) -%> +<%= lines(build_property_documentation(prop, pwd)) -%> <% end -%> <% properties.select(&:required).each do |prop| -%> -<%= lines(build_nested_property_documentation(prop)) -%> +<%= lines(build_nested_property_documentation(prop, pwd)) -%> <% end -%> <%- unless object.docs.required_properties.nil? -%> <%= "\n" + object.docs.required_properties -%> @@ -127,7 +127,7 @@ The following arguments are supported: - - - <% object.root_properties.reject(&:required).reject(&:output).each do |prop| -%> -<%= lines(build_property_documentation(prop)) -%> +<%= lines(build_property_documentation(prop, pwd)) -%> <% end -%> <% if object.base_url.include?("{{project}}") || (object.create_url && object.create_url.include?('{{project}}'))-%> <%# The following new line allow for project to be bullet-formatted properly. -%> @@ -145,7 +145,7 @@ The following arguments are supported: <%= "\n" + object.docs.optional_properties -%> <% end -%> <% properties.reject(&:required).reject(&:output).each do |prop| -%> -<%= lines(build_nested_property_documentation(prop)) -%> +<%= lines(build_nested_property_documentation(prop, pwd)) -%> <% end -%> ## Attributes Reference @@ -154,14 +154,14 @@ In addition to the arguments listed above, the following computed attributes are * `id` - an identifier for the resource with format `<%= id_format(object) %>` <% object.root_properties.select(&:output).each do |prop| -%> -<%= lines(build_property_documentation(prop)) -%> +<%= lines(build_property_documentation(prop, pwd)) -%> <% end -%> <% if object.has_self_link -%> * `self_link` - The URI of the created resource. <% end -%> <% properties.select(&:output).each do |prop| -%> -<%= lines(build_nested_property_documentation(prop)) -%> +<%= lines(build_nested_property_documentation(prop, pwd)) -%> <% end -%> <%- unless object.docs.attributes.nil? -%> <%= "\n" + object.docs.attributes -%> diff --git a/templates/terraform/resource_iam.html.markdown.erb b/templates/terraform/resource_iam.html.markdown.erb index 028ff18be3ee..ffbb5a20513c 100644 --- a/templates/terraform/resource_iam.html.markdown.erb +++ b/templates/terraform/resource_iam.html.markdown.erb @@ -50,7 +50,7 @@ timeouts ||= Api::Timeouts.new -%> --- -<%= lines(autogen_notice :yaml) -%> +<%= lines(autogen_notice(:yaml, pwd)) -%> subcategory: "<%= tf_subcategory -%>" layout: "google" page_title: "Google: <%= resource_ns_iam -%>" @@ -95,7 +95,7 @@ data "google_iam_policy" "admin" { } resource "<%= resource_ns_iam -%>_policy" "policy" { -<%= lines(compile(object.iam_policy.example_config_body)) -%> +<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> policy_data = data.google_iam_policy.admin.policy_data } ``` @@ -120,7 +120,7 @@ data "google_iam_policy" "admin" { } resource "<%= resource_ns_iam -%>_policy" "policy" { -<%= lines(compile(object.iam_policy.example_config_body)) -%> +<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> policy_data = data.google_iam_policy.admin.policy_data } ``` @@ -129,7 +129,7 @@ resource "<%= resource_ns_iam -%>_policy" "policy" { ```hcl resource "<%= resource_ns_iam -%>_binding" "binding" { -<%= lines(compile(object.iam_policy.example_config_body)) -%> +<%= 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", @@ -142,7 +142,7 @@ With IAM Conditions ([beta](https://terraform.io/docs/providers/google/provider_ ```hcl resource "<%= resource_ns_iam -%>_binding" "binding" { -<%= lines(compile(object.iam_policy.example_config_body)) -%> +<%= 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", @@ -160,7 +160,7 @@ resource "<%= resource_ns_iam -%>_binding" "binding" { ```hcl resource "<%= resource_ns_iam -%>_member" "member" { -<%= lines(compile(object.iam_policy.example_config_body)) -%> +<%= 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" } @@ -171,7 +171,7 @@ With IAM Conditions ([beta](https://terraform.io/docs/providers/google/provider_ ```hcl resource "<%= resource_ns_iam -%>_member" "member" { -<%= lines(compile(object.iam_policy.example_config_body)) -%> +<%= 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" diff --git a/templates/terraform/schema_property.erb b/templates/terraform/schema_property.erb index ce287a01db3d..a82fc5ccdce5 100644 --- a/templates/terraform/schema_property.erb +++ b/templates/terraform/schema_property.erb @@ -14,7 +14,7 @@ -%> <% if property.flatten_object -%> <% order_properties(property.properties).each do |prop| -%> - <%= lines(build_schema_property(prop, object)) -%> + <%= lines(build_schema_property(prop, object, pwd)) -%> <% end -%> <% elsif tf_types.include?(property.class) -%> "<%= property.name.underscore -%>": { @@ -81,7 +81,7 @@ Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ <% order_properties(property.properties).each do |prop| -%> - <%= lines(build_schema_property(prop, object)) -%> + <%= lines(build_schema_property(prop, object, pwd)) -%> <% end -%> }, }, @@ -99,7 +99,7 @@ Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ <% order_properties(property.item_type.properties).each do |prop| -%> - <%= lines(build_schema_property(prop, object)) -%> + <%= lines(build_schema_property(prop, object, pwd)) -%> <% end -%> }, }, @@ -141,7 +141,7 @@ <% end -%> }, <% order_properties(property.value_type.properties).each do |prop| -%> - <%= lines(build_schema_property(prop, object)) -%> + <%= lines(build_schema_property(prop, object, pwd)) -%> <% end -%> }, }, diff --git a/templates/terraform/schema_subresource.erb b/templates/terraform/schema_subresource.erb index 3d5ba12434d0..a62023a5d884 100644 --- a/templates/terraform/schema_subresource.erb +++ b/templates/terraform/schema_subresource.erb @@ -19,7 +19,7 @@ func <%= namespace_property_from_object(property, object) -%>Schema() *schema.Re return &schema.Resource{ Schema: map[string]*schema.Schema{ <% order_properties(property.item_type.properties).each do |prop| -%> - <%= lines(build_schema_property(prop, object)) -%> + <%= lines(build_schema_property(prop, object, pwd)) -%> <% end -%> }, } @@ -27,5 +27,5 @@ func <%= namespace_property_from_object(property, object) -%>Schema() *schema.Re <% end %> <% property.nested_properties.each do |prop| -%> -<%= lines(build_subresource_schema(prop, object), 1) -%> +<%= lines(build_subresource_schema(prop, object, pwd), 1) -%> <% end -%> diff --git a/templates/terraform/sweeper_file.go.erb b/templates/terraform/sweeper_file.go.erb index 3e0735e72c4e..67375d164e88 100644 --- a/templates/terraform/sweeper_file.go.erb +++ b/templates/terraform/sweeper_file.go.erb @@ -1,4 +1,4 @@ -<%= lines(autogen_notice :go) -%> +<%= lines(autogen_notice(:go, pwd)) -%> package google