Method: Inspec::Resources::AzureResourceBase#initialize

Defined in:
lib/resources/azure/azure_backend.rb

#initialize(opts) ⇒ AzureResourceBase

Constructor that retreives the specified resource

The opts hash should contain the following

:group_name - name of the resource group in which to look for items
:type - the type of Azure resource to look for
:apiversion - API version to use when looking for a specific resource
:name - name of the resource to find

rubocop:disable Metrics/AbcSize

Parameters:

  • opts (Hash)

    Hashtable of options as highlighted above

Author:

  • Russell Seymour



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/resources/azure/azure_backend.rb', line 21

def initialize(opts)
  # declare the hashtable of counts
  @counts = {}
  @total = 0
  @opts = opts

  # Determine if the environment variables for the options have been set
  option_var_names = {
    group_name: "AZURE_RESOURCE_GROUP_NAME",
    name: "AZURE_RESOURCE_NAME",
    type: "AZURE_RESOURCE_TYPE",
    apiversion: "AZURE_RESOURCE_API_VERSION",
  }
  option_var_names.each do |option_name, env_var_name|
    opts[option_name] = ENV[env_var_name] unless ENV[env_var_name].nil?
  end

  @azure = inspec.backend
  @client = azure.azure_client
  @failed_resource = false
end