bolt 2.38.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bolt might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Puppetfile +17 -17
- data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +25 -0
- data/bolt-modules/boltlib/lib/puppet/functions/parallelize.rb +6 -8
- data/bolt-modules/boltlib/lib/puppet/functions/wait_until_available.rb +7 -3
- data/lib/bolt/analytics.rb +3 -2
- data/lib/bolt/applicator.rb +11 -1
- data/lib/bolt/bolt_option_parser.rb +3 -113
- data/lib/bolt/catalog.rb +10 -29
- data/lib/bolt/cli.rb +54 -155
- data/lib/bolt/config.rb +63 -269
- data/lib/bolt/config/options.rb +59 -97
- data/lib/bolt/config/transport/local.rb +1 -0
- data/lib/bolt/config/transport/options.rb +10 -2
- data/lib/bolt/config/transport/orch.rb +1 -0
- data/lib/bolt/config/transport/ssh.rb +0 -5
- data/lib/bolt/executor.rb +15 -5
- data/lib/bolt/inventory.rb +3 -2
- data/lib/bolt/inventory/group.rb +35 -12
- data/lib/bolt/inventory/inventory.rb +1 -1
- data/lib/bolt/logger.rb +115 -11
- data/lib/bolt/module.rb +10 -2
- data/lib/bolt/module_installer.rb +4 -2
- data/lib/bolt/module_installer/resolver.rb +65 -12
- data/lib/bolt/module_installer/specs/forge_spec.rb +8 -2
- data/lib/bolt/module_installer/specs/git_spec.rb +17 -2
- data/lib/bolt/outputter/human.rb +9 -5
- data/lib/bolt/outputter/json.rb +16 -16
- data/lib/bolt/outputter/rainbow.rb +3 -3
- data/lib/bolt/pal.rb +93 -14
- data/lib/bolt/pal/yaml_plan.rb +8 -2
- data/lib/bolt/pal/yaml_plan/evaluator.rb +7 -19
- data/lib/bolt/pal/yaml_plan/step.rb +3 -24
- data/lib/bolt/pal/yaml_plan/step/upload.rb +2 -2
- data/lib/bolt/pal/yaml_plan/transpiler.rb +6 -1
- data/lib/bolt/plugin.rb +3 -3
- data/lib/bolt/plugin/cache.rb +8 -8
- data/lib/bolt/plugin/module.rb +0 -23
- data/lib/bolt/plugin/puppet_connect_data.rb +77 -0
- data/lib/bolt/plugin/puppetdb.rb +1 -1
- data/lib/bolt/project.rb +54 -81
- data/lib/bolt/project_manager.rb +4 -3
- data/lib/bolt/project_manager/module_migrator.rb +6 -5
- data/lib/bolt/rerun.rb +1 -1
- data/lib/bolt/shell/bash.rb +1 -1
- data/lib/bolt/shell/bash/tmpdir.rb +4 -1
- data/lib/bolt/shell/powershell.rb +3 -4
- data/lib/bolt/shell/powershell/snippets.rb +9 -149
- data/lib/bolt/task.rb +1 -1
- data/lib/bolt/transport/docker/connection.rb +2 -2
- data/lib/bolt/transport/local.rb +1 -9
- data/lib/bolt/transport/orch/connection.rb +1 -1
- data/lib/bolt/transport/ssh.rb +1 -2
- data/lib/bolt/transport/ssh/connection.rb +1 -1
- data/lib/bolt/validator.rb +16 -15
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt_server/config.rb +1 -1
- data/lib/bolt_server/schemas/partials/task.json +1 -1
- data/lib/bolt_server/transport_app.rb +3 -2
- data/libexec/bolt_catalog +1 -1
- data/modules/aggregate/plans/count.pp +21 -0
- data/modules/aggregate/plans/targets.pp +21 -0
- data/modules/puppet_connect/plans/test_input_data.pp +31 -0
- data/modules/puppetdb_fact/plans/init.pp +10 -0
- metadata +26 -17
- data/modules/aggregate/plans/nodes.pp +0 -36
data/lib/bolt/project_manager.rb
CHANGED
@@ -166,10 +166,11 @@ module Bolt
|
|
166
166
|
# Migrates the project-level configuration file to the latest version.
|
167
167
|
#
|
168
168
|
private def migrate_config
|
169
|
-
migrator
|
169
|
+
migrator = ConfigMigrator.new(@outputter)
|
170
|
+
configfile = @config.project.path + 'bolt.yaml'
|
170
171
|
|
171
172
|
migrator.migrate(
|
172
|
-
|
173
|
+
configfile,
|
173
174
|
@config.project.project_file,
|
174
175
|
@config.inventoryfile || @config.project.inventory_file,
|
175
176
|
@config.project.backup_dir
|
@@ -194,7 +195,7 @@ module Bolt
|
|
194
195
|
|
195
196
|
migrator.migrate(
|
196
197
|
@config.project,
|
197
|
-
@config.modulepath
|
198
|
+
@config.modulepath[0...-1]
|
198
199
|
)
|
199
200
|
end
|
200
201
|
end
|
@@ -6,19 +6,20 @@ module Bolt
|
|
6
6
|
class ProjectManager
|
7
7
|
class ModuleMigrator < Migrator
|
8
8
|
def migrate(project, configured_modulepath)
|
9
|
-
return true
|
9
|
+
return true if project.managed_moduledir.exist?
|
10
10
|
|
11
11
|
@outputter.print_message "Migrating project modules\n\n"
|
12
12
|
|
13
13
|
config = project.project_file
|
14
14
|
puppetfile = project.puppetfile
|
15
15
|
managed_moduledir = project.managed_moduledir
|
16
|
-
|
16
|
+
new_modulepath = [(project.path + 'modules').to_s]
|
17
|
+
old_modulepath = [(project.path + 'modules').to_s,
|
17
18
|
(project.path + 'site-modules').to_s,
|
18
19
|
(project.path + 'site').to_s]
|
19
20
|
|
20
21
|
# Notify user to manually migrate modules if using non-default modulepath
|
21
|
-
if configured_modulepath !=
|
22
|
+
if configured_modulepath != new_modulepath && configured_modulepath != old_modulepath
|
22
23
|
@outputter.print_action_step(
|
23
24
|
"Project has a non-default configured modulepath, unable to automatically "\
|
24
25
|
"migrate project modules. To migrate project modules manually, see "\
|
@@ -27,10 +28,10 @@ module Bolt
|
|
27
28
|
true
|
28
29
|
# Migrate modules from Puppetfile
|
29
30
|
elsif File.exist?(puppetfile)
|
30
|
-
migrate_modules_from_puppetfile(config, puppetfile, managed_moduledir,
|
31
|
+
migrate_modules_from_puppetfile(config, puppetfile, managed_moduledir, old_modulepath)
|
31
32
|
# Migrate modules to updated modulepath
|
32
33
|
else
|
33
|
-
consolidate_modules(
|
34
|
+
consolidate_modules(old_modulepath)
|
34
35
|
update_project_config([], config)
|
35
36
|
end
|
36
37
|
end
|
data/lib/bolt/rerun.rb
CHANGED
@@ -49,7 +49,7 @@ module Bolt
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
rescue StandardError => e
|
52
|
-
Bolt::Logger.warn_once(
|
52
|
+
Bolt::Logger.warn_once("unwriteable_file", "Failed to save result to #{@path}: #{e.message}")
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
data/lib/bolt/shell/bash.rb
CHANGED
@@ -48,7 +48,10 @@ module Bolt
|
|
48
48
|
def delete
|
49
49
|
result = @shell.execute(['rm', '-rf', @path], sudoable: true, run_as: @owner)
|
50
50
|
if result.exit_code != 0
|
51
|
-
|
51
|
+
Bolt::Logger.warn(
|
52
|
+
"fail_cleanup",
|
53
|
+
"Failed to clean up tmpdir '#{@path}': #{result.stderr.string}"
|
54
|
+
)
|
52
55
|
end
|
53
56
|
# For testing
|
54
57
|
result.stderr.string
|
@@ -23,11 +23,10 @@ module Bolt
|
|
23
23
|
# This lets us know how many targets have Powershell 2, and lets the
|
24
24
|
# user know how many targets they have with PS2
|
25
25
|
msg = "Detected PowerShell 2 on one or more targets.\nPowerShell 2 "\
|
26
|
-
"is
|
27
|
-
"bolt-debug.log or run with '--log-level debug' to see the full "\
|
26
|
+
"is unsupported. See bolt-debug.log or run with '--log-level debug' to see the full "\
|
28
27
|
"list of targets with PowerShell 2."
|
29
28
|
|
30
|
-
Bolt::Logger.
|
29
|
+
Bolt::Logger.deprecate_once("powershell_2", msg)
|
31
30
|
@logger.debug("Detected PowerShell 2 on #{target}.")
|
32
31
|
end
|
33
32
|
end
|
@@ -163,7 +162,7 @@ module Bolt
|
|
163
162
|
if target.options['cleanup']
|
164
163
|
rmdir(@tmpdir)
|
165
164
|
else
|
166
|
-
|
165
|
+
Bolt::Logger.warn("Skipping cleanup of tmpdir '#{@tmpdir}'", "skip_cleanup")
|
167
166
|
end
|
168
167
|
end
|
169
168
|
end
|
@@ -70,12 +70,17 @@ module Bolt
|
|
70
70
|
def ps_task(path, arguments)
|
71
71
|
<<~PS
|
72
72
|
$private:tempArgs = Get-ContentAsJson (
|
73
|
-
|
73
|
+
[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('#{Base64.encode64(JSON.dump(arguments))}'))
|
74
74
|
)
|
75
75
|
$allowedArgs = (Get-Command "#{path}").Parameters.Keys
|
76
76
|
$private:taskArgs = @{}
|
77
77
|
$private:tempArgs.Keys | ? { $allowedArgs -contains $_ } | % { $private:taskArgs[$_] = $private:tempArgs[$_] }
|
78
|
-
try {
|
78
|
+
try {
|
79
|
+
& "#{path}" @taskArgs
|
80
|
+
} catch {
|
81
|
+
$Host.UI.WriteErrorLine("[$($_.FullyQualifiedErrorId)] Exception $($_.InvocationInfo.PositionMessage).`n$($_.Exception.Message)");
|
82
|
+
exit 1;
|
83
|
+
}
|
79
84
|
PS
|
80
85
|
end
|
81
86
|
|
@@ -102,151 +107,11 @@ module Bolt
|
|
102
107
|
"${boltBaseDir}\\hiera\\lib;" +
|
103
108
|
$ENV:RUBYLIB
|
104
109
|
|
105
|
-
Add-Type -AssemblyName System.ServiceModel.Web, System.Runtime.Serialization
|
106
|
-
$utf8 = [System.Text.Encoding]::UTF8
|
107
|
-
|
108
|
-
function Write-Stream {
|
109
|
-
PARAM(
|
110
|
-
[Parameter(Position=0)] $stream,
|
111
|
-
[Parameter(ValueFromPipeline=$true)] $string
|
112
|
-
)
|
113
|
-
PROCESS {
|
114
|
-
$bytes = $utf8.GetBytes($string)
|
115
|
-
$stream.Write( $bytes, 0, $bytes.Length )
|
116
|
-
}
|
117
|
-
}
|
118
|
-
|
119
|
-
function Convert-JsonToXml {
|
120
|
-
PARAM([Parameter(ValueFromPipeline=$true)] [string[]] $json)
|
121
|
-
BEGIN {
|
122
|
-
$mStream = New-Object System.IO.MemoryStream
|
123
|
-
}
|
124
|
-
PROCESS {
|
125
|
-
$json | Write-Stream -Stream $mStream
|
126
|
-
}
|
127
|
-
END {
|
128
|
-
$mStream.Position = 0
|
129
|
-
try {
|
130
|
-
$jsonReader = [System.Runtime.Serialization.Json.JsonReaderWriterFactory]::CreateJsonReader($mStream,[System.Xml.XmlDictionaryReaderQuotas]::Max)
|
131
|
-
$xml = New-Object Xml.XmlDocument
|
132
|
-
$xml.Load($jsonReader)
|
133
|
-
$xml
|
134
|
-
} finally {
|
135
|
-
$jsonReader.Close()
|
136
|
-
$mStream.Dispose()
|
137
|
-
}
|
138
|
-
}
|
139
|
-
}
|
140
|
-
|
141
|
-
Function ConvertFrom-Xml {
|
142
|
-
[CmdletBinding(DefaultParameterSetName="AutoType")]
|
143
|
-
PARAM(
|
144
|
-
[Parameter(ValueFromPipeline=$true,Mandatory=$true,Position=1)] [Xml.XmlNode] $xml,
|
145
|
-
[Parameter(Mandatory=$true,ParameterSetName="ManualType")] [Type] $Type,
|
146
|
-
[Switch] $ForceType
|
147
|
-
)
|
148
|
-
PROCESS{
|
149
|
-
if (Get-Member -InputObject $xml -Name root) {
|
150
|
-
return $xml.root.Objects | ConvertFrom-Xml
|
151
|
-
} elseif (Get-Member -InputObject $xml -Name Objects) {
|
152
|
-
return $xml.Objects | ConvertFrom-Xml
|
153
|
-
}
|
154
|
-
$propbag = @{}
|
155
|
-
foreach ($name in Get-Member -InputObject $xml -MemberType Properties | Where-Object{$_.Name -notmatch "^(__.*|type)$"} | Select-Object -ExpandProperty name) {
|
156
|
-
Write-Debug "$Name Type: $($xml.$Name.type)" -Debug:$false
|
157
|
-
$propbag."$Name" = Convert-Properties $xml."$name"
|
158
|
-
}
|
159
|
-
if (!$Type -and $xml.HasAttribute("__type")) { $Type = $xml.__Type }
|
160
|
-
if ($ForceType -and $Type) {
|
161
|
-
try {
|
162
|
-
$output = New-Object $Type -Property $propbag
|
163
|
-
} catch {
|
164
|
-
$output = New-Object PSObject -Property $propbag
|
165
|
-
$output.PsTypeNames.Insert(0, $xml.__type)
|
166
|
-
}
|
167
|
-
} elseif ($propbag.Count -ne 0) {
|
168
|
-
$output = New-Object PSObject -Property $propbag
|
169
|
-
if ($Type) {
|
170
|
-
$output.PsTypeNames.Insert(0, $Type)
|
171
|
-
}
|
172
|
-
}
|
173
|
-
return $output
|
174
|
-
}
|
175
|
-
}
|
176
|
-
|
177
|
-
Function Convert-Properties {
|
178
|
-
PARAM($InputObject)
|
179
|
-
switch ($InputObject.type) {
|
180
|
-
"object" {
|
181
|
-
return (ConvertFrom-Xml -Xml $InputObject)
|
182
|
-
}
|
183
|
-
"string" {
|
184
|
-
$MightBeADate = $InputObject.get_InnerText() -as [DateTime]
|
185
|
-
## Strings that are actually dates (*grumble* JSON is crap)
|
186
|
-
if ($MightBeADate -and $propbag."$Name" -eq $MightBeADate.ToString("G")) {
|
187
|
-
return $MightBeADate
|
188
|
-
} else {
|
189
|
-
return $InputObject.get_InnerText()
|
190
|
-
}
|
191
|
-
}
|
192
|
-
"number" {
|
193
|
-
$number = $InputObject.get_InnerText()
|
194
|
-
if ($number -eq ($number -as [int])) {
|
195
|
-
return $number -as [int]
|
196
|
-
} elseif ($number -eq ($number -as [double])) {
|
197
|
-
return $number -as [double]
|
198
|
-
} else {
|
199
|
-
return $number -as [decimal]
|
200
|
-
}
|
201
|
-
}
|
202
|
-
"boolean" {
|
203
|
-
return [bool]::parse($InputObject.get_InnerText())
|
204
|
-
}
|
205
|
-
"null" {
|
206
|
-
return $null
|
207
|
-
}
|
208
|
-
"array" {
|
209
|
-
[object[]]$Items = $(foreach( $item in $InputObject.GetEnumerator() ) {
|
210
|
-
Convert-Properties $item
|
211
|
-
})
|
212
|
-
return $Items
|
213
|
-
}
|
214
|
-
default {
|
215
|
-
return $InputObject
|
216
|
-
}
|
217
|
-
}
|
218
|
-
}
|
219
|
-
|
220
|
-
Function ConvertFrom-Json2 {
|
221
|
-
[CmdletBinding()]
|
222
|
-
PARAM(
|
223
|
-
[Parameter(ValueFromPipeline=$true,Mandatory=$true,Position=1)] [string] $InputObject,
|
224
|
-
[Parameter(Mandatory=$true)] [Type] $Type,
|
225
|
-
[Switch] $ForceType
|
226
|
-
)
|
227
|
-
PROCESS {
|
228
|
-
$null = $PSBoundParameters.Remove("InputObject")
|
229
|
-
[Xml.XmlElement]$xml = (Convert-JsonToXml $InputObject).Root
|
230
|
-
if ($xml) {
|
231
|
-
if ($xml.Objects) {
|
232
|
-
$xml.Objects.Item.GetEnumerator() | ConvertFrom-Xml @PSBoundParameters
|
233
|
-
} elseif ($xml.Item -and $xml.Item -isnot [System.Management.Automation.PSParameterizedProperty]) {
|
234
|
-
$xml.Item | ConvertFrom-Xml @PSBoundParameters
|
235
|
-
} else {
|
236
|
-
$xml | ConvertFrom-Xml @PSBoundParameters
|
237
|
-
}
|
238
|
-
} else {
|
239
|
-
Write-Error "Failed to parse JSON with JsonReader" -Debug:$false
|
240
|
-
}
|
241
|
-
}
|
242
|
-
}
|
243
|
-
|
244
110
|
function ConvertFrom-PSCustomObject
|
245
111
|
{
|
246
112
|
PARAM([Parameter(ValueFromPipeline = $true)] $InputObject)
|
247
113
|
PROCESS {
|
248
114
|
if ($null -eq $InputObject) { return $null }
|
249
|
-
|
250
115
|
if ($InputObject -is [System.Collections.IEnumerable] -and $InputObject -isnot [string]) {
|
251
116
|
$collection = @(
|
252
117
|
foreach ($object in $InputObject) { ConvertFrom-PSCustomObject $object }
|
@@ -273,13 +138,8 @@ module Bolt
|
|
273
138
|
[Parameter(Mandatory = $true)] $Text,
|
274
139
|
[Parameter(Mandatory = $false)] [Text.Encoding] $Encoding = [Text.Encoding]::UTF8
|
275
140
|
)
|
276
|
-
|
277
|
-
|
278
|
-
if ($PSVersionTable.PSVersion -lt [Version]'3.0') {
|
279
|
-
$Text | ConvertFrom-Json2 -Type PSObject | ConvertFrom-PSCustomObject
|
280
|
-
} else {
|
281
|
-
$Text | ConvertFrom-Json | ConvertFrom-PSCustomObject
|
282
|
-
}
|
141
|
+
|
142
|
+
$Text | ConvertFrom-Json | ConvertFrom-PSCustomObject
|
283
143
|
}
|
284
144
|
PS
|
285
145
|
end
|
data/lib/bolt/task.rb
CHANGED
@@ -149,7 +149,7 @@ module Bolt
|
|
149
149
|
if unknown_keys.any?
|
150
150
|
msg = "Metadata for task '#{@name}' contains unknown keys: #{unknown_keys.join(', ')}."
|
151
151
|
msg += " This could be a typo in the task metadata or may result in incorrect behavior."
|
152
|
-
|
152
|
+
Bolt::Logger.warn("unknown_task_metadata_keys", msg)
|
153
153
|
end
|
154
154
|
end
|
155
155
|
end
|
@@ -140,10 +140,10 @@ module Bolt
|
|
140
140
|
if @target.options['cleanup']
|
141
141
|
_, stderr, exitcode = execute('rm', '-rf', dir, {})
|
142
142
|
if exitcode != 0
|
143
|
-
|
143
|
+
Bolt::Logger.warn("fail_cleanup", "Failed to clean up tmpdir '#{dir}': #{stderr}")
|
144
144
|
end
|
145
145
|
else
|
146
|
-
|
146
|
+
Bolt::Logger.warn("skip_cleanup", "Skipping cleanup of tmpdir '#{dir}'")
|
147
147
|
end
|
148
148
|
end
|
149
149
|
end
|
data/lib/bolt/transport/local.rb
CHANGED
@@ -11,18 +11,10 @@ module Bolt
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def with_connection(target)
|
14
|
-
if target.transport_config['bundled-ruby']
|
14
|
+
if target.transport_config['bundled-ruby']
|
15
15
|
target.set_local_defaults
|
16
16
|
end
|
17
17
|
|
18
|
-
if target.name != 'localhost' &&
|
19
|
-
!target.transport_config.key?('bundled-ruby')
|
20
|
-
msg = "The local transport will default to using Bolt's Ruby interpreter and "\
|
21
|
-
"setting the 'puppet-agent' feature in Bolt 3.0. Enable or disable these "\
|
22
|
-
"defaults by setting 'bundled-ruby' in the local transport config."
|
23
|
-
Bolt::Logger.warn_once('local default config', msg)
|
24
|
-
end
|
25
|
-
|
26
18
|
yield Connection.new(target)
|
27
19
|
end
|
28
20
|
end
|
@@ -21,7 +21,7 @@ module Bolt
|
|
21
21
|
|
22
22
|
@logger = logger
|
23
23
|
@key = self.class.get_key(opts)
|
24
|
-
client_opts = opts.slice('token-file', 'cacert', 'job-poll-interval', 'job-poll-timeout')
|
24
|
+
client_opts = opts.slice('token-file', 'cacert', 'job-poll-interval', 'job-poll-timeout', 'read-timeout')
|
25
25
|
|
26
26
|
if opts['service-url']
|
27
27
|
uri = Addressable::URI.parse(opts['service-url'])
|
data/lib/bolt/transport/ssh.rb
CHANGED
@@ -23,8 +23,7 @@ module Bolt
|
|
23
23
|
|
24
24
|
def with_connection(target)
|
25
25
|
if target.transport_config['ssh-command'] && !target.transport_config['native-ssh']
|
26
|
-
Bolt::Logger.warn_once("
|
27
|
-
"native-ssh must be true to use ssh-command")
|
26
|
+
Bolt::Logger.warn_once("native_ssh_disabled", "native-ssh must be true to use ssh-command")
|
28
27
|
end
|
29
28
|
|
30
29
|
conn = if target.transport_config['native-ssh']
|
data/lib/bolt/validator.rb
CHANGED
@@ -47,17 +47,18 @@ module Bolt
|
|
47
47
|
# the value's type, the value is passed off to an individual
|
48
48
|
# validation method for the value's type.
|
49
49
|
#
|
50
|
-
private def validate_value(value, definition)
|
51
|
-
definition
|
50
|
+
private def validate_value(value, definition, plugin_supported = false)
|
51
|
+
definition = @schema.dig(:definitions, definition[:_ref]) if definition[:_ref]
|
52
|
+
plugin_supported = definition[:_plugin] if definition.key?(:_plugin)
|
52
53
|
|
53
|
-
return if plugin_reference?(value,
|
54
|
+
return if plugin_reference?(value, plugin_supported)
|
54
55
|
return unless valid_type?(value, definition)
|
55
56
|
|
56
57
|
case value
|
57
58
|
when Hash
|
58
|
-
validate_hash(value, definition)
|
59
|
+
validate_hash(value, definition, plugin_supported)
|
59
60
|
when Array
|
60
|
-
validate_array(value, definition)
|
61
|
+
validate_array(value, definition, plugin_supported)
|
61
62
|
when String
|
62
63
|
validate_string(value, definition)
|
63
64
|
when Numeric
|
@@ -69,7 +70,7 @@ module Bolt
|
|
69
70
|
# This will enumerate each key-value pair in the hash and validate each
|
70
71
|
# value individually.
|
71
72
|
#
|
72
|
-
private def validate_hash(value, definition)
|
73
|
+
private def validate_hash(value, definition, plugin_supported)
|
73
74
|
properties = definition[:properties] ? definition[:properties].keys : []
|
74
75
|
|
75
76
|
if definition[:properties] && definition[:additionalProperties].nil?
|
@@ -86,9 +87,9 @@ module Bolt
|
|
86
87
|
|
87
88
|
if properties.include?(key)
|
88
89
|
check_deprecated(key, definition[:properties][key])
|
89
|
-
validate_value(val, definition[:properties][key])
|
90
|
-
elsif definition[:additionalProperties]
|
91
|
-
validate_value(val, definition[:additionalProperties])
|
90
|
+
validate_value(val, definition[:properties][key], plugin_supported)
|
91
|
+
elsif definition[:additionalProperties].is_a?(Hash)
|
92
|
+
validate_value(val, definition[:additionalProperties], plugin_supported)
|
92
93
|
end
|
93
94
|
ensure
|
94
95
|
@path.pop
|
@@ -99,7 +100,7 @@ module Bolt
|
|
99
100
|
# This will enumerate the items in the array and validate each item
|
100
101
|
# individually.
|
101
102
|
#
|
102
|
-
private def validate_array(value, definition)
|
103
|
+
private def validate_array(value, definition, plugin_supported)
|
103
104
|
if definition[:uniqueItems] && value.size != value.uniq.size
|
104
105
|
@errors << "Value at '#{path}' must not include duplicate elements"
|
105
106
|
return
|
@@ -109,7 +110,7 @@ module Bolt
|
|
109
110
|
|
110
111
|
value.each_with_index do |item, index|
|
111
112
|
@path.push(index)
|
112
|
-
validate_value(item, definition[:items])
|
113
|
+
validate_value(item, definition[:items], plugin_supported)
|
113
114
|
ensure
|
114
115
|
@path.pop
|
115
116
|
end
|
@@ -146,7 +147,7 @@ module Bolt
|
|
146
147
|
message += " at '#{path}'" if @path.any?
|
147
148
|
message += " at #{@location}" if @location
|
148
149
|
message += "."
|
149
|
-
@warnings << message
|
150
|
+
@warnings << { id: 'unknown_option', msg: message }
|
150
151
|
end
|
151
152
|
end
|
152
153
|
|
@@ -159,7 +160,7 @@ module Bolt
|
|
159
160
|
message = "Option '#{path}' "
|
160
161
|
message += "at #{@location} " if @location
|
161
162
|
message += "is deprecated. #{definition[:_deprecation]}"
|
162
|
-
@deprecations << {
|
163
|
+
@deprecations << { id: "#{key}_option", msg: message }
|
163
164
|
end
|
164
165
|
end
|
165
166
|
|
@@ -168,9 +169,9 @@ module Bolt
|
|
168
169
|
# plugin reference but cannot be one according to the schema, then this will
|
169
170
|
# log an error.
|
170
171
|
#
|
171
|
-
private def plugin_reference?(value,
|
172
|
+
private def plugin_reference?(value, plugin_supported)
|
172
173
|
if value.is_a?(Hash) && value.key?('_plugin')
|
173
|
-
unless
|
174
|
+
unless plugin_supported
|
174
175
|
@errors << "Value at '#{path}' is a plugin reference, which is unsupported at "\
|
175
176
|
"this location"
|
176
177
|
end
|