Class: Kitchen::Driver::Oci::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/driver/oci/config.rb

Overview

Config class that defines the oci config that will be used for the API calls

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(driver_config) ⇒ Config

Returns a new instance of Config.



27
28
29
30
# File 'lib/kitchen/driver/oci/config.rb', line 27

def initialize(driver_config)
  setup_driver_config(driver_config)
  @config = oci_config
end

Instance Attribute Details

#configOCI::Config (readonly)

The config used to authenticate to OCI

Returns:

  • (OCI::Config)


37
38
39
# File 'lib/kitchen/driver/oci/config.rb', line 37

def config
  @config
end

Instance Method Details

#compartmentObject



49
50
51
52
53
54
55
56
57
# File 'lib/kitchen/driver/oci/config.rb', line 49

def compartment
  @compartment ||= @compartment_id
  return @compartment if @compartment

  raise "must specify either compartment_id or compartment_name" unless [@compartment_id, @compartment_name].any?

  @compartment ||= compartment_id_by_name(@compartment_name)
  raise "compartment not found" unless @compartment
end

#oci_configObject



39
40
41
42
43
44
45
46
47
# File 'lib/kitchen/driver/oci/config.rb', line 39

def oci_config
  # OCI::Config is missing this
  OCI::Config.class_eval { attr_accessor :security_token_file } if @driver_config[:use_token_auth]
  conf = config_loader(config_file_location: @driver_config[:oci_config_file], profile_name: @driver_config[:oci_profile_name])
  @driver_config[:oci_config].each do |key, value|
    conf.send("#{key}=", value) unless value.nil? || value.empty?
  end
  conf
end