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
|
# File 'lib/ktools/tools/swap.rb', line 14
def start
unless @subject
files = Dir["#{@kube_path}/*.yml", "#{@kube_path}/*.yaml"]
files.each do |file|
name = File.basename(file).chomp(".yml").chomp(".yaml")
if name == @cfg["cluster"]
puts "-> #{name}".colorize(:yellow)
else
puts "- #{name}"
end
end
else
c_file = "#{@kube_path}/config"
File.delete(c_file) if File.exist?(c_file)
subject_file = check_subject_file
do_fail unless subject_file
FileUtils.cp(subject_file, c_file)
KTools::KDB.update(@cfg, {"cluster" => @subject})
puts "Swapped to #{@subject}."
end
end
|