Class: Seira::Settings
- Inherits:
-
Object
- Object
- Seira::Settings
- Defined in:
- lib/seira/settings.rb
Constant Summary collapse
- DEFAULT_CONFIG_PATH =
'.seira.yml'.freeze
Instance Attribute Summary collapse
-
#config_path ⇒ Object
readonly
Returns the value of attribute config_path.
Instance Method Summary collapse
- #clusters ⇒ Object
- #default_zone ⇒ Object
- #full_cluster_name_for_shorthand(shorthand) ⇒ Object
-
#initialize(config_path: DEFAULT_CONFIG_PATH) ⇒ Settings
constructor
A new instance of Settings.
- #organization_id ⇒ Object
- #project_for_cluster(cluster) ⇒ Object
- #settings ⇒ Object
- #valid_apps ⇒ Object
- #valid_cluster_names ⇒ Object
Constructor Details
#initialize(config_path: DEFAULT_CONFIG_PATH) ⇒ Settings
Returns a new instance of Settings.
10 11 12 |
# File 'lib/seira/settings.rb', line 10 def initialize(config_path: DEFAULT_CONFIG_PATH) @config_path = config_path end |
Instance Attribute Details
#config_path ⇒ Object (readonly)
Returns the value of attribute config_path.
8 9 10 |
# File 'lib/seira/settings.rb', line 8 def config_path @config_path end |
Instance Method Details
#clusters ⇒ Object
35 36 37 |
# File 'lib/seira/settings.rb', line 35 def clusters settings['seira']['clusters'] end |
#default_zone ⇒ Object
23 24 25 |
# File 'lib/seira/settings.rb', line 23 def default_zone settings['seira']['default_zone'] end |
#full_cluster_name_for_shorthand(shorthand) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/seira/settings.rb', line 39 def full_cluster_name_for_shorthand(shorthand) return shorthand if valid_cluster_names.include?(shorthand) # Try iterating through each cluster to find the relevant alias clusters.each do |cluster_name, | next if ['aliases'].empty? return cluster_name if ['aliases'].include?(shorthand) end nil end |
#organization_id ⇒ Object
19 20 21 |
# File 'lib/seira/settings.rb', line 19 def organization_id settings['seira']['organization_id'] end |
#project_for_cluster(cluster) ⇒ Object
51 52 53 |
# File 'lib/seira/settings.rb', line 51 def project_for_cluster(cluster) settings['seira']['clusters'][cluster]['project'] end |
#settings ⇒ Object
14 15 16 17 |
# File 'lib/seira/settings.rb', line 14 def settings return @_settings if defined?(@_settings) @_settings = parse_settings end |
#valid_apps ⇒ Object
27 28 29 |
# File 'lib/seira/settings.rb', line 27 def valid_apps settings['seira']['valid_apps'] end |
#valid_cluster_names ⇒ Object
31 32 33 |
# File 'lib/seira/settings.rb', line 31 def valid_cluster_names settings['seira']['clusters'].keys end |