Class: Kitchen::Driver::Oci::Config
- Inherits:
-
Object
- Object
- Kitchen::Driver::Oci::Config
- 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
-
#config ⇒ OCI::Config
readonly
The config used to authenticate to OCI.
Instance Method Summary collapse
-
#compartment ⇒ String
The ocid of the compartment where the Kitchen instance will be created.
-
#initialize(driver_config) ⇒ Config
constructor
A new instance of Config.
-
#oci_config ⇒ OCI::Config
Creates a new instance of OCI::Config to be used to authenticate to OCI.
Constructor Details
#initialize(driver_config) ⇒ Config
Returns a new instance of Config.
29 30 31 32 |
# File 'lib/kitchen/driver/oci/config.rb', line 29 def initialize(driver_config) setup_driver_config(driver_config) @config = oci_config end |
Instance Attribute Details
#config ⇒ OCI::Config (readonly)
The config used to authenticate to OCI.
37 38 39 |
# File 'lib/kitchen/driver/oci/config.rb', line 37 def config @config end |
Instance Method Details
#compartment ⇒ String
The ocid of the compartment where the Kitchen instance will be created.
-
If compartment_id is specified in the kitchen.yml, that will be returned.
-
If compartment_name is specified in the kitchen.yml, lookup with the Identity API to find the ocid by the compartment name.
60 61 62 63 64 65 66 67 68 |
# File 'lib/kitchen/driver/oci/config.rb', line 60 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_config ⇒ OCI::Config
Creates a new instance of OCI::Config to be used to authenticate to OCI.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/kitchen/driver/oci/config.rb', line 42 def oci_config # OCI::Config is missing this attribute. It is always added so that a security_token_file # present in the selected profile is loaded, which enables auto-detection of session # (RPST) token authentication even when use_token_auth is not explicitly set. OCI::Config.class_eval { attr_accessor :security_token_file } unless OCI::Config.instance_methods.include?(:security_token_file) 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 |