Class: SkullIsland::CLI
Overview
Instance Method Summary
collapse
#migrate_0_14_to_1_1, #migrate_config
Instance Method Details
#export(output_file = '-') ⇒ Object
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
43
44
45
46
|
# File 'lib/skull_island/cli.rb', line 18
def export(output_file = '-')
if output_file == '-'
STDERR.puts '[INFO] Outputting to STDOUT' if options['verbose']
else
full_filename = File.expand_path(output_file)
dirname = File.dirname(full_filename)
unless File.exist?(dirname) && File.ftype(dirname) == 'directory'
raise Exceptions::InvalidArguments, "#{full_filename} is invalid"
end
end
validate_server_version
output = { 'version' => '1.1' }
[
Resources::Certificate,
Resources::Consumer,
Resources::Upstream,
Resources::Service,
Resources::Plugin
].each { |clname| export_class(clname, output) }
if output_file == '-'
STDOUT.puts output.to_yaml
else
File.write(full_filename, output.to_yaml)
end
end
|
#import(input_file = '-') ⇒ Object
#migrate(input_file = '-', output_file = '-') ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/skull_island/cli.rb', line 72
def migrate(input_file = '-', output_file = '-')
raw ||= acquire_input(input_file, options['verbose'])
input = YAML.load(raw)
validate_migrate_version input['version']
output = migrate_config(input)
if output_file == '-'
STDERR.puts '[INFO] Outputting to STDOUT' if options['verbose']
STDOUT.puts output.to_yaml
else
full_filename = File.expand_path(output_file)
dirname = File.dirname(full_filename)
unless File.exist?(dirname) && File.ftype(dirname) == 'directory'
raise Exceptions::InvalidArguments, "#{full_filename} is invalid"
end
File.write(full_filename, output.to_yaml)
end
end
|