Class: DigitalOceanInventory::Config
- Inherits:
-
Object
- Object
- DigitalOceanInventory::Config
- Defined in:
- lib/digital_ocean_inventory/config.rb
Defined Under Namespace
Classes: MissingAccessTokenError
Constant Summary collapse
- CONFIG_FILE_PATHS =
%w[ ./digitalocean.yml ~/.ansible/digitalocean.yml /etc/ansible/digitalocean.yml ]
Instance Attribute Summary collapse
-
#cache_max_age ⇒ Object
readonly
Returns the value of attribute cache_max_age.
-
#cache_path ⇒ Object
readonly
Returns the value of attribute cache_path.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#group_by_region ⇒ Object
readonly
Returns the value of attribute group_by_region.
-
#group_by_tag ⇒ Object
readonly
Returns the value of attribute group_by_tag.
-
#ignore_hosts ⇒ Object
readonly
Returns the value of attribute ignore_hosts.
-
#ignore_tags ⇒ Object
readonly
Returns the value of attribute ignore_tags.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#select_tags ⇒ Object
readonly
Returns the value of attribute select_tags.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #cache_file ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/digital_ocean_inventory/config.rb', line 25 def initialize conf = load_from_file.merge load_from_env @token = conf[:access_token] raise MissingAccessTokenError unless @token @client = DropletKit::Client.new access_token: @token @project = conf.fetch :project, "default" @select_tags = conf.fetch :select_tags, [] @ignore_tags = conf.fetch :ignore_tags, [] @ignore_hosts = conf.fetch :ignore_hosts, [] @group_by_region = conf.fetch :group_by_region, true @group_by_tag = conf.fetch :group_by_tag, true @cache_path = conf.fetch :cache_path, "." @cache_max_age = conf.fetch :cache_max_age, 900 end |
Instance Attribute Details
#cache_max_age ⇒ Object (readonly)
Returns the value of attribute cache_max_age.
14 15 16 |
# File 'lib/digital_ocean_inventory/config.rb', line 14 def cache_max_age @cache_max_age end |
#cache_path ⇒ Object (readonly)
Returns the value of attribute cache_path.
14 15 16 |
# File 'lib/digital_ocean_inventory/config.rb', line 14 def cache_path @cache_path end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
14 15 16 |
# File 'lib/digital_ocean_inventory/config.rb', line 14 def client @client end |
#group_by_region ⇒ Object (readonly)
Returns the value of attribute group_by_region.
14 15 16 |
# File 'lib/digital_ocean_inventory/config.rb', line 14 def group_by_region @group_by_region end |
#group_by_tag ⇒ Object (readonly)
Returns the value of attribute group_by_tag.
14 15 16 |
# File 'lib/digital_ocean_inventory/config.rb', line 14 def group_by_tag @group_by_tag end |
#ignore_hosts ⇒ Object (readonly)
Returns the value of attribute ignore_hosts.
14 15 16 |
# File 'lib/digital_ocean_inventory/config.rb', line 14 def ignore_hosts @ignore_hosts end |
#ignore_tags ⇒ Object (readonly)
Returns the value of attribute ignore_tags.
14 15 16 |
# File 'lib/digital_ocean_inventory/config.rb', line 14 def @ignore_tags end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
14 15 16 |
# File 'lib/digital_ocean_inventory/config.rb', line 14 def project @project end |
#select_tags ⇒ Object (readonly)
Returns the value of attribute select_tags.
14 15 16 |
# File 'lib/digital_ocean_inventory/config.rb', line 14 def @select_tags end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
14 15 16 |
# File 'lib/digital_ocean_inventory/config.rb', line 14 def token @token end |
Instance Method Details
#cache_file ⇒ Object
43 44 45 |
# File 'lib/digital_ocean_inventory/config.rb', line 43 def cache_file "#{cache_path}/.ansible_digital_ocean_inventory_cache.json" end |