pdk 2.6.1 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -1
- data/lib/pdk/analytics/client/google_analytics.rb +4 -2
- data/lib/pdk/cli/build.rb +17 -21
- data/lib/pdk/cli/bundle.rb +4 -5
- data/lib/pdk/cli/config/get.rb +6 -6
- data/lib/pdk/cli/config.rb +3 -3
- data/lib/pdk/cli/console.rb +7 -7
- data/lib/pdk/cli/convert.rb +11 -11
- data/lib/pdk/cli/env.rb +3 -4
- data/lib/pdk/cli/errors.rb +1 -1
- data/lib/pdk/cli/exec/command.rb +12 -14
- data/lib/pdk/cli/exec/interactive_command.rb +11 -11
- data/lib/pdk/cli/exec.rb +4 -4
- data/lib/pdk/cli/exec_group.rb +1 -3
- data/lib/pdk/cli/get/config.rb +5 -5
- data/lib/pdk/cli/get.rb +2 -2
- data/lib/pdk/cli/module/build.rb +3 -3
- data/lib/pdk/cli/module/generate.rb +4 -4
- data/lib/pdk/cli/module.rb +3 -3
- data/lib/pdk/cli/new/class.rb +4 -4
- data/lib/pdk/cli/new/defined_type.rb +4 -4
- data/lib/pdk/cli/new/fact.rb +3 -3
- data/lib/pdk/cli/new/function.rb +4 -4
- data/lib/pdk/cli/new/module.rb +10 -11
- data/lib/pdk/cli/new/provider.rb +3 -3
- data/lib/pdk/cli/new/task.rb +5 -5
- data/lib/pdk/cli/new/test.rb +7 -7
- data/lib/pdk/cli/new/transport.rb +3 -3
- data/lib/pdk/cli/new.rb +3 -3
- data/lib/pdk/cli/release/prep.rb +9 -9
- data/lib/pdk/cli/release/publish.rb +7 -11
- data/lib/pdk/cli/release.rb +35 -39
- data/lib/pdk/cli/remove/config.rb +15 -15
- data/lib/pdk/cli/remove.rb +2 -2
- data/lib/pdk/cli/set/config.rb +16 -16
- data/lib/pdk/cli/set.rb +2 -2
- data/lib/pdk/cli/test/unit.rb +13 -13
- data/lib/pdk/cli/test.rb +2 -2
- data/lib/pdk/cli/update.rb +19 -29
- data/lib/pdk/cli/util/command_redirector.rb +1 -1
- data/lib/pdk/cli/util/interview.rb +4 -4
- data/lib/pdk/cli/util/option_normalizer.rb +2 -2
- data/lib/pdk/cli/util/option_validator.rb +1 -1
- data/lib/pdk/cli/util.rb +19 -20
- data/lib/pdk/cli/validate.rb +16 -18
- data/lib/pdk/cli.rb +16 -33
- data/lib/pdk/config/ini_file_setting.rb +2 -2
- data/lib/pdk/config/json_schema_namespace.rb +3 -3
- data/lib/pdk/config/json_schema_setting.rb +1 -1
- data/lib/pdk/config/json_with_schema.rb +1 -1
- data/lib/pdk/config/namespace.rb +4 -4
- data/lib/pdk/config/setting.rb +5 -5
- data/lib/pdk/config/validator.rb +2 -2
- data/lib/pdk/config/yaml.rb +2 -2
- data/lib/pdk/config/yaml_with_schema.rb +3 -3
- data/lib/pdk/config.rb +18 -20
- data/lib/pdk/context/control_repo.rb +1 -1
- data/lib/pdk/context/module.rb +1 -1
- data/lib/pdk/context/none.rb +1 -1
- data/lib/pdk/generate/module.rb +52 -64
- data/lib/pdk/generate/puppet_object.rb +6 -6
- data/lib/pdk/generate/task.rb +1 -1
- data/lib/pdk/module/build.rb +11 -16
- data/lib/pdk/module/convert.rb +14 -16
- data/lib/pdk/module/metadata.rb +12 -12
- data/lib/pdk/module/release.rb +20 -19
- data/lib/pdk/module/update.rb +5 -5
- data/lib/pdk/module/update_manager.rb +6 -6
- data/lib/pdk/report/event.rb +11 -11
- data/lib/pdk/template/fetcher/git.rb +4 -4
- data/lib/pdk/template/fetcher.rb +1 -1
- data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +1 -1
- data/lib/pdk/template/renderer/v1/renderer.rb +5 -7
- data/lib/pdk/template/renderer/v1/template_file.rb +3 -1
- data/lib/pdk/template/template_dir.rb +1 -1
- data/lib/pdk/template.rb +2 -2
- data/lib/pdk/tests/unit.rb +12 -12
- data/lib/pdk/util/bundler.rb +14 -14
- data/lib/pdk/util/changelog_generator.rb +6 -8
- data/lib/pdk/util/filesystem.rb +2 -2
- data/lib/pdk/util/git.rb +5 -5
- data/lib/pdk/util/puppet_strings.rb +2 -2
- data/lib/pdk/util/puppet_version.rb +24 -17
- data/lib/pdk/util/ruby_version.rb +2 -5
- data/lib/pdk/util/template_uri.rb +8 -8
- data/lib/pdk/util/vendored_file.rb +3 -3
- data/lib/pdk/util/windows/api_types.rb +3 -4
- data/lib/pdk/util/windows/file.rb +1 -1
- data/lib/pdk/util/windows/process.rb +5 -8
- data/lib/pdk/util.rb +2 -2
- data/lib/pdk/validate/control_repo/environment_conf_validator.rb +5 -5
- data/lib/pdk/validate/invokable_validator.rb +6 -6
- data/lib/pdk/validate/metadata/metadata_json_lint_validator.rb +2 -2
- data/lib/pdk/validate/metadata/metadata_syntax_validator.rb +2 -2
- data/lib/pdk/validate/puppet/puppet_epp_validator.rb +1 -1
- data/lib/pdk/validate/puppet/puppet_lint_validator.rb +1 -1
- data/lib/pdk/validate/puppet/puppet_plan_syntax_validator.rb +38 -0
- data/lib/pdk/validate/puppet/puppet_syntax_validator.rb +1 -1
- data/lib/pdk/validate/puppet/puppet_validator_group.rb +1 -0
- data/lib/pdk/validate/ruby/ruby_rubocop_validator.rb +1 -1
- data/lib/pdk/validate/tasks/tasks_metadata_lint_validator.rb +4 -4
- data/lib/pdk/validate/tasks/tasks_name_validator.rb +2 -5
- data/lib/pdk/validate/validator.rb +1 -1
- data/lib/pdk/validate/validator_group.rb +1 -1
- data/lib/pdk/validate/yaml/yaml_syntax_validator.rb +4 -4
- data/lib/pdk/validate.rb +2 -1
- data/lib/pdk/version.rb +2 -2
- data/lib/pdk.rb +0 -2
- metadata +32 -54
- data/lib/pdk/i18n.rb +0 -4
- data/locales/config.yaml +0 -21
- data/locales/pdk.pot +0 -2111
data/lib/pdk/cli.rb
CHANGED
@@ -49,23 +49,7 @@ module PDK::CLI
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
def self.deprecated_runtime?
|
53
|
-
Gem::Version.new(RbConfig::CONFIG['ruby_version']) < Gem::Version.new('2.4.0')
|
54
|
-
end
|
55
|
-
|
56
52
|
def self.run(args)
|
57
|
-
if deprecated_runtime?
|
58
|
-
PDK.logger.info(
|
59
|
-
text: _(
|
60
|
-
'Support for Ruby versions older than 2.4 will be dropped in the ' \
|
61
|
-
'future PDK 2.0.0 release. We recommend updating your Ruby ' \
|
62
|
-
'installation to ensure that you can continue using the latest ' \
|
63
|
-
'version of PDK.',
|
64
|
-
),
|
65
|
-
wrap: true,
|
66
|
-
)
|
67
|
-
end
|
68
|
-
|
69
53
|
@args = args
|
70
54
|
PDK::Config.analytics_config_interview! unless PDK::Util::Env['PDK_DISABLE_ANALYTICS'] || PDK::Config.analytics_config_exist?
|
71
55
|
@base_cmd.run(args)
|
@@ -94,63 +78,62 @@ module PDK::CLI
|
|
94
78
|
def self.template_url_option(dsl)
|
95
79
|
require 'pdk/util/template_uri'
|
96
80
|
|
97
|
-
desc =
|
81
|
+
desc = 'Specifies the URL to the template to use when creating new modules or classes. (default: %{default_url})' % { default_url: PDK::Util::TemplateURI.default_template_uri }
|
98
82
|
|
99
83
|
dsl.option nil, 'template-url', desc, argument: :required
|
100
84
|
end
|
101
85
|
|
102
86
|
def self.template_ref_option(dsl)
|
103
|
-
dsl.option nil, 'template-ref',
|
87
|
+
dsl.option nil, 'template-ref', 'Specifies the template git branch or tag to use when creating new modules or classes.', argument: :required
|
104
88
|
end
|
105
89
|
|
106
90
|
def self.skip_interview_option(dsl)
|
107
|
-
dsl.option nil, 'skip-interview',
|
91
|
+
dsl.option nil, 'skip-interview', 'When specified, skips interactive querying of metadata.'
|
108
92
|
end
|
109
93
|
|
110
94
|
def self.full_interview_option(dsl)
|
111
|
-
dsl.option nil, 'full-interview',
|
95
|
+
dsl.option nil, 'full-interview', 'When specified, interactive querying of metadata will include all optional questions.'
|
112
96
|
end
|
113
97
|
|
114
98
|
def self.puppet_version_options(dsl)
|
115
|
-
dsl.option nil, 'puppet-version',
|
116
|
-
dsl.option nil, 'pe-version',
|
99
|
+
dsl.option nil, 'puppet-version', 'Puppet version to run tests or validations against.', argument: :required
|
100
|
+
dsl.option nil, 'pe-version', 'Puppet Enterprise version to run tests or validations against.', argument: :required
|
117
101
|
end
|
118
102
|
|
119
103
|
def self.puppet_dev_option(dsl)
|
120
104
|
dsl.option nil,
|
121
105
|
'puppet-dev',
|
122
|
-
|
106
|
+
'When specified, PDK will validate or test against the current Puppet source from github.com. To use this option, you must have network access to https://github.com.'
|
123
107
|
end
|
124
108
|
|
125
109
|
@base_cmd = Cri::Command.define do
|
126
110
|
name 'pdk'
|
127
|
-
usage
|
128
|
-
summary
|
129
|
-
description
|
111
|
+
usage 'pdk command [options]'
|
112
|
+
summary 'Puppet Development Kit'
|
113
|
+
description 'The shortest path to better modules.'
|
130
114
|
default_subcommand 'help'
|
131
115
|
|
132
|
-
flag nil, :version,
|
116
|
+
flag nil, :version, 'Show version of pdk.' do |_, _|
|
133
117
|
puts PDK::Util::Version.version_string
|
134
118
|
exit 0
|
135
119
|
end
|
136
120
|
|
137
|
-
flag :h, :help,
|
121
|
+
flag :h, :help, 'Show help for this command.' do |_, c|
|
138
122
|
puts c.help
|
139
123
|
exit 0
|
140
124
|
end
|
141
125
|
|
142
|
-
format_desc =
|
143
|
-
"Specify desired output format. Valid formats are '
|
126
|
+
format_desc =
|
127
|
+
"Specify desired output format. Valid formats are '#{PDK::Report.formats.join("', '")}'. " \
|
144
128
|
'You may also specify a file to which the formatted output is sent, ' \
|
145
129
|
"for example: '--format=junit:report.xml'. This option may be specified " \
|
146
|
-
'multiple times if each option specifies a distinct target file.'
|
147
|
-
) % { available_formats: PDK::Report.formats.join("', '") }
|
130
|
+
'multiple times if each option specifies a distinct target file.'
|
148
131
|
|
149
132
|
option :f, :format, format_desc, argument: :required, multiple: true do |values|
|
150
133
|
PDK::CLI::Util::OptionNormalizer.report_formats(values.compact)
|
151
134
|
end
|
152
135
|
|
153
|
-
flag :d, :debug,
|
136
|
+
flag :d, :debug, 'Enable debug output.' do |_, _|
|
154
137
|
PDK.logger.enable_debug_output
|
155
138
|
end
|
156
139
|
end
|
@@ -20,7 +20,7 @@ module PDK
|
|
20
20
|
return if value.nil? || value.is_a?(String) || value.is_a?(Integer)
|
21
21
|
# The only other valid-ish type is a Hash
|
22
22
|
unless value.is_a?(Hash)
|
23
|
-
raise ArgumentError,
|
23
|
+
raise ArgumentError, 'The setting %{key} may only be a String or Integer, not %{class}' % {
|
24
24
|
key: qualified_name,
|
25
25
|
class: value.class,
|
26
26
|
}
|
@@ -28,7 +28,7 @@ module PDK
|
|
28
28
|
# Any hashes can only have a single String/Integer value
|
29
29
|
value.each do |child_name, child_value|
|
30
30
|
next if child_value.nil? || child_value.is_a?(String) || child_value.is_a?(Integer)
|
31
|
-
raise ArgumentError,
|
31
|
+
raise ArgumentError, 'The setting %{key} may only be a String or Integer, not %{class}' % {
|
32
32
|
key: qualified_name + '.' + child_name,
|
33
33
|
class: child_value.class,
|
34
34
|
}
|
@@ -99,7 +99,7 @@ module PDK
|
|
99
99
|
#
|
100
100
|
# @private
|
101
101
|
def create_missing_setting(key, _initial_value = nil)
|
102
|
-
raise ArgumentError,
|
102
|
+
raise ArgumentError, "Setting '#{key}' does not exist'"
|
103
103
|
end
|
104
104
|
|
105
105
|
# Create a valid, but empty schema
|
@@ -120,7 +120,7 @@ module PDK
|
|
120
120
|
|
121
121
|
return @document_schema if @schema_file.nil?
|
122
122
|
unless PDK::Util::Filesystem.file?(@schema_file)
|
123
|
-
raise PDK::Config::LoadError,
|
123
|
+
raise PDK::Config::LoadError, 'Unable to open %{file} for reading. File does not exist' % {
|
124
124
|
file: @schema_file,
|
125
125
|
}
|
126
126
|
end
|
@@ -132,7 +132,7 @@ module PDK
|
|
132
132
|
)
|
133
133
|
@document_schema = schema_reader.read(Addressable::URI.convert_path(@schema_file))
|
134
134
|
rescue ::JSON::Schema::JsonParseError => e
|
135
|
-
raise PDK::Config::LoadError,
|
135
|
+
raise PDK::Config::LoadError, 'Unable to open %{file} for reading. JSON Error: %{msg}' % {
|
136
136
|
file: @schema_file,
|
137
137
|
msg: e.message,
|
138
138
|
}
|
@@ -24,7 +24,7 @@ module PDK
|
|
24
24
|
# ... add validate it
|
25
25
|
namespace.validate_document!(new_document)
|
26
26
|
rescue ::JSON::Schema::ValidationError => e
|
27
|
-
raise ArgumentError,
|
27
|
+
raise ArgumentError, '%{key} %{message}' % {
|
28
28
|
key: qualified_name,
|
29
29
|
message: e.message,
|
30
30
|
}
|
@@ -19,7 +19,7 @@ module PDK
|
|
19
19
|
# Ensure the parsed document is actually valid
|
20
20
|
validate_document!(@raw_data)
|
21
21
|
rescue ::JSON::Schema::ValidationError => e
|
22
|
-
raise PDK::Config::LoadError,
|
22
|
+
raise PDK::Config::LoadError, 'The configuration file %{filename} is not valid: %{message}' % {
|
23
23
|
filename: filename,
|
24
24
|
message: e.message,
|
25
25
|
}
|
data/lib/pdk/config/namespace.rb
CHANGED
@@ -65,7 +65,7 @@ module PDK
|
|
65
65
|
#
|
66
66
|
# @return [self] the mounted namespace.
|
67
67
|
def mount(key, obj, &block)
|
68
|
-
raise ArgumentError,
|
68
|
+
raise ArgumentError, 'Only PDK::Config::Namespace objects can be mounted into a namespace' unless obj.is_a?(PDK::Config::Namespace)
|
69
69
|
obj.parent = self
|
70
70
|
obj.name = key.to_s
|
71
71
|
obj.instance_eval(&block) if block_given?
|
@@ -138,7 +138,7 @@ module PDK
|
|
138
138
|
# @return [nil]
|
139
139
|
def []=(key, value)
|
140
140
|
# You can't set the value of a mount
|
141
|
-
raise ArgumentError,
|
141
|
+
raise ArgumentError, 'Namespace mounts can not be set a value' unless @mounts[key.to_s].nil?
|
142
142
|
set_volatile_value(key, value)
|
143
143
|
# Persist the change
|
144
144
|
save_data
|
@@ -305,7 +305,7 @@ module PDK
|
|
305
305
|
rescue Errno::ENOENT => e
|
306
306
|
raise PDK::Config::LoadError, e.message
|
307
307
|
rescue Errno::EACCES
|
308
|
-
raise PDK::Config::LoadError,
|
308
|
+
raise PDK::Config::LoadError, 'Unable to open %{file} for reading' % {
|
309
309
|
file: filename,
|
310
310
|
}
|
311
311
|
end
|
@@ -328,7 +328,7 @@ module PDK
|
|
328
328
|
|
329
329
|
PDK::Util::Filesystem.write_file(file, serialize_data(to_h))
|
330
330
|
rescue Errno::EACCES
|
331
|
-
raise PDK::Config::LoadError,
|
331
|
+
raise PDK::Config::LoadError, 'Unable to open %{file} for writing' % {
|
332
332
|
file: file,
|
333
333
|
}
|
334
334
|
rescue SystemCallError => e
|
data/lib/pdk/config/setting.rb
CHANGED
@@ -77,9 +77,9 @@ module PDK
|
|
77
77
|
#
|
78
78
|
# @return [nil]
|
79
79
|
def validate(validator)
|
80
|
-
raise ArgumentError,
|
81
|
-
raise ArgumentError,
|
82
|
-
raise ArgumentError,
|
80
|
+
raise ArgumentError, '`validator` must be a Hash' unless validator.is_a?(Hash)
|
81
|
+
raise ArgumentError, 'the :proc key must contain a Proc' unless validator.key?(:proc) && validator[:proc].is_a?(Proc)
|
82
|
+
raise ArgumentError, 'the :message key must contain a String' unless validator.key?(:message) && validator[:message].is_a?(String)
|
83
83
|
|
84
84
|
@validators << validator
|
85
85
|
end
|
@@ -96,7 +96,7 @@ module PDK
|
|
96
96
|
@validators.each do |validator|
|
97
97
|
next if validator[:proc].call(value)
|
98
98
|
|
99
|
-
raise ArgumentError,
|
99
|
+
raise ArgumentError, '%{key} %{message}' % {
|
100
100
|
key: qualified_name,
|
101
101
|
message: validator[:message],
|
102
102
|
}
|
@@ -110,7 +110,7 @@ module PDK
|
|
110
110
|
#
|
111
111
|
# @return [nil]
|
112
112
|
def default_to(&block)
|
113
|
-
raise ArgumentError,
|
113
|
+
raise ArgumentError, 'must be passed a block' unless block_given?
|
114
114
|
@default_to = block
|
115
115
|
end
|
116
116
|
|
data/lib/pdk/config/validator.rb
CHANGED
@@ -13,7 +13,7 @@ module PDK
|
|
13
13
|
def self.boolean
|
14
14
|
{
|
15
15
|
proc: ->(value) { [true, false].include?(value) },
|
16
|
-
message:
|
16
|
+
message: 'must be a boolean: true or false',
|
17
17
|
}
|
18
18
|
end
|
19
19
|
|
@@ -23,7 +23,7 @@ module PDK
|
|
23
23
|
def self.uuid
|
24
24
|
{
|
25
25
|
proc: ->(value) { value.match(%r{\A\h{8}(?:-\h{4}){3}-\h{12}\z}) },
|
26
|
-
message:
|
26
|
+
message: 'must be a version 4 UUID',
|
27
27
|
}
|
28
28
|
end
|
29
29
|
end
|
data/lib/pdk/config/yaml.rb
CHANGED
@@ -22,12 +22,12 @@ module PDK
|
|
22
22
|
|
23
23
|
data.each { |k, v| yield k, PDK::Config::Setting.new(k, self, v) }
|
24
24
|
rescue Psych::SyntaxError => e
|
25
|
-
raise PDK::Config::LoadError,
|
25
|
+
raise PDK::Config::LoadError, 'Syntax error when loading %{file}: %{error}' % {
|
26
26
|
file: filename,
|
27
27
|
error: "#{e.problem} #{e.context}",
|
28
28
|
}
|
29
29
|
rescue Psych::DisallowedClass => e
|
30
|
-
raise PDK::Config::LoadError,
|
30
|
+
raise PDK::Config::LoadError, 'Unsupported class in %{file}: %{error}' % {
|
31
31
|
file: filename,
|
32
32
|
error: e.message,
|
33
33
|
}
|
@@ -20,7 +20,7 @@ module PDK
|
|
20
20
|
# Ensure the parsed document is actually valid
|
21
21
|
validate_document!(@raw_data)
|
22
22
|
rescue ::JSON::Schema::ValidationError => e
|
23
|
-
raise PDK::Config::LoadError,
|
23
|
+
raise PDK::Config::LoadError, 'The configuration file %{filename} is not valid: %{message}' % {
|
24
24
|
filename: filename,
|
25
25
|
message: e.message,
|
26
26
|
}
|
@@ -36,12 +36,12 @@ module PDK
|
|
36
36
|
# we're left with the settings that we don't manage.
|
37
37
|
self.unmanaged_settings = @raw_data.reject { |k, _| schema_property_names.include?(k) }
|
38
38
|
rescue Psych::SyntaxError => e
|
39
|
-
raise PDK::Config::LoadError,
|
39
|
+
raise PDK::Config::LoadError, 'Syntax error when loading %{file}: %{error}' % {
|
40
40
|
file: filename,
|
41
41
|
error: "#{e.problem} #{e.context}",
|
42
42
|
}
|
43
43
|
rescue Psych::DisallowedClass => e
|
44
|
-
raise PDK::Config::LoadError,
|
44
|
+
raise PDK::Config::LoadError, 'Unsupported class in %{file}: %{error}' % {
|
45
45
|
file: filename,
|
46
46
|
error: e.message,
|
47
47
|
}
|
data/lib/pdk/config.rb
CHANGED
@@ -143,8 +143,8 @@ module PDK
|
|
143
143
|
# @scopes [Nil, Array[String]] The list of scopes, in order, to query in turn for the setting_name. Invalid or missing scopes are ignored.
|
144
144
|
# @return [PDK::Config::Namespace, Object, nil] The value of the configuration setting. Returns nil if it does no exist
|
145
145
|
def get_within_scopes(setting_name, scopes = nil)
|
146
|
-
raise ArgumentError,
|
147
|
-
raise ArgumentError,
|
146
|
+
raise ArgumentError, 'Expected an Array but got \'%{klass}\' for scopes' % { klass: scopes.class } unless scopes.nil? || scopes.is_a?(Array)
|
147
|
+
raise ArgumentError, 'Expected an Array or String but got \'%{klass}\' for setting_name' % { klass: setting_name.class } unless setting_name.is_a?(Array) || setting_name.is_a?(String)
|
148
148
|
|
149
149
|
setting_arr = setting_name.is_a?(String) ? split_key_string(setting_name) : setting_name
|
150
150
|
all_scope_names = all_scopes.keys
|
@@ -164,7 +164,7 @@ module PDK
|
|
164
164
|
# @scopes [Nil, Array[String]] The list of scopes, in order, to query in turn for the setting_name. Invalid or missing scopes are ignored.
|
165
165
|
# @yield [PDK::Config::Namespace, Object] The value of the configuration setting. Does not yield if the setting does not exist or is nil
|
166
166
|
def with_scoped_value(setting_name, scopes = nil)
|
167
|
-
raise ArgumentError,
|
167
|
+
raise ArgumentError, 'must be passed a block' unless block_given?
|
168
168
|
value = get_within_scopes(setting_name, scopes)
|
169
169
|
yield value unless value.nil?
|
170
170
|
end
|
@@ -183,9 +183,9 @@ module PDK
|
|
183
183
|
}.merge(options)
|
184
184
|
|
185
185
|
names = key.is_a?(String) ? split_key_string(key) : key
|
186
|
-
raise ArgumentError,
|
186
|
+
raise ArgumentError, 'Invalid configuration names' if names.nil? || !names.is_a?(Array) || names.empty?
|
187
187
|
scope_name = names[0]
|
188
|
-
raise ArgumentError,
|
188
|
+
raise ArgumentError, "Unknown configuration root '%{name}'" % { name: scope_name } if all_scopes[scope_name].nil?
|
189
189
|
deep_set_object(value, options[:force], send(all_scopes[scope_name]), *names[1..-1])
|
190
190
|
end
|
191
191
|
|
@@ -193,7 +193,7 @@ module PDK
|
|
193
193
|
file = PDK::Util::Filesystem.expand_path('~/.puppetlabs/bolt/analytics.yaml')
|
194
194
|
PDK::Config::YAML.new(file: file)
|
195
195
|
rescue PDK::Config::LoadError => e
|
196
|
-
PDK.logger.debug
|
196
|
+
PDK.logger.debug 'Unable to load %{file}: %{message}' % {
|
197
197
|
file: file,
|
198
198
|
message: e.message,
|
199
199
|
}
|
@@ -234,25 +234,23 @@ module PDK
|
|
234
234
|
|
235
235
|
return unless PDK::CLI::Util.interactive?
|
236
236
|
|
237
|
-
pre_message =
|
237
|
+
pre_message =
|
238
238
|
'PDK collects anonymous usage information to help us understand how ' \
|
239
239
|
'it is being used and make decisions on how to improve it. You can ' \
|
240
240
|
'find out more about what data we collect and how it is used in the ' \
|
241
|
-
"PDK documentation at %{url}.\n"
|
242
|
-
|
243
|
-
post_message = _(
|
241
|
+
"PDK documentation at %{url}.\n" % { url: 'https://puppet.com/docs/pdk/latest/pdk_install.html' }
|
242
|
+
post_message =
|
244
243
|
'You can opt in or out of the usage data collection at any time by ' \
|
245
244
|
'editing the analytics configuration file at %{path} and changing ' \
|
246
|
-
"the '%{key}' value."
|
247
|
-
|
248
|
-
path: PDK::Config.analytics_config_path,
|
245
|
+
"the '%{key}' value." % {
|
246
|
+
path: PDK::Config.analytics_config_path,
|
249
247
|
key: 'disabled',
|
250
|
-
|
248
|
+
}
|
251
249
|
|
252
250
|
questions = [
|
253
251
|
{
|
254
252
|
name: 'enabled',
|
255
|
-
question:
|
253
|
+
question: 'Do you consent to the collection of anonymous PDK usage information?',
|
256
254
|
type: :yes,
|
257
255
|
},
|
258
256
|
]
|
@@ -266,7 +264,7 @@ module PDK
|
|
266
264
|
answers = interview.run
|
267
265
|
|
268
266
|
if answers.nil?
|
269
|
-
PDK.logger.info
|
267
|
+
PDK.logger.info 'No answer given, opting out of analytics collection.'
|
270
268
|
PDK.config.set(%w[user analytics disabled], true)
|
271
269
|
else
|
272
270
|
PDK.config.set(%w[user analytics disabled], !answers['enabled'])
|
@@ -304,7 +302,7 @@ module PDK
|
|
304
302
|
# 'user.a.b.c' becomes ['user', 'a', 'b', 'c']
|
305
303
|
# @return [Array[String]] The string split into each setting name as an array
|
306
304
|
def split_key_string(key)
|
307
|
-
raise ArgumentError,
|
305
|
+
raise ArgumentError, 'Expected a String but got \'%{klass}\'' % { klass: key.class } unless key.is_a?(String)
|
308
306
|
key.split('.')
|
309
307
|
end
|
310
308
|
#:nocov:
|
@@ -328,8 +326,8 @@ module PDK
|
|
328
326
|
#
|
329
327
|
# Creating any missing parent hashes during the traversal
|
330
328
|
def deep_set_object(value, force, namespace, *names)
|
331
|
-
raise ArgumentError,
|
332
|
-
raise ArgumentError,
|
329
|
+
raise ArgumentError, 'Missing or invalid namespace' unless namespace.is_a?(PDK::Config::Namespace)
|
330
|
+
raise ArgumentError, 'Missing a name to set' if names.nil? || names.empty?
|
333
331
|
|
334
332
|
name = names.shift
|
335
333
|
current_value = namespace[name]
|
@@ -380,7 +378,7 @@ module PDK
|
|
380
378
|
return value
|
381
379
|
end
|
382
380
|
|
383
|
-
raise ArgumentError,
|
381
|
+
raise ArgumentError, "Unable to set '%{key}' to '%{value}' as it is not a Hash" % { key: namespace.name + '.' + name, value: hash_value } unless current_value.is_a?(Hash)
|
384
382
|
|
385
383
|
namespace[name] = current_value.merge(hash_value)
|
386
384
|
value
|
data/lib/pdk/context/module.rb
CHANGED