steplib 0.9.0.9 → 0.9.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66bb253b9b4d908a32cc28ffb1f2b671d3c53848
4
- data.tar.gz: 17f4d9fc6d09322e655d0e4d51ef3358981ca007
3
+ metadata.gz: 29beea916964360158c55afd643599b4c2cbacd1
4
+ data.tar.gz: 9b4b97d934c619c98f04b5625cf00076ac708892
5
5
  SHA512:
6
- metadata.gz: 5e2534c38514f8509787b55cd493b8c5abbaf1e276826d97b25006ee7abb5c7672667d8999ee440ccbbe59168344b672534437d18a69bf10d16be7976bf61eab
7
- data.tar.gz: 2a3c4bbba3dd0801a0fc0ffa5d7f7d9c9d25bbcd29c84dd466ed8bc5a8f74fd2e8930d8364462b8c70453248baec5cad6f64908fb03c41b336d0582b293256c8
6
+ metadata.gz: 664338f0de934c201ec60eac49e04200a609337945e9f63aad4d462b4b1dcdf4731da1cb85f3b31c8c83b19282043b95b59b2709259abdc71d472e74effd1f57
7
+ data.tar.gz: decd7a09acf49380bf5b52ef7958a17aed2cce998dc315ddf6aea250f297c06447bb32f9ce2494dd3675b840ed8b0c4fef045d7ad308021a92877845b8831e86
@@ -16,6 +16,7 @@ module Steplib
16
16
  {key: 'type_tags', value: []},
17
17
  {key: 'inputs', value: []},
18
18
  {key: 'outputs', value: []},
19
+ {key: 'log_highlights', value: []},
19
20
  ])
20
21
  #
21
22
  # inputs
@@ -63,6 +63,12 @@ module Steplib
63
63
  a_step_output,
64
64
  required_step_version_outputs_properties_with_types().map { |e| e.first })
65
65
  end
66
+ # log_highlights
67
+ step_version_data['log_highlights'] = step_version_data['log_highlights'].map do |a_step_log_highlight|
68
+ HashUtils.whitelist(
69
+ a_step_log_highlight,
70
+ required_step_version_log_highlights_properties_with_types().map { |e| e.first })
71
+ end
66
72
  return step_version_data
67
73
  end
68
74
 
@@ -85,11 +91,18 @@ module Steplib
85
91
  ['is_always_run', ABooleanValue],
86
92
  ['inputs', Array],
87
93
  ['outputs', Array],
94
+ ['log_highlights', Array],
95
+ ]
96
+ end
97
+
98
+ def optional_step_version_properties_with_types
99
+ return [
100
+ ['icon_url_256', String],
88
101
  ]
89
102
  end
90
103
 
91
104
  def optional_step_version_properties
92
- return ['icon_url_256']
105
+ return optional_step_version_properties_with_types().map { |e| e.first }
93
106
  end
94
107
 
95
108
  def required_step_version_source_properties_with_types
@@ -117,6 +130,13 @@ module Steplib
117
130
  ]
118
131
  end
119
132
 
133
+ def required_step_version_log_highlights_properties_with_types
134
+ return [
135
+ ['search_pattern', String],
136
+ ['highlight_type', String]
137
+ ]
138
+ end
139
+
120
140
  def validate_step_version!(step_version_data)
121
141
  # whitelist
122
142
  step_version_data = whitelist_step_version(step_version_data)
@@ -126,10 +146,14 @@ module Steplib
126
146
  required_step_version_properties_with_types()
127
147
  )
128
148
 
129
- # optional - can be nil
149
+ # optional
130
150
  step_version_data = HashUtils.set_missing_defaults(
131
151
  step_version_data,
132
- [{key: 'icon_url_256', value: nil}])
152
+ [
153
+ {key: 'icon_url_256', value: nil},
154
+ {key: 'log_highlights', value: []}
155
+ ]
156
+ )
133
157
 
134
158
  HashUtils.check_required_attributes_and_types!(
135
159
  step_version_data['source'],
@@ -171,6 +195,14 @@ module Steplib
171
195
  required_step_version_outputs_properties_with_types()
172
196
  )
173
197
  end
198
+
199
+ a_log_highlights = step_version_data['log_highlights']
200
+ a_log_highlights.each do |a_log_highlight_itm|
201
+ HashUtils.check_required_attributes_and_types!(
202
+ a_log_highlight_itm,
203
+ required_step_version_log_highlights_properties_with_types()
204
+ )
205
+ end
174
206
  end
175
207
 
176
208
  end
@@ -47,6 +47,7 @@ module Steplib
47
47
  # main arrays
48
48
  {key: 'inputs', value: []},
49
49
  {key: 'outputs', value: []},
50
+ {key: 'log_highlights', value: []},
50
51
  ])
51
52
  workflow_step_data['inputs'] = workflow_step_data['inputs'].map { |a_step_inp|
52
53
  a_step_inp = HashUtils.set_missing_defaults(a_step_inp, [
@@ -175,4 +176,4 @@ module Steplib
175
176
 
176
177
  end
177
178
  end
178
- end
179
+ end
@@ -1,20 +1,69 @@
1
1
  require_relative 'hash_utils'
2
+ require_relative 'steplib_validator'
2
3
 
3
4
  module Steplib
4
5
  class WorkflowValidator
5
6
  class << self
6
7
 
8
+ def whitelist_workflow(workflow_data)
9
+ whitelisted_data = HashUtils.whitelist(workflow_data,
10
+ only_attributes(allowed_top_level_attributes_with_types())
11
+ )
12
+
13
+ whitelisted_data['environments'] = whitelisted_data['environments'].map do |an_env|
14
+ whitelist_workflow_environment(an_env)
15
+ end
16
+
17
+ whitelisted_data['steps'] = whitelisted_data['steps'].map do |a_step_version|
18
+ whitelist_workflow_step_version(a_step_version)
19
+ end
20
+
21
+ return whitelisted_data
22
+ end
23
+
24
+ def whitelist_workflow_environment(workflow_env_data)
25
+ whitelisted_data = HashUtils.whitelist(workflow_env_data,
26
+ only_attributes(allowed_environment_attributes_with_types())
27
+ )
28
+ return whitelisted_data
29
+ end
30
+
31
+ def whitelist_workflow_step_version(workflow_step_version_data)
32
+ whitelisted_data = HashUtils.whitelist(workflow_step_version_data,
33
+ only_attributes(allowed_step_version_attributes_with_types())
34
+ )
35
+ whitelisted_data['inputs'] = whitelisted_data['inputs'].map do |a_step_input|
36
+ whitelist_workflow_step_version_input(a_step_input)
37
+ end
38
+ whitelisted_data['outputs'] = whitelisted_data['outputs'].map do |a_step_output|
39
+ whitelist_workflow_step_version_output(a_step_output)
40
+ end
41
+ return whitelisted_data
42
+ end
43
+
44
+ def whitelist_workflow_step_version_input(workflow_step_version_input_data)
45
+ whitelisted_data = HashUtils.whitelist(workflow_step_version_input_data,
46
+ only_attributes(allowed_step_version_input_attributes_with_types())
47
+ )
48
+ return whitelisted_data
49
+ end
50
+
51
+ def whitelist_workflow_step_version_output(workflow_step_version_output_data)
52
+ whitelisted_data = HashUtils.whitelist(workflow_step_version_output_data,
53
+ only_attributes(allowed_step_version_output_attributes_with_types())
54
+ )
55
+ return whitelisted_data
56
+ end
57
+
7
58
  def validate_workflow!(workflow_data)
8
59
  expected_format_version = '0.9.0'
9
60
  if workflow_data['format_version'] != expected_format_version
10
61
  raise "Invalid format_version, expected (#{expected_format_version}) got (#{workflow_data['format_version']})"
11
62
  end
12
63
 
13
- HashUtils.check_required_attributes_and_types!(workflow_data, [
14
- ['format_version', String],
15
- ['environments', Array],
16
- ['steps', Array]
17
- ])
64
+ HashUtils.check_required_attributes_and_types!(workflow_data,
65
+ required_top_level_attributes_with_types()
66
+ )
18
67
 
19
68
  envs_arr = workflow_data['environments']
20
69
  envs_arr.each do |a_env_data|
@@ -28,35 +77,13 @@ module Steplib
28
77
  end
29
78
 
30
79
  def validate_workflow_environment!(env_item_data)
31
- HashUtils.check_required_attributes_and_types!(env_item_data, [
32
- ['title', String],
33
- ['mapped_to', String],
34
- ['is_expand', ABooleanValue],
35
- ['value', String],
36
- ])
80
+ HashUtils.check_required_attributes_and_types!(env_item_data,
81
+ required_environment_attributes_with_types())
37
82
  end
38
83
 
39
84
  def validate_workflow_step!(workflow_step_data)
40
- HashUtils.check_required_attributes_and_types!(workflow_step_data, [
41
- ['position_in_workflow', Fixnum],
42
- ['is_always_run', ABooleanValue],
43
- # auto generated
44
- ['id', String],
45
- ['steplib_source', String],
46
- ['version_tag', String],
47
- # data from step.yml
48
- ['name', String],
49
- ['description', String],
50
- ['website', String],
51
- ['fork_url', String],
52
- ['source', Hash],
53
- ['host_os_tags', Array],
54
- ['project_type_tags', Array],
55
- ['type_tags', Array],
56
- ['is_requires_admin_user', ABooleanValue],
57
- ['inputs', Array],
58
- ['outputs', Array],
59
- ])
85
+ HashUtils.check_required_attributes_and_types!(workflow_step_data,
86
+ required_step_version_attributes_with_types())
60
87
 
61
88
  # optional - can be nil
62
89
  workflow_step_data = HashUtils.set_missing_defaults(
@@ -84,16 +111,9 @@ module Steplib
84
111
 
85
112
  a_inputs = workflow_step_data['inputs']
86
113
  a_inputs.each do |a_input_itm|
87
- HashUtils.check_required_attributes_and_types!(a_input_itm, [
88
- ['title', String],
89
- ['description', String],
90
- ['mapped_to', String],
91
- ['is_expand', ABooleanValue],
92
- ['is_required', ABooleanValue],
93
- ['value_options', Array],
94
- ['value', String],
95
- ['is_dont_change_value', ABooleanValue]
96
- ])
114
+ HashUtils.check_required_attributes_and_types!(a_input_itm,
115
+ required_step_version_input_attributes()
116
+ )
97
117
 
98
118
  a_value_options = a_input_itm['value_options']
99
119
  a_value_options.each { |a_value_option|
@@ -103,14 +123,75 @@ module Steplib
103
123
 
104
124
  a_outputs = workflow_step_data['outputs']
105
125
  a_outputs.each do |a_output_itm|
106
- HashUtils.check_required_attributes_and_types!(a_output_itm, [
107
- ['title', String],
108
- ['description', String],
109
- ['mapped_to', String]
110
- ])
126
+ HashUtils.check_required_attributes_and_types!(a_output_itm,
127
+ required_step_version_output_attributes())
111
128
  end
112
129
  end
113
130
 
131
+
132
+ #
133
+ # required and allowed properties
134
+
135
+ def required_top_level_attributes_with_types
136
+ return [
137
+ ['format_version', String],
138
+ ['environments', Array],
139
+ ['steps', Array]
140
+ ]
141
+ end
142
+
143
+ def allowed_top_level_attributes_with_types
144
+ return required_top_level_attributes_with_types().concat([
145
+ ['meta', Hash]
146
+ ])
147
+ end
148
+
149
+ def required_environment_attributes_with_types
150
+ return [
151
+ ['title', String],
152
+ ['mapped_to', String],
153
+ ['is_expand', ABooleanValue],
154
+ ['value', String],
155
+ ]
156
+ end
157
+
158
+ def allowed_environment_attributes_with_types
159
+ return required_environment_attributes_with_types()
160
+ end
161
+
162
+ def required_step_version_attributes_with_types
163
+ return [
164
+ ['position_in_workflow', Fixnum],
165
+ ['is_always_run', ABooleanValue],
166
+ ].concat Steplib::SteplibValidator.required_step_version_properties_with_types()
167
+ end
168
+
169
+ def allowed_step_version_attributes_with_types
170
+ return required_step_version_attributes_with_types().concat(
171
+ Steplib::SteplibValidator.optional_step_version_properties_with_types()
172
+ )
173
+ end
174
+
175
+ def required_step_version_input_attributes
176
+ return Steplib::SteplibValidator.required_step_version_inputs_properties_with_types()
177
+ end
178
+
179
+ def required_step_version_output_attributes
180
+ return Steplib::SteplibValidator.required_step_version_outputs_properties_with_types()
181
+ end
182
+
183
+ def allowed_step_version_input_attributes_with_types
184
+ return Steplib::SteplibValidator.required_step_version_inputs_properties_with_types()
185
+ end
186
+
187
+ def allowed_step_version_output_attributes_with_types
188
+ return Steplib::SteplibValidator.required_step_version_outputs_properties_with_types()
189
+ end
190
+
191
+ def only_attributes(attributes_list_with_types)
192
+ return attributes_list_with_types.map { |e| e.first }
193
+ end
194
+
114
195
  end
115
196
  end
116
- end
197
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: steplib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0.9
4
+ version: 0.9.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bitrise
@@ -46,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
46
  version: '0'
47
47
  requirements: []
48
48
  rubyforge_project:
49
- rubygems_version: 2.4.3
49
+ rubygems_version: 2.4.6
50
50
  signing_key:
51
51
  specification_version: 4
52
52
  summary: StepLib.com's validator and other utilities GEM