Class: SkullIsland::CLI
Overview
Instance Method Summary
collapse
#migrate_0_14_to_1_1, #migrate_config
Instance Method Details
#export(output_file = '-') ⇒ Object
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
47
48
|
# File 'lib/skull_island/cli.rb', line 19
def export(output_file = '-')
if output_file == '-'
warn '[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.2' }
output['project'] = options['project'] if options['project']
[
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/skull_island/cli.rb', line 53
def import(input_file = '-')
raw ||= acquire_input(input_file, options['verbose'])
input = YAML.load(raw)
validate_config_version input['version']
import_time = Time.now.utc.to_i
input['project'] = options['project'] if options['project']
[
Resources::Certificate,
Resources::Consumer,
Resources::Upstream,
Resources::Service,
Resources::Plugin
].each { |clname| import_class(clname, input, import_time) }
end
|
#migrate(input_file = '-', output_file = '-') ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/skull_island/cli.rb', line 79
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)
output['project'] = options['project'] if options['project']
if output_file == '-'
warn '[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
|