Sha256: d5c7c6d9d977d58b33b7a5667a22495a69fd84b60795f73d426cd0e82f18baa1
Contents?: true
Size: 1.26 KB
Versions: 3
Compression:
Stored size: 1.26 KB
Contents
require 'json' require 'yaml' module Seira class Settings DEFAULT_CONFIG_PATH = '.seira.yml'.freeze attr_reader :config_path def initialize(config_path: DEFAULT_CONFIG_PATH) @config_path = config_path end def settings return @_settings if defined?(@_settings) @_settings = parse_settings end def organization_id settings['seira']['organization_id'] end def default_zone settings['seira']['default_zone'] end def valid_apps settings['seira']['valid_apps'] end def valid_cluster_names settings['seira']['clusters'].keys end def clusters settings['seira']['clusters'] end 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, cluster_metadata| next if cluster_metadata['aliases'].empty? return cluster_name if cluster_metadata['aliases'].include?(shorthand) end nil end def project_for_cluster(cluster) settings['seira']['clusters'][cluster]['project'] end private def parse_settings YAML.load_file(config_path) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
seira-0.1.7 | lib/seira/settings.rb |
seira-0.1.6 | lib/seira/settings.rb |
seira-0.1.5 | lib/seira/settings.rb |