idcfcloud 0.2.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +12 -0
  3. data/.rubocop.yml +12 -2
  4. data/README.md +15 -4
  5. data/idcfcloud.gemspec +7 -8
  6. data/lib/idcf/cli/command/morio.rb +4 -4
  7. data/lib/idcf/cli/conf/const.rb +32 -29
  8. data/lib/idcf/cli/controller/base.rb +50 -23
  9. data/lib/idcf/cli/controller/cdn.rb +3 -0
  10. data/lib/idcf/cli/controller/compute.rb +15 -1
  11. data/lib/idcf/cli/controller/extend/command.rb +25 -2
  12. data/lib/idcf/cli/controller/extend/search_module.rb +0 -10
  13. data/lib/idcf/cli/controller/extend/util.rb +12 -0
  14. data/lib/idcf/cli/controller/include/client.rb +1 -1
  15. data/lib/idcf/cli/controller/include/command.rb +1 -1
  16. data/lib/idcf/cli/controller/include/util.rb +3 -5
  17. data/lib/idcf/cli/controller/include/validate.rb +1 -1
  18. data/lib/idcf/cli/extend/configure.rb +2 -4
  19. data/lib/idcf/cli/extend/update.rb +20 -20
  20. data/lib/idcf/cli/extend/update_file.rb +3 -3
  21. data/lib/idcf/cli/gem_ext/idcf/json_hyper_schema/expands/link_info_base_extension.rb +25 -9
  22. data/lib/idcf/cli/gem_ext/thor/init_util.rb +6 -3
  23. data/lib/idcf/cli/index.rb +17 -5
  24. data/lib/idcf/cli/lib/api.rb +5 -4
  25. data/lib/idcf/cli/lib/configure.rb +2 -2
  26. data/lib/idcf/cli/lib/convert/filter/field_filter.rb +9 -12
  27. data/lib/idcf/cli/lib/convert/filter/json_path_filter.rb +1 -1
  28. data/lib/idcf/cli/lib/convert/formatter/base.rb +1 -2
  29. data/lib/idcf/cli/lib/convert/formatter/csv_format.rb +15 -32
  30. data/lib/idcf/cli/lib/convert/formatter/json_format.rb +1 -1
  31. data/lib/idcf/cli/lib/convert/formatter/table_format.rb +2 -2
  32. data/lib/idcf/cli/lib/convert/formatter/xml_format.rb +1 -1
  33. data/lib/idcf/cli/lib/convert/helper.rb +16 -5
  34. data/lib/idcf/cli/lib/document.rb +42 -0
  35. data/lib/idcf/cli/lib/util/cli_file.rb +1 -1
  36. data/lib/idcf/cli/lib/util/cli_logger.rb +3 -3
  37. data/lib/idcf/cli/lib/util/ini_conf.rb +2 -2
  38. data/lib/idcf/cli/lib/util/input.rb +40 -5
  39. data/lib/idcf/cli/lib/util/yml_conf.rb +1 -1
  40. data/lib/idcf/cli/service/base.rb +6 -6
  41. data/lib/idcf/cli/service/ilb/base_server_for_protocol.rb +22 -18
  42. data/lib/idcf/cli/validate/custom/month_check_validator.rb +1 -1
  43. data/lib/idcf/cli/validate/custom/require_relation_validator.rb +2 -2
  44. data/lib/idcf/cli/validate/define/base.rb +3 -2
  45. data/lib/idcf/cli/version.rb +1 -1
  46. metadata +45 -44
@@ -5,20 +5,29 @@ module Idcf
5
5
  # input
6
6
  class Input
7
7
  class << self
8
+ # qa
9
+ #
10
+ # @param title [String]
11
+ # @param setting [Hash]
12
+ # @param nd [String]
13
+ # @return [String]
8
14
  def qa(title, setting, nd = '')
9
15
  loop do
10
- v = setting.class == Hash ? setting[:list] : nil
11
- v = v.nil? ? [] : v
12
- set_s = v.empty? ? '' : "(#{v.join('/')})"
13
- puts "#{title}#{set_s}[#{nd.empty? ? 'NONE' : nd}]"
16
+ v = qa_setting_list(setting)
17
+ qa_puts_question(title, nd, v)
14
18
  result = qa_answer_input(v, nd)
15
19
  return result unless result.empty?
16
20
  end
17
21
  end
18
22
 
23
+ # qa_answer_input
24
+ #
25
+ # @param list [Array]
26
+ # @param nd [String]
27
+ # @return [String]
19
28
  def qa_answer_input(list, nd = '')
20
29
  loop do
21
- res = STDIN.gets.strip
30
+ res = STDIN.gets.strip
22
31
  result = res.empty? ? nd : res
23
32
  return result if qa_answer?(result, list)
24
33
  puts "from this [#{list.join('/')}]"
@@ -28,6 +37,32 @@ module Idcf
28
37
 
29
38
  protected
30
39
 
40
+ # qa_puts_question
41
+ #
42
+ # @param title [String]
43
+ # @param nd [String]
44
+ # @param set_list [Array]
45
+ # @return nil
46
+ def qa_puts_question(title, nd, set_list)
47
+ set_s = set_list.blank? ? '' : "(#{set_list.join('/')})"
48
+ puts "#{title}#{set_s}[#{nd.empty? ? 'NONE' : nd}]"
49
+ nil
50
+ end
51
+
52
+ # qa_setting_list
53
+ #
54
+ # @param setting [Hash]
55
+ # @return [Array]
56
+ def qa_setting_list(setting)
57
+ v = setting.class == Hash ? setting[:list] : nil
58
+ v.nil? ? [] : v
59
+ end
60
+
61
+ # qa_answer?
62
+ #
63
+ # @param val [String]
64
+ # @param list [Array]
65
+ # @return [Boolean]
31
66
  def qa_answer?(val, list)
32
67
  return true if list.nil? || list.empty?
33
68
  return true if Regexp.new("\\A(#{list.join('|')})\\Z") =~ val
@@ -38,7 +38,7 @@ module Idcf
38
38
  end
39
39
 
40
40
  result
41
- rescue
41
+ rescue StandardError => _e
42
42
  raise Idcf::Cli::Error::CliError, "Error: could not read '#{path}'"
43
43
  end
44
44
  end
@@ -8,9 +8,9 @@ module Idcf
8
8
  ARG_TYPE_OPT = :opt
9
9
  ARG_TYPE_REST = :rest
10
10
  HELP_FORMAT = {
11
- ARG_TYPE_REQ => '<%s>',
12
- ARG_TYPE_OPT => '[%s]',
13
- ARG_TYPE_REST => '[%s ...]'
11
+ ARG_TYPE_REQ => '<%<name>s>',
12
+ ARG_TYPE_OPT => '[%<name>s]',
13
+ ARG_TYPE_REST => '[%<name>s ...]'
14
14
  }.freeze
15
15
  attr_reader :last_command, :last_command_args
16
16
  include Idcf::Cli::Lib::Include::RecurringCalling
@@ -51,7 +51,7 @@ module Idcf
51
51
  valid_params.each do |param|
52
52
  f = HELP_FORMAT[param[0]]
53
53
  next if f.nil?
54
- cp << format(f, param[1])
54
+ cp << format(f, name: param[1])
55
55
  end
56
56
  cp.join(' ')
57
57
  end
@@ -72,7 +72,7 @@ module Idcf
72
72
  # @return Boolean
73
73
  def target_param?(name)
74
74
  val = name.to_s
75
- exclusion_list = %w(api o)
75
+ exclusion_list = %w[api o]
76
76
  return false if exclusion_list.include?(val)
77
77
  return false if val[0] == '_'
78
78
  true
@@ -107,7 +107,7 @@ module Idcf
107
107
  opt_cnt = method_option_cnt(param)
108
108
 
109
109
  min = p_cnt - opt_cnt
110
- msg = format('Argument: %s', self.class.make_param_s)
110
+ msg = format('Argument: %<arg>s', arg: self.class.make_param_s)
111
111
  cli_error msg unless arg_size.between?(min, p_cnt)
112
112
  true
113
113
  end
@@ -12,15 +12,15 @@ module Idcf
12
12
  #
13
13
  # @param api [Idcf::Ilb::Lib::Api]
14
14
  # @param o [Hash] options
15
- # @option lb_id [String]
16
- # @option protocol [Stirng] http
17
- # @option protocol_port [int] 80
18
- # @option params [Hash] {ipaddress: '0.0.0.0', port: 80}
15
+ # @param lb_id [String]
16
+ # @param protocol [Stirng] http
17
+ # @param protocol_port [int] 80
18
+ # @param params [Hash] {ipaddress: '0.0.0.0', port: 80}
19
19
  def do(api, o, lb_id, protocol, protocol_port, params)
20
20
  @api = api
21
21
  @options = o
22
22
  lb = search_lb(lbs, lb_id)
23
- config = search_config(lb, protocol, protocol_port)
23
+ config = search_config(lb['configs'], protocol, protocol_port)
24
24
 
25
25
  if config.nil?
26
26
  not_param = o[:protocol].nil? ? 'conf_id' : 'protocol'
@@ -64,20 +64,19 @@ module Idcf
64
64
 
65
65
  # config search
66
66
  #
67
- # @param lb_info [Hash]
68
- # @param o [Hash]
67
+ # @param configs [Hash]
68
+ # @param protocol [String]
69
+ # @param p_port [String]
69
70
  # @return Hash
70
71
  # @raise
71
- def search_config(lb_info, protocol, p_port)
72
- lb_info['configs'].each do |v|
72
+ def search_config(configs, protocol, p_port)
73
+ result = nil
74
+ configs.each do |v|
73
75
  next unless target_config?(v, protocol, p_port)
74
- unless v['state'].casecmp('running').zero?
75
- msg = 'The operation is impossible because the target is currently being processed'
76
- cli_error msg
77
- end
78
- return v
76
+ result = v
77
+ break
79
78
  end
80
- nil
79
+ result
81
80
  end
82
81
 
83
82
  # is target config
@@ -86,9 +85,14 @@ module Idcf
86
85
  # @param protocol [String]
87
86
  # @param p_port [String]
88
87
  # @return boolean
89
- def target_config?(config, purotocol, p_port)
90
- config['frontend_protocol'] == purotocol &&
91
- config['port'].to_s == p_port.to_s
88
+ # @raise
89
+ def target_config?(config, protocol, p_port)
90
+ unless config['frontend_protocol'] == protocol && config['port'].to_s == p_port.to_s
91
+ return false
92
+ end
93
+ return true if config['state'].casecmp('running').zero?
94
+ msg = 'The operation is impossible because the target is currently being processed'
95
+ cli_error msg
92
96
  end
93
97
  end
94
98
  end
@@ -29,7 +29,7 @@ module Idcf
29
29
  def valid?(val)
30
30
  Date.parse("#{val}-01")
31
31
  true
32
- rescue
32
+ rescue StandardError => _e
33
33
  false
34
34
  end
35
35
  end
@@ -7,7 +7,7 @@ module Idcf
7
7
  # require relation validator
8
8
  class RequireRelationValidator < ActiveModel::EachValidator
9
9
  MESSAGES = {
10
- message: 'A related parameter isn\'t input. (%s)'
10
+ message: 'A related parameter isn\'t input. (%<msg>s)'
11
11
  }.freeze
12
12
 
13
13
  def validate(record)
@@ -16,7 +16,7 @@ module Idcf
16
16
  nones = make_nones(record)
17
17
  return if nones.empty?
18
18
 
19
- msg = MESSAGES[:message] % nones.join('/')
19
+ msg = format(MESSAGES[:message], msg: nones.join('/'))
20
20
  record.errors.add(nones.first, msg, {})
21
21
  end
22
22
 
@@ -16,12 +16,13 @@ module Idcf
16
16
  :no_ssl,
17
17
  :no_vssl,
18
18
  :json_path,
19
- :fields
19
+ :fields,
20
+ :version
20
21
 
21
22
  validates :output,
22
23
  allow_blank: true,
23
24
  inclusion: {
24
- in: %w(table json xml csv),
25
+ in: %w[table json xml csv],
25
26
  message: 'from this [table/json/xml/csv]'
26
27
  }
27
28
 
@@ -1,5 +1,5 @@
1
1
  module Idcf
2
2
  module Cli
3
- VERSION = '0.2.2'.freeze
3
+ VERSION = '1.0.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idcfcloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - IDC Frontier Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-08 00:00:00.000000000 Z
11
+ date: 2018-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -119,157 +119,157 @@ dependencies:
119
119
  - !ruby/object:Gem::Version
120
120
  version: 4.2.3
121
121
  - !ruby/object:Gem::Dependency
122
- name: inifile
122
+ name: builder
123
123
  requirement: !ruby/object:Gem::Requirement
124
124
  requirements:
125
125
  - - "~>"
126
126
  - !ruby/object:Gem::Version
127
- version: '3.0'
128
- - - ">="
129
- - !ruby/object:Gem::Version
130
- version: 3.0.0
127
+ version: '3.1'
131
128
  type: :runtime
132
129
  prerelease: false
133
130
  version_requirements: !ruby/object:Gem::Requirement
134
131
  requirements:
135
132
  - - "~>"
136
133
  - !ruby/object:Gem::Version
137
- version: '3.0'
138
- - - ">="
139
- - !ruby/object:Gem::Version
140
- version: 3.0.0
134
+ version: '3.1'
141
135
  - !ruby/object:Gem::Dependency
142
- name: thor
136
+ name: CFPropertyList
143
137
  requirement: !ruby/object:Gem::Requirement
144
138
  requirements:
145
139
  - - "~>"
146
140
  - !ruby/object:Gem::Version
147
- version: 0.19.4
141
+ version: 2.3.5
148
142
  type: :runtime
149
143
  prerelease: false
150
144
  version_requirements: !ruby/object:Gem::Requirement
151
145
  requirements:
152
146
  - - "~>"
153
147
  - !ruby/object:Gem::Version
154
- version: 0.19.4
148
+ version: 2.3.5
155
149
  - !ruby/object:Gem::Dependency
156
- name: builder
150
+ name: facter
157
151
  requirement: !ruby/object:Gem::Requirement
158
152
  requirements:
159
153
  - - "~>"
160
154
  - !ruby/object:Gem::Version
161
- version: '3.1'
155
+ version: 2.5.1
162
156
  type: :runtime
163
157
  prerelease: false
164
158
  version_requirements: !ruby/object:Gem::Requirement
165
159
  requirements:
166
160
  - - "~>"
167
161
  - !ruby/object:Gem::Version
168
- version: '3.1'
162
+ version: 2.5.1
169
163
  - !ruby/object:Gem::Dependency
170
- name: kosi
164
+ name: idcf-faraday_middleware
171
165
  requirement: !ruby/object:Gem::Requirement
172
166
  requirements:
173
167
  - - "~>"
174
168
  - !ruby/object:Gem::Version
175
- version: '1.0'
176
- - - ">="
177
- - !ruby/object:Gem::Version
178
- version: 1.0.0
169
+ version: 0.0.2
179
170
  type: :runtime
180
171
  prerelease: false
181
172
  version_requirements: !ruby/object:Gem::Requirement
182
173
  requirements:
183
174
  - - "~>"
184
175
  - !ruby/object:Gem::Version
185
- version: '1.0'
186
- - - ">="
187
- - !ruby/object:Gem::Version
188
- version: 1.0.0
176
+ version: 0.0.2
189
177
  - !ruby/object:Gem::Dependency
190
- name: open_uri_redirections
178
+ name: idcf-json_hyper_schema
191
179
  requirement: !ruby/object:Gem::Requirement
192
180
  requirements:
193
181
  - - "~>"
194
182
  - !ruby/object:Gem::Version
195
- version: 0.2.1
183
+ version: 0.2.0
196
184
  type: :runtime
197
185
  prerelease: false
198
186
  version_requirements: !ruby/object:Gem::Requirement
199
187
  requirements:
200
188
  - - "~>"
201
189
  - !ruby/object:Gem::Version
202
- version: 0.2.1
190
+ version: 0.2.0
203
191
  - !ruby/object:Gem::Dependency
204
- name: idcf-json_hyper_schema
192
+ name: inifile
205
193
  requirement: !ruby/object:Gem::Requirement
206
194
  requirements:
207
195
  - - "~>"
208
196
  - !ruby/object:Gem::Version
209
- version: 0.1.0
197
+ version: '3.0'
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: 3.0.0
210
201
  type: :runtime
211
202
  prerelease: false
212
203
  version_requirements: !ruby/object:Gem::Requirement
213
204
  requirements:
214
205
  - - "~>"
215
206
  - !ruby/object:Gem::Version
216
- version: 0.1.0
207
+ version: '3.0'
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ version: 3.0.0
217
211
  - !ruby/object:Gem::Dependency
218
- name: idcf-faraday_middleware
212
+ name: jsonpath
219
213
  requirement: !ruby/object:Gem::Requirement
220
214
  requirements:
221
215
  - - "~>"
222
216
  - !ruby/object:Gem::Version
223
- version: 0.0.2
217
+ version: 0.8.10
224
218
  type: :runtime
225
219
  prerelease: false
226
220
  version_requirements: !ruby/object:Gem::Requirement
227
221
  requirements:
228
222
  - - "~>"
229
223
  - !ruby/object:Gem::Version
230
- version: 0.0.2
224
+ version: 0.8.10
231
225
  - !ruby/object:Gem::Dependency
232
- name: jsonpath
226
+ name: kosi
233
227
  requirement: !ruby/object:Gem::Requirement
234
228
  requirements:
235
229
  - - "~>"
236
230
  - !ruby/object:Gem::Version
237
- version: 0.8.10
231
+ version: '1.0'
232
+ - - ">="
233
+ - !ruby/object:Gem::Version
234
+ version: 1.0.0
238
235
  type: :runtime
239
236
  prerelease: false
240
237
  version_requirements: !ruby/object:Gem::Requirement
241
238
  requirements:
242
239
  - - "~>"
243
240
  - !ruby/object:Gem::Version
244
- version: 0.8.10
241
+ version: '1.0'
242
+ - - ">="
243
+ - !ruby/object:Gem::Version
244
+ version: 1.0.0
245
245
  - !ruby/object:Gem::Dependency
246
- name: facter
246
+ name: open_uri_redirections
247
247
  requirement: !ruby/object:Gem::Requirement
248
248
  requirements:
249
249
  - - "~>"
250
250
  - !ruby/object:Gem::Version
251
- version: 2.5.1
251
+ version: 0.2.1
252
252
  type: :runtime
253
253
  prerelease: false
254
254
  version_requirements: !ruby/object:Gem::Requirement
255
255
  requirements:
256
256
  - - "~>"
257
257
  - !ruby/object:Gem::Version
258
- version: 2.5.1
258
+ version: 0.2.1
259
259
  - !ruby/object:Gem::Dependency
260
- name: CFPropertyList
260
+ name: thor
261
261
  requirement: !ruby/object:Gem::Requirement
262
262
  requirements:
263
263
  - - "~>"
264
264
  - !ruby/object:Gem::Version
265
- version: 2.3.5
265
+ version: 0.19.4
266
266
  type: :runtime
267
267
  prerelease: false
268
268
  version_requirements: !ruby/object:Gem::Requirement
269
269
  requirements:
270
270
  - - "~>"
271
271
  - !ruby/object:Gem::Version
272
- version: 2.3.5
272
+ version: 0.19.4
273
273
  description: IDCF Cli
274
274
  email: []
275
275
  executables:
@@ -328,6 +328,7 @@ files:
328
328
  - lib/idcf/cli/lib/convert/formatter/table_format.rb
329
329
  - lib/idcf/cli/lib/convert/formatter/xml_format.rb
330
330
  - lib/idcf/cli/lib/convert/helper.rb
331
+ - lib/idcf/cli/lib/document.rb
331
332
  - lib/idcf/cli/lib/include/recurring_calling.rb
332
333
  - lib/idcf/cli/lib/util/cli_file.rb
333
334
  - lib/idcf/cli/lib/util/cli_logger.rb