class Vidar::Config
Constants
- DEFAULT_BRANCHES
- DEFAULT_MANIFEST_FILE
- DEFAULT_OPTIONS
Attributes
data[R]
manifest_file[W]
Public Class Methods
branches()
click to toggle source
# File lib/vidar/config.rb, line 77 def branches `git for-each-ref --format='%(refname:short)' refs/heads/*`.split("\n") end
build_url()
click to toggle source
# File lib/vidar/config.rb, line 56 def build_url value = ENV[get(:build_env).to_s] || get(:build_url) value&.empty? ? nil : value end
default_branch?()
click to toggle source
# File lib/vidar/config.rb, line 81 def default_branch? get!(:current_branch) == get!(:default_branch) end
deploy_config()
click to toggle source
# File lib/vidar/config.rb, line 61 def deploy_config deployments = get(:deployments) deployments = {} unless deployments.is_a?(Hash) deployment = deployments[get!(:kubectl_context)] if deployment.nil? Log.error "ERROR: could not find deployment config for #{get!(:kubectl_context)} context" return nil end deployment.transform_keys!(&:to_sym) deployment.transform_values! { |value| Vidar::Interpolation.call(value, self) } DeployConfig.new(deployment) end
ensure_file_exist!(file_path)
click to toggle source
# File lib/vidar/config.rb, line 34 def ensure_file_exist!(file_path) fail(MissingManifestFileError, file_path) unless File.exist?(file_path) end
get(key)
click to toggle source
# File lib/vidar/config.rb, line 42 def get(key) load unless loaded? value = @data[key.to_s] || DEFAULT_OPTIONS[key.to_sym]&.call return value unless value.is_a?(String) Vidar::Interpolation.call(value, self) end
get!(key)
click to toggle source
# File lib/vidar/config.rb, line 52 def get!(key) get(key) || fail(MissingConfigError, key) end
load(file_path = manifest_file)
click to toggle source
# File lib/vidar/config.rb, line 23 def load(file_path = manifest_file) ensure_file_exist!(file_path) @data = YAML.load_file(file_path) @loaded = true end
loaded?()
click to toggle source
# File lib/vidar/config.rb, line 38 def loaded? @loaded end
manifest_file()
click to toggle source
# File lib/vidar/config.rb, line 30 def manifest_file @manifest_file || DEFAULT_MANIFEST_FILE end