Repository navigation
Expand file tree
/
Copy pathplugins
More file actions
executable file
·75 lines (60 loc) · 3.55 KB
/
Copy pathplugins
File metadata and controls
executable file
·75 lines (60 loc) · 3.55 KB
1
2
3
4
5
6
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env ruby
require 'thor'
require_relative 'lib/schema_downloader'
require_relative 'lib/example_validator'
require_relative 'lib/example_copier'
require_relative 'lib/referenceable_fields'
class Plugins < Thor
class_option :verbose, :type => :boolean
def self.exit_on_failure?
true
end
desc 'download_schemas', 'Downloads the plugins schemas in json format'
option :version, aliases: '-v', type: :string, required: true, desc: 'Kong Version'
option :plugins, aliases: '-p', type: :array, required: true, desc: 'List containing the name of the plugins'
option :host, aliases: '-d', type: :string, default: 'localhost', desc: 'Hostname of the server running the API.'
option :port, aliases: '-h', type: :numeric, default: 8001, desc: 'Port number'
option :destination, aliases: '-dest', type: :string, default: './schemas', desc: 'Destination folder where the schemas will be written'
def download_schemas
puts 'Downloading schemas...'
options[:plugins].each do |plugin|
SchemaDownloader.run!(plugin:, options:)
end
puts 'Done!'
end
desc 'validate_examples', 'Validates an example against the schema'
option :version, aliases: '-v', type: :string, required: true, default: '_index', desc: 'Kong Version'
option :plugins, aliases: '-p', type: :array, required: true, desc: 'List containing the name of the plugins'
option :host, aliases: '-d', type: :string, default: 'localhost', desc: 'Hostname of the server running the API.'
option :port, aliases: '-h', type: :numeric, default: 8001, desc: 'Port number'
option :source, aliases: '-s', type: :string, default: './examples', desc: 'Source folder containing the examples'
def validate_examples
puts 'Validating examples...'
options[:plugins].each do |plugin|
ExampleValidator.run!(plugin:, options:)
end
puts 'Done!'
end
desc 'copy_examples', 'Copy latest examples'
option :version, aliases: '-v', type: :string, required: true, default: '_index', desc: 'Kong Version'
option :plugins, aliases: '-p', type: :array, required: true, desc: 'List containing the name of the plugins'
option :source, aliases: '-s', type: :string, default: './examples', desc: 'Source folder containing the examples'
def copy_examples
puts 'Copying examples...'
options[:plugins].each do |plugin|
ExampleCopier.run!(plugin:, options:)
end
puts 'Done!'
end
desc 'generate_referenceable_fields_list', 'Generates a json object listing all the referenceable fields for each plugin'
option :version, aliases: '-v', type: :string, required: true, desc: 'Kong Version'
option :plugins, aliases: '-p', type: :array, required: true, desc: 'List containing the name of the plugins'
option :source, aliases: '-s', type: :string, default: './schemas', desc: 'Source folder containing the schemas'
option :destination, aliases: '-dest', type: :string, default: './data', desc: 'Destination folder where the json object containing the referenceable fields will be written'
def generate_referenceable_fields_list
puts 'Finding referenceable fields...'
ReferenceableFields.run!(plugins: options[:plugins], options: options)
puts 'Done!'
end
end
Plugins.start(ARGV)