7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/rancher/shell/config.rb', line 7
def self.load options = {}
config_file_paths = [
"#{ENV['HOME']}/.rancher-shell.yml",
"#{Dir.pwd}/.rancher-shell.yml",
]
@data = {}
@data['options'] ||= options.dup
@data['projects'] ||= {}
config_file_paths.each do |file_path|
next unless File.exists? file_path
config = YAML.load_file file_path
if config
if config['options']
config['options'].each do |key, value|
@data['options'][key] = value unless options[key]
end
config.delete('options')
end
@data.deep_merge! config
end
end
return unless @data['options']['project']
@data['project'] = @data['projects'][@data['options']['project']]
if @data['project']['options']
@data['project']['options'].each do |key, value|
@data['options'][key] = value unless options[key]
end
end
if @data['options']['stack'] && @data['project']['stacks'] && @data['project']['stacks'][@data['options']['stack']]
if @data['project']['stacks'][@data['options']['stack']]['options']
@data['project']['stacks'][@data['options']['stack']]['options'].each do |key, value|
@data['options'][key] = value unless options[key]
end
end
end
end
|