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
43
44
45
46
47
|
# File 'lib/xapixctl/connector_cli.rb', line 16
def import(spec_filename)
path = Pathname.new(spec_filename)
unless path.file? && path.readable?
warn "Cannot read #{path}, please check file exists and is readable"
exit 1
end
if options[:schema_import]
say "uploading to update schema import '#{options[:schema_import]}': #{spec_filename}..."
result = prj_connection.update_schema_import(options[:schema_import], spec_filename)
say "updated #{result.dig('resource', 'kind')} #{result.dig('resource', 'id')}"
else
say "uploading as new import: #{spec_filename}..."
result = prj_connection.add_schema_import(spec_filename)
say "created #{result.dig('resource', 'kind')} #{result.dig('resource', 'id')}"
end
[['issues', 'import'], ['validation_issues', 'validation']].each do |key, name|
issues = result.dig('schema_import', 'report', key)
if issues.any?
say "\n#{name} issues:"
shell.indent { issues.each { |issue| say "- #{issue}" } }
end
end
updated_resources = result.dig('schema_import', 'updated_resources')
if updated_resources.any?
say "\nconnectors:"
shell.indent { updated_resources.each { |resource| say "- #{resource['kind']} #{resource['id']}" } }
else
say "\nno connectors created/updated."
end
end
|