bolt 0.15.0 → 0.16.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/lib/bolt/cli.rb +30 -131
- data/lib/bolt/config.rb +35 -9
- data/lib/bolt/executor.rb +33 -7
- data/lib/bolt/node.rb +19 -2
- data/lib/bolt/node/orch.rb +4 -4
- data/lib/bolt/node/ssh.rb +46 -21
- data/lib/bolt/node/winrm.rb +12 -23
- data/lib/bolt/outputter.rb +9 -0
- data/lib/bolt/outputter/human.rb +33 -4
- data/lib/bolt/outputter/json.rb +6 -1
- data/lib/bolt/pal.rb +87 -20
- data/lib/bolt/version.rb +1 -1
- data/modules/boltlib/lib/puppet/functions/run_command.rb +1 -1
- data/modules/boltlib/lib/puppet/functions/run_plan.rb +18 -1
- data/modules/boltlib/lib/puppet/functions/run_script.rb +1 -1
- data/modules/boltlib/lib/puppet/functions/run_task.rb +2 -1
- data/vendored/facter/lib/facter/virtual.rb +2 -0
- data/vendored/hiera/lib/hiera/config.rb +2 -2
- data/vendored/hiera/lib/hiera/version.rb +1 -1
- data/vendored/puppet/lib/hiera/puppet_function.rb +5 -2
- data/vendored/puppet/lib/hiera_puppet.rb +3 -3
- data/vendored/puppet/lib/puppet/agent/locker.rb +6 -5
- data/vendored/puppet/lib/puppet/application/filebucket.rb +23 -6
- data/vendored/puppet/lib/puppet/daemon.rb +2 -2
- data/vendored/puppet/lib/puppet/defaults.rb +42 -10
- data/vendored/puppet/lib/puppet/error.rb +5 -15
- data/vendored/puppet/lib/puppet/external/pson/common.rb +2 -2
- data/vendored/puppet/lib/puppet/face/module/build.rb +1 -0
- data/vendored/puppet/lib/puppet/face/module/install.rb +1 -0
- data/vendored/puppet/lib/puppet/face/module/search.rb +2 -1
- data/vendored/puppet/lib/puppet/face/module/uninstall.rb +1 -0
- data/vendored/puppet/lib/puppet/face/module/upgrade.rb +1 -0
- data/vendored/puppet/lib/puppet/file_bucket/dipper.rb +1 -1
- data/vendored/puppet/lib/puppet/file_serving/base.rb +2 -1
- data/vendored/puppet/lib/puppet/file_serving/configuration/parser.rb +21 -9
- data/vendored/puppet/lib/puppet/file_serving/http_metadata.rb +1 -1
- data/vendored/puppet/lib/puppet/forge.rb +2 -1
- data/vendored/puppet/lib/puppet/functions/binary_file.rb +1 -0
- data/vendored/puppet/lib/puppet/functions/eyaml_lookup_key.rb +4 -2
- data/vendored/puppet/lib/puppet/functions/module_directory.rb +41 -0
- data/vendored/puppet/lib/puppet/functions/strftime.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/unique.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/yaml_data.rb +1 -1
- data/vendored/puppet/lib/puppet/gettext/config.rb +10 -5
- data/vendored/puppet/lib/puppet/graph/relationship_graph.rb +1 -1
- data/vendored/puppet/lib/puppet/indirector/catalog/compiler.rb +1 -1
- data/vendored/puppet/lib/puppet/indirector/exec.rb +1 -1
- data/vendored/puppet/lib/puppet/indirector/facts/facter.rb +3 -3
- data/vendored/puppet/lib/puppet/indirector/facts/network_device.rb +2 -2
- data/vendored/puppet/lib/puppet/indirector/file_bucket_file/file.rb +10 -3
- data/vendored/puppet/lib/puppet/indirector/indirection.rb +17 -9
- data/vendored/puppet/lib/puppet/indirector/ldap.rb +2 -2
- data/vendored/puppet/lib/puppet/indirector/node/write_only_yaml.rb +3 -1
- data/vendored/puppet/lib/puppet/indirector/rest.rb +2 -1
- data/vendored/puppet/lib/puppet/indirector/ssl_file.rb +2 -2
- data/vendored/puppet/lib/puppet/indirector/terminus.rb +3 -3
- data/vendored/puppet/lib/puppet/interface.rb +1 -1
- data/vendored/puppet/lib/puppet/interface/action.rb +41 -24
- data/vendored/puppet/lib/puppet/interface/action_builder.rb +14 -5
- data/vendored/puppet/lib/puppet/interface/action_manager.rb +1 -1
- data/vendored/puppet/lib/puppet/interface/documentation.rb +21 -10
- data/vendored/puppet/lib/puppet/interface/face_collection.rb +4 -2
- data/vendored/puppet/lib/puppet/interface/option.rb +36 -15
- data/vendored/puppet/lib/puppet/interface/option_builder.rb +23 -9
- data/vendored/puppet/lib/puppet/interface/option_manager.rb +8 -3
- data/vendored/puppet/lib/puppet/metatype/manager.rb +7 -3
- data/vendored/puppet/lib/puppet/module.rb +2 -1
- data/vendored/puppet/lib/puppet/module_tool/applications/builder.rb +4 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/installer.rb +3 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/uninstaller.rb +3 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/upgrader.rb +3 -0
- data/vendored/puppet/lib/puppet/module_tool/errors/shared.rb +3 -3
- data/vendored/puppet/lib/puppet/network/auth_config_parser.rb +10 -5
- data/vendored/puppet/lib/puppet/network/authstore.rb +2 -2
- data/vendored/puppet/lib/puppet/network/client_request.rb +1 -1
- data/vendored/puppet/lib/puppet/network/format.rb +3 -3
- data/vendored/puppet/lib/puppet/network/http/api/indirection_type.rb +1 -1
- data/vendored/puppet/lib/puppet/network/http/api/master/v3/environment.rb +5 -2
- data/vendored/puppet/lib/puppet/network/http/webrick.rb +1 -3
- data/vendored/puppet/lib/puppet/node.rb +16 -7
- data/vendored/puppet/lib/puppet/parameter.rb +3 -3
- data/vendored/puppet/lib/puppet/parameter/value_collection.rb +5 -2
- data/vendored/puppet/lib/puppet/parser/ast/leaf.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/ast/node.rb +2 -2
- data/vendored/puppet/lib/puppet/parser/compiler.rb +6 -5
- data/vendored/puppet/lib/puppet/parser/functions.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/fqdn_rand.rb +6 -2
- data/vendored/puppet/lib/puppet/parser/functions/generate.rb +2 -4
- data/vendored/puppet/lib/puppet/parser/functions/inline_template.rb +1 -2
- data/vendored/puppet/lib/puppet/parser/functions/sha256.rb +5 -0
- data/vendored/puppet/lib/puppet/parser/functions/template.rb +6 -2
- data/vendored/puppet/lib/puppet/parser/resource.rb +18 -91
- data/vendored/puppet/lib/puppet/parser/scope.rb +12 -11
- data/vendored/puppet/lib/puppet/parser/templatewrapper.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/collector_transformer.rb +2 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/epp_evaluator.rb +21 -8
- data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +2 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/external_syntax_support.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_converter.rb +3 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_resource_support.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_support.rb +5 -6
- data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/functions/function.rb +8 -2
- data/vendored/puppet/lib/puppet/pops/issue_reporter.rb +7 -2
- data/vendored/puppet/lib/puppet/pops/issues.rb +14 -4
- data/vendored/puppet/lib/puppet/pops/label_provider.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/loader/base_loader.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/loader/dependency_loader.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/loader/loader.rb +6 -1
- data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +27 -6
- data/vendored/puppet/lib/puppet/pops/loader/runtime3_type_loader.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/loaders.rb +7 -3
- data/vendored/puppet/lib/puppet/pops/lookup/explainer.rb +2 -1
- data/vendored/puppet/lib/puppet/pops/merge_strategy.rb +6 -3
- data/vendored/puppet/lib/puppet/pops/migration/migration_checker.rb +8 -8
- data/vendored/puppet/lib/puppet/pops/model/factory.rb +4 -2
- data/vendored/puppet/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/serialization/abstract_writer.rb +2 -1
- data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +6 -2
- data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +36 -15
- data/vendored/puppet/lib/puppet/pops/types/type_calculator.rb +2 -1
- data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +3 -1
- data/vendored/puppet/lib/puppet/pops/types/type_mismatch_describer.rb +4 -1
- data/vendored/puppet/lib/puppet/pops/types/type_parser.rb +75 -7
- data/vendored/puppet/lib/puppet/pops/types/types.rb +9 -5
- data/vendored/puppet/lib/puppet/pops/validation.rb +14 -12
- data/vendored/puppet/lib/puppet/property.rb +14 -6
- data/vendored/puppet/lib/puppet/property/ensure.rb +2 -2
- data/vendored/puppet/lib/puppet/provider.rb +4 -4
- data/vendored/puppet/lib/puppet/provider/group/aix.rb +4 -2
- data/vendored/puppet/lib/puppet/provider/group/groupadd.rb +25 -1
- data/vendored/puppet/lib/puppet/provider/ldap.rb +2 -2
- data/vendored/puppet/lib/puppet/provider/naginator.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/nameservice.rb +7 -4
- data/vendored/puppet/lib/puppet/provider/nameservice/directoryservice.rb +4 -3
- data/vendored/puppet/lib/puppet/provider/nameservice/objectadd.rb +13 -24
- data/vendored/puppet/lib/puppet/provider/nameservice/pw.rb +14 -14
- data/vendored/puppet/lib/puppet/provider/package/aix.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/package/pkg.rb +3 -2
- data/vendored/puppet/lib/puppet/provider/package/yum.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/parsedfile.rb +4 -4
- data/vendored/puppet/lib/puppet/provider/service/base.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/service/launchd.rb +2 -2
- data/vendored/puppet/lib/puppet/provider/service/runit.rb +2 -1
- data/vendored/puppet/lib/puppet/provider/service/systemd.rb +1 -0
- data/vendored/puppet/lib/puppet/provider/service/upstart.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/user/aix.rb +13 -6
- data/vendored/puppet/lib/puppet/provider/user/openbsd.rb +2 -1
- data/vendored/puppet/lib/puppet/provider/user/useradd.rb +33 -4
- data/vendored/puppet/lib/puppet/provider/yumrepo/inifile.rb +2 -1
- data/vendored/puppet/lib/puppet/provider/zone/solaris.rb +2 -2
- data/vendored/puppet/lib/puppet/relationship.rb +2 -1
- data/vendored/puppet/lib/puppet/reports/store.rb +1 -1
- data/vendored/puppet/lib/puppet/resource.rb +7 -5
- data/vendored/puppet/lib/puppet/resource/capability_finder.rb +14 -11
- data/vendored/puppet/lib/puppet/resource/catalog.rb +33 -18
- data/vendored/puppet/lib/puppet/resource/type.rb +5 -5
- data/vendored/puppet/lib/puppet/settings.rb +19 -13
- data/vendored/puppet/lib/puppet/settings/base_setting.rb +23 -8
- data/vendored/puppet/lib/puppet/settings/config_file.rb +14 -4
- data/vendored/puppet/lib/puppet/settings/environment_conf.rb +5 -7
- data/vendored/puppet/lib/puppet/settings/ini_file.rb +4 -0
- data/vendored/puppet/lib/puppet/ssl/base.rb +9 -4
- data/vendored/puppet/lib/puppet/ssl/oids.rb +8 -2
- data/vendored/puppet/lib/puppet/transaction.rb +6 -2
- data/vendored/puppet/lib/puppet/transaction/persistence.rb +15 -0
- data/vendored/puppet/lib/puppet/transaction/report.rb +9 -1
- data/vendored/puppet/lib/puppet/type.rb +26 -26
- data/vendored/puppet/lib/puppet/type/file.rb +2 -1
- data/vendored/puppet/lib/puppet/type/file/data_sync.rb +2 -1
- data/vendored/puppet/lib/puppet/type/file/source.rb +1 -1
- data/vendored/puppet/lib/puppet/type/group.rb +4 -1
- data/vendored/puppet/lib/puppet/type/mount.rb +1 -1
- data/vendored/puppet/lib/puppet/type/resources.rb +1 -1
- data/vendored/puppet/lib/puppet/type/user.rb +12 -7
- data/vendored/puppet/lib/puppet/type/zone.rb +1 -1
- data/vendored/puppet/lib/puppet/util.rb +15 -21
- data/vendored/puppet/lib/puppet/util/at_fork/solaris.rb +6 -4
- data/vendored/puppet/lib/puppet/util/command_line/trollop.rb +6 -5
- data/vendored/puppet/lib/puppet/util/errors.rb +59 -8
- data/vendored/puppet/lib/puppet/util/fileparsing.rb +3 -5
- data/vendored/puppet/lib/puppet/util/http_proxy.rb +14 -6
- data/vendored/puppet/lib/puppet/util/instance_loader.rb +1 -3
- data/vendored/puppet/lib/puppet/util/ldap/manager.rb +6 -3
- data/vendored/puppet/lib/puppet/util/log.rb +15 -21
- data/vendored/puppet/lib/puppet/util/logging.rb +21 -28
- data/vendored/puppet/lib/puppet/util/methodhelper.rb +1 -1
- data/vendored/puppet/lib/puppet/util/nagios_maker.rb +1 -1
- data/vendored/puppet/lib/puppet/util/network_device/config.rb +20 -13
- data/vendored/puppet/lib/puppet/util/platform.rb +13 -0
- data/vendored/puppet/lib/puppet/util/posix.rb +1 -1
- data/vendored/puppet/lib/puppet/util/provider_features.rb +1 -1
- data/vendored/puppet/lib/puppet/util/rdoc/generators/puppet_generator.rb +1 -1
- data/vendored/puppet/lib/puppet/util/selinux.rb +1 -1
- data/vendored/puppet/lib/puppet/util/windows/eventlog.rb +10 -5
- data/vendored/puppet/lib/puppet/util/windows/file.rb +61 -9
- data/vendored/puppet/lib/puppet/util/windows/process.rb +1 -1
- data/vendored/puppet/lib/puppet/util/windows/taskscheduler.rb +2 -2
- data/vendored/puppet/lib/puppet/version.rb +1 -1
- data/vendored/puppet/lib/puppet_pal.rb +23 -22
- metadata +4 -2
@@ -802,7 +802,9 @@ class Factory
|
|
802
802
|
end
|
803
803
|
else
|
804
804
|
# Bad number should already have been caught by lexer - this should never happen
|
805
|
-
|
805
|
+
#TRANSLATORS 'NUMBER' refers to a method name and the 'name_or_numeric' was the passed in value and should not be translated
|
806
|
+
raise ArgumentError, _("Internal Error, NUMBER token does not contain a valid number, %{name_or_numeric}") %
|
807
|
+
{ name_or_numeric: name_or_numeric }
|
806
808
|
end
|
807
809
|
end
|
808
810
|
|
@@ -1109,7 +1111,7 @@ class Factory
|
|
1109
1111
|
elsif e.is_a?(String)
|
1110
1112
|
result << e
|
1111
1113
|
else
|
1112
|
-
raise ArgumentError, "can only concatenate strings, got
|
1114
|
+
raise ArgumentError, _("can only concatenate strings, got %{class_name}") % { class_name: e.class }
|
1113
1115
|
end
|
1114
1116
|
end
|
1115
1117
|
infer(result)
|
@@ -164,7 +164,7 @@ class ResourceTypeImpl
|
|
164
164
|
# the 'package' type where 'provider' attribute is handled as part of the key without being
|
165
165
|
# set from the title.
|
166
166
|
#
|
167
|
-
raise Puppet::DevError,"you must specify title patterns when there are two or more key attributes"
|
167
|
+
raise Puppet::DevError, _("you must specify title patterns when there are two or more key attributes")
|
168
168
|
end
|
169
169
|
@title_patterns_hash.nil? ? [] : @title_patterns_hash.map { |k,v| [ k, v.map { |n| [ n.to_sym] } ] }
|
170
170
|
end
|
@@ -99,7 +99,8 @@ class AbstractWriter
|
|
99
99
|
#
|
100
100
|
# @api private
|
101
101
|
def write_tpl(ep, value)
|
102
|
-
|
102
|
+
#TRANSLATORS 'Integers' is a Ruby class for numbers and should not be translated
|
103
|
+
raise ArgumentError, _('Internal error. Integers cannot be tabulated in extension payload') if value.is_a?(Integer)
|
103
104
|
if @tabulate
|
104
105
|
index = @written[value]
|
105
106
|
if index.nil?
|
@@ -188,17 +188,21 @@ module Serialization
|
|
188
188
|
end
|
189
189
|
|
190
190
|
def unknown_key_to_string_with_warning(value)
|
191
|
-
str = value
|
191
|
+
str = unknown_to_string(value)
|
192
192
|
serialization_issue(Issues::SERIALIZATION_UNKNOWN_KEY_CONVERTED_TO_STRING, :path => path_to_s, :klass => value.class, :value => str)
|
193
193
|
str
|
194
194
|
end
|
195
195
|
|
196
196
|
def unknown_to_string_with_warning(value)
|
197
|
-
str = value
|
197
|
+
str = unknown_to_string(value)
|
198
198
|
serialization_issue(Issues::SERIALIZATION_UNKNOWN_CONVERTED_TO_STRING, :path => path_to_s, :klass => value.class, :value => str)
|
199
199
|
str
|
200
200
|
end
|
201
201
|
|
202
|
+
def unknown_to_string(value)
|
203
|
+
value.is_a?(Regexp) ? Puppet::Pops::Types::PRegexpType.regexp_to_s_with_delimiters(value) : value.to_s
|
204
|
+
end
|
205
|
+
|
202
206
|
def non_string_keyed_hash_to_data(hash)
|
203
207
|
if @rich_data
|
204
208
|
to_key_extended_hash(hash)
|
@@ -143,7 +143,10 @@ class PObjectType < PMetaType
|
|
143
143
|
def assert_override(parent_members)
|
144
144
|
parent_member = parent_members[@name]
|
145
145
|
if parent_member.nil?
|
146
|
-
|
146
|
+
if @override
|
147
|
+
raise Puppet::ParseError, _("expected %{label} to override an inherited %{feature_type}, but no such %{feature_type} was found") %
|
148
|
+
{ label: label, feature_type: feature_type }
|
149
|
+
end
|
147
150
|
self
|
148
151
|
else
|
149
152
|
parent_member.assert_can_be_overridden(self)
|
@@ -157,10 +160,19 @@ class PObjectType < PMetaType
|
|
157
160
|
# @raises [Puppet::ParseError] if the assertion fails
|
158
161
|
# @api private
|
159
162
|
def assert_can_be_overridden(member)
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
163
|
+
unless self.class == member.class
|
164
|
+
raise Puppet::ParseError, _("%{member} attempts to override %{label}") % { member: member.label, label: label }
|
165
|
+
end
|
166
|
+
if @final && !(constant? && member.constant?)
|
167
|
+
raise Puppet::ParseError, _("%{member} attempts to override final %{label}") % { member: member.label, label: label }
|
168
|
+
end
|
169
|
+
unless member.override?
|
170
|
+
#TRANSLATOR 'override => true' is a puppet syntax and should not be translated
|
171
|
+
raise Puppet::ParseError, _("%{member} attempts to override %{label} without having override => true") % { member: member.label, label: label }
|
172
|
+
end
|
173
|
+
unless @type.assignable?(member.type)
|
174
|
+
raise Puppet::ParseError, _("%{member} attempts to override %{label} with a type that does not match") % { member: member.label, label: label }
|
175
|
+
end
|
164
176
|
member
|
165
177
|
end
|
166
178
|
|
@@ -275,19 +287,20 @@ class PObjectType < PMetaType
|
|
275
287
|
@kind = init_hash[KEY_KIND]
|
276
288
|
if @kind == ATTRIBUTE_KIND_CONSTANT # final is implied
|
277
289
|
if init_hash.include?(KEY_FINAL) && !@final
|
278
|
-
|
290
|
+
#TRANSLATOR 'final => false' is puppet syntax and should not be translated
|
291
|
+
raise Puppet::ParseError, _("%{label} of kind 'constant' cannot be combined with final => false") % { label: label }
|
279
292
|
end
|
280
293
|
@final = true
|
281
294
|
end
|
282
295
|
|
283
296
|
if init_hash.include?(KEY_VALUE)
|
284
297
|
if @kind == ATTRIBUTE_KIND_DERIVED || @kind == ATTRIBUTE_KIND_GIVEN_OR_DERIVED
|
285
|
-
raise Puppet::ParseError, "
|
298
|
+
raise Puppet::ParseError, _("%{label} of kind '%{kind}' cannot be combined with an attribute value") % { label: label, kind: @kind }
|
286
299
|
end
|
287
300
|
v = init_hash[KEY_VALUE]
|
288
301
|
@value = v == :default ? v : TypeAsserter.assert_instance_of(nil, type, v) {"#{label} #{KEY_VALUE}" }
|
289
302
|
else
|
290
|
-
raise Puppet::ParseError, "
|
303
|
+
raise Puppet::ParseError, _("%{label} of kind 'constant' requires a value") % { label: label } if @kind == ATTRIBUTE_KIND_CONSTANT
|
291
304
|
@value = :undef # Not to be confused with nil or :default
|
292
305
|
end
|
293
306
|
end
|
@@ -703,7 +716,9 @@ class PObjectType < PMetaType
|
|
703
716
|
end
|
704
717
|
unless constants.nil? || constants.empty?
|
705
718
|
constants.each do |key, value|
|
706
|
-
|
719
|
+
if attr_specs.include?(key)
|
720
|
+
raise Puppet::ParseError, _("attribute %{label}[%{key}] is defined as both a constant and an attribute") % { label: label, key: key }
|
721
|
+
end
|
707
722
|
attr_spec = {
|
708
723
|
# Type must be generic here, or overrides would become impossible
|
709
724
|
KEY_TYPE => TypeCalculator.infer(value).generalize,
|
@@ -734,7 +749,7 @@ class PObjectType < PMetaType
|
|
734
749
|
func_spec = { KEY_TYPE => TypeAsserter.assert_instance_of(nil, TYPE_FUNCTION_TYPE, func_spec) { "function #{label}[#{key}]" } } unless func_spec.is_a?(Hash)
|
735
750
|
func = PFunction.new(key, self, func_spec)
|
736
751
|
name = func.name
|
737
|
-
raise Puppet::ParseError, "
|
752
|
+
raise Puppet::ParseError, _("%{label} conflicts with attribute with the same name") % { label: func.label } if @attributes.include?(name)
|
738
753
|
[name, func.assert_override(parent_members)]
|
739
754
|
end].freeze
|
740
755
|
end
|
@@ -746,7 +761,8 @@ class PObjectType < PMetaType
|
|
746
761
|
equality = [equality] if equality.is_a?(String)
|
747
762
|
if equality.is_a?(Array)
|
748
763
|
unless equality.empty?
|
749
|
-
|
764
|
+
#TRANSLATORS equality_include_type = false should not be translated
|
765
|
+
raise Puppet::ParseError, _('equality_include_type = false cannot be combined with non empty equality specification') unless @equality_include_type
|
750
766
|
parent_eq_attrs = nil
|
751
767
|
equality.each do |attr_name|
|
752
768
|
|
@@ -758,16 +774,21 @@ class PObjectType < PMetaType
|
|
758
774
|
parent_eq_attrs ||= parent_object_type.equality_attributes
|
759
775
|
if parent_eq_attrs.include?(attr_name)
|
760
776
|
including_parent = find_equality_definer_of(attr)
|
761
|
-
raise Puppet::ParseError, "
|
777
|
+
raise Puppet::ParseError, _("%{label} equality is referencing %{attribute} which is included in equality of %{including_parent}") %
|
778
|
+
{ label: label, attribute: attr.label, including_parent: including_parent.label }
|
762
779
|
end
|
763
780
|
end
|
764
781
|
|
765
782
|
unless attr.is_a?(PAttribute)
|
766
|
-
|
767
|
-
|
783
|
+
if attr.nil?
|
784
|
+
raise Puppet::ParseError, _("%{label} equality is referencing non existent attribute '%{attribute}'") % { label: label, attribute: attr_name }
|
785
|
+
end
|
786
|
+
raise Puppet::ParseError, _("%{label} equality is referencing %{attribute}. Only attribute references are allowed") %
|
787
|
+
{ label: label, attribute: attr.label }
|
768
788
|
end
|
769
789
|
if attr.kind == ATTRIBUTE_KIND_CONSTANT
|
770
|
-
raise Puppet::ParseError, "
|
790
|
+
raise Puppet::ParseError, _("%{label} equality is referencing constant %{attribute}.") % { label: label, attribute: attr.label } + ' ' +
|
791
|
+
_("Reference to constant is not allowed in equality")
|
771
792
|
end
|
772
793
|
end
|
773
794
|
end
|
@@ -163,7 +163,8 @@ class TypeCalculator
|
|
163
163
|
|
164
164
|
# Returns an iterable if the t represents something that can be iterated
|
165
165
|
def enumerable(t)
|
166
|
-
|
166
|
+
#TRANSLATOR 'TypeCalculator.enumerable' and 'iterable' are methods and should not be translated
|
167
|
+
Puppet.deprecation_warning(_('TypeCalculator.enumerable is deprecated. Use iterable'))
|
167
168
|
iterable(t)
|
168
169
|
end
|
169
170
|
|
@@ -100,7 +100,9 @@ module TypeFactory
|
|
100
100
|
size_type_or_value.nil? ? PStringType::DEFAULT : PStringType.new(size_type_or_value)
|
101
101
|
else
|
102
102
|
if Puppet[:strict] != :off
|
103
|
-
|
103
|
+
#TRANSLATORS 'TypeFactory#string' is a class and method name and should not be translated
|
104
|
+
message = _("Passing more than one argument to TypeFactory#string is deprecated")
|
105
|
+
Puppet.warn_once('deprecations', "TypeFactory#string_multi_args", message)
|
104
106
|
end
|
105
107
|
deprecated_second_argument.size == 1 ? PStringType.new(deprecated_second_argument[0]) : PEnumType.new(*deprecated_second_argument)
|
106
108
|
end
|
@@ -512,7 +512,10 @@ module Types
|
|
512
512
|
end
|
513
513
|
|
514
514
|
def tense_deprecated
|
515
|
-
|
515
|
+
#TRANSLATORS TypeMismatchDescriber is a class name and 'tense' is a method name and should not be translated
|
516
|
+
message = _("Passing a 'tense' argument to the TypeMismatchDescriber is deprecated and ignored.")
|
517
|
+
message += ' ' + _("Everything is now reported using present tense")
|
518
|
+
Puppet.warn_once('deprecations', 'typemismatch#tense', message)
|
516
519
|
end
|
517
520
|
|
518
521
|
# Validates that all entries in the give_hash exists in the given param_struct, that their type conforms
|
@@ -33,6 +33,10 @@ class TypeParser
|
|
33
33
|
# @api public
|
34
34
|
#
|
35
35
|
def parse(string, context = nil)
|
36
|
+
# quick "peephole" optimization of common data types
|
37
|
+
if t = self.class.opt_type_map[string]
|
38
|
+
return t
|
39
|
+
end
|
36
40
|
model = @parser.parse_string(string)
|
37
41
|
interpret(model.model.body, context)
|
38
42
|
end
|
@@ -205,6 +209,70 @@ class TypeParser
|
|
205
209
|
}.freeze
|
206
210
|
end
|
207
211
|
|
212
|
+
# @api private
|
213
|
+
def self.opt_type_map
|
214
|
+
# Map of common (and simple to optimize) data types in string form
|
215
|
+
# (Note that some types are the result of evaluation even if they appear to be simple
|
216
|
+
# - for example 'Data' and they cannot be optimized this way since the factory calls
|
217
|
+
# back to the parser for evaluation).
|
218
|
+
#
|
219
|
+
@opt_type_map ||= {
|
220
|
+
'Integer' => TypeFactory.integer,
|
221
|
+
'Float' => TypeFactory.float,
|
222
|
+
'Numeric' => TypeFactory.numeric,
|
223
|
+
|
224
|
+
'String' => TypeFactory.string,
|
225
|
+
'String[1]' => TypeFactory.string(TypeFactory.range(1, :default)),
|
226
|
+
|
227
|
+
'Binary' => TypeFactory.binary,
|
228
|
+
|
229
|
+
'Boolean' => TypeFactory.boolean,
|
230
|
+
'Boolean[true]' => TypeFactory.boolean(true),
|
231
|
+
'Boolean[false]' => TypeFactory.boolean(false),
|
232
|
+
|
233
|
+
'Array' => TypeFactory.array_of_any,
|
234
|
+
'Array[1]' => TypeFactory.array_of(TypeFactory.any, TypeFactory.range(1, :default)),
|
235
|
+
|
236
|
+
'Hash' => TypeFactory.hash_of_any,
|
237
|
+
'Collection' => TypeFactory.collection,
|
238
|
+
'Scalar' => TypeFactory.scalar,
|
239
|
+
|
240
|
+
'Scalardata' => TypeFactory.scalar_data,
|
241
|
+
'ScalarData' => TypeFactory.scalar_data,
|
242
|
+
|
243
|
+
'Catalogentry' => TypeFactory.catalog_entry,
|
244
|
+
'CatalogEntry' => TypeFactory.catalog_entry,
|
245
|
+
|
246
|
+
'Undef' => TypeFactory.undef,
|
247
|
+
'Default' => TypeFactory.default,
|
248
|
+
'Any' => TypeFactory.any,
|
249
|
+
'Type' => TypeFactory.type_type,
|
250
|
+
'Callable' => TypeFactory.all_callables,
|
251
|
+
|
252
|
+
'Semver' => TypeFactory.sem_ver,
|
253
|
+
'SemVer' => TypeFactory.sem_ver,
|
254
|
+
|
255
|
+
'Semverrange' => TypeFactory.sem_ver_range,
|
256
|
+
'SemVerRange' => TypeFactory.sem_ver_range,
|
257
|
+
|
258
|
+
'Timestamp' => TypeFactory.timestamp,
|
259
|
+
'TimeStamp' => TypeFactory.timestamp,
|
260
|
+
|
261
|
+
'Timespan' => TypeFactory.timespan,
|
262
|
+
'TimeSpan' => TypeFactory.timespan,
|
263
|
+
|
264
|
+
'Uri' => TypeFactory.uri,
|
265
|
+
'URI' => TypeFactory.uri,
|
266
|
+
|
267
|
+
'Optional[Integer]' => TypeFactory.optional(TypeFactory.integer),
|
268
|
+
'Optional[String]' => TypeFactory.optional(TypeFactory.string),
|
269
|
+
'Optional[String[1]]' => TypeFactory.optional(TypeFactory.string(TypeFactory.range(1, :default))),
|
270
|
+
'Optional[Array]' => TypeFactory.optional(TypeFactory.array_of_any),
|
271
|
+
'Optional[Hash]' => TypeFactory.optional(TypeFactory.hash_of_any),
|
272
|
+
|
273
|
+
}.freeze
|
274
|
+
end
|
275
|
+
|
208
276
|
# @api private
|
209
277
|
def interpret_QualifiedReference(name_ast, context)
|
210
278
|
name = name_ast.value
|
@@ -349,7 +417,7 @@ class TypeParser
|
|
349
417
|
case_insensitive = last
|
350
418
|
end
|
351
419
|
raise_invalid_parameters_error('Enum', '1 or more', parameters.size) unless parameters.size >= 1
|
352
|
-
parameters.each { |p|
|
420
|
+
parameters.each { |p| raise Puppet::ParseError, _('Enum parameters must be identifiers or strings') unless p.is_a?(String) }
|
353
421
|
PEnumType.new(parameters, case_insensitive)
|
354
422
|
|
355
423
|
when 'pattern'
|
@@ -585,21 +653,21 @@ class TypeParser
|
|
585
653
|
end
|
586
654
|
|
587
655
|
def raise_invalid_type_specification_error(ast)
|
588
|
-
raise Puppet::ParseError,
|
589
|
-
|
656
|
+
raise Puppet::ParseError, _("The expression <%{expression}> is not a valid type specification.") %
|
657
|
+
{ expression: original_text_of(ast) }
|
590
658
|
end
|
591
659
|
|
592
660
|
def raise_invalid_parameters_error(type, required, given)
|
593
|
-
raise Puppet::ParseError,
|
594
|
-
|
661
|
+
raise Puppet::ParseError, _("Invalid number of type parameters specified: %{type} requires %{required}, %{given} provided") %
|
662
|
+
{ type: type, required: required, given: given }
|
595
663
|
end
|
596
664
|
|
597
665
|
def raise_unparameterized_type_error(ast)
|
598
|
-
raise Puppet::ParseError, "Not a parameterized type
|
666
|
+
raise Puppet::ParseError, _("Not a parameterized type <%{type}>") % { type: original_text_of(ast) }
|
599
667
|
end
|
600
668
|
|
601
669
|
def raise_unknown_type_error(ast)
|
602
|
-
raise Puppet::ParseError, "Unknown type
|
670
|
+
raise Puppet::ParseError, _("Unknown type <%{type}>") % { type: original_text_of(ast) }
|
603
671
|
end
|
604
672
|
|
605
673
|
def original_text_of(ast)
|
@@ -1313,7 +1313,7 @@ class PCollectionType < PAnyType
|
|
1313
1313
|
attr_reader :size_type
|
1314
1314
|
|
1315
1315
|
def initialize(size_type)
|
1316
|
-
@size_type = size_type
|
1316
|
+
@size_type = size_type.nil? ? nil : size_type.to_size
|
1317
1317
|
end
|
1318
1318
|
|
1319
1319
|
def accept(visitor, guard)
|
@@ -1504,11 +1504,13 @@ class PStringType < PScalarDataType
|
|
1504
1504
|
def initialize(size_type_or_value, deprecated_multi_args = EMPTY_ARRAY)
|
1505
1505
|
unless deprecated_multi_args.empty?
|
1506
1506
|
if Puppet[:strict] != :off
|
1507
|
-
|
1507
|
+
#TRANSLATORS 'PStringType#initialize' is a class and method name and should not be translated
|
1508
|
+
Puppet.warn_once('deprecations', "PStringType#initialize_multi_args",
|
1509
|
+
_("Passing more than one argument to PStringType#initialize is deprecated"))
|
1508
1510
|
end
|
1509
1511
|
size_type_or_value = deprecated_multi_args[0]
|
1510
1512
|
end
|
1511
|
-
@size_type_or_value = size_type_or_value
|
1513
|
+
@size_type_or_value = size_type_or_value.is_a?(PIntegerType) ? size_type_or_value.to_size : size_type_or_value
|
1512
1514
|
end
|
1513
1515
|
|
1514
1516
|
def accept(visitor, guard)
|
@@ -1557,7 +1559,8 @@ class PStringType < PScalarDataType
|
|
1557
1559
|
# @api private
|
1558
1560
|
def values
|
1559
1561
|
if Puppet[:strict] != :off
|
1560
|
-
|
1562
|
+
#TRANSLATORS 'PStringType#values' and '#value' are classes and method names and should not be translated
|
1563
|
+
Puppet.warn_once('deprecations', "PStringType#values", _("Method PStringType#values is deprecated. Use #value instead"))
|
1561
1564
|
end
|
1562
1565
|
@value.is_a?(String) ? [@value] : EMPTY_ARRAY
|
1563
1566
|
end
|
@@ -2704,8 +2707,9 @@ class PHashType < PCollectionType
|
|
2704
2707
|
|
2705
2708
|
def element_type
|
2706
2709
|
if Puppet[:strict] != :off
|
2710
|
+
#TRANSLATOR 'Puppet::Pops::Types::PHashType#element_type' and '#value_type' are class and method names and should not be translated
|
2707
2711
|
Puppet.warn_once('deprecations', 'Puppet::Pops::Types::PHashType#element_type',
|
2708
|
-
'Puppet::Pops::Types::PHashType#element_type is deprecated, use #value_type instead')
|
2712
|
+
_('Puppet::Pops::Types::PHashType#element_type is deprecated, use #value_type instead'))
|
2709
2713
|
end
|
2710
2714
|
@value_type
|
2711
2715
|
end
|
@@ -125,9 +125,15 @@ module Validation
|
|
125
125
|
# @api public
|
126
126
|
#
|
127
127
|
def []=(issue, level)
|
128
|
-
|
129
|
-
|
130
|
-
|
128
|
+
unless issue.is_a? Issues::Issue
|
129
|
+
raise Puppet::DevError.new(_("Attempt to set validation severity for something that is not an Issue. (Got %{issue})") % { issue: issue.class })
|
130
|
+
end
|
131
|
+
unless @@severity_hash[level]
|
132
|
+
raise Puppet::DevError.new(_("Illegal severity level: %{level} for '%{issue_code}'") % { issue_code: issue.issue_code, level: level })
|
133
|
+
end
|
134
|
+
unless issue.demotable? || level == :error
|
135
|
+
raise Puppet::DevError.new(_("Attempt to demote the hard issue '%{issue_code}' to %{level}") % { issue_code: issue.issue_code, level: level })
|
136
|
+
end
|
131
137
|
@severities[issue] = level
|
132
138
|
end
|
133
139
|
|
@@ -145,14 +151,9 @@ module Validation
|
|
145
151
|
# @api private
|
146
152
|
#
|
147
153
|
def assert_issue issue
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
# Checks if the given severity level is valid.
|
152
|
-
# @api private
|
153
|
-
#
|
154
|
-
def assert_severity level
|
155
|
-
raise Puppet::DevError.new("Illegal severity level: #{option}") unless @@severity_hash[level]
|
154
|
+
unless issue.is_a? Issues::Issue
|
155
|
+
raise Puppet::DevError.new(_("Attempt to get validation severity for something that is not an Issue. (Got %{issue})") % { issue: issue.class })
|
156
|
+
end
|
156
157
|
end
|
157
158
|
end
|
158
159
|
|
@@ -203,7 +204,8 @@ module Validation
|
|
203
204
|
# Accept an Error as semantic if it supports methods #file(), #line(), and #pos()
|
204
205
|
if semantic.is_a?(StandardError)
|
205
206
|
unless semantic.respond_to?(:file) && semantic.respond_to?(:line) && semantic.respond_to?(:pos)
|
206
|
-
raise Puppet::DevError("Issue
|
207
|
+
raise Puppet::DevError, _("Issue %{issue_code}: Cannot pass a %{class_name} as a semantic object when it does not support #pos(), #file() and #line()") %
|
208
|
+
{ issue_code: issue.issue_code, class_name: semantic.class }
|
207
209
|
end
|
208
210
|
end
|
209
211
|
|
@@ -95,7 +95,8 @@ class Puppet::Property < Puppet::Parameter
|
|
95
95
|
#
|
96
96
|
def array_matching=(value)
|
97
97
|
value = value.intern if value.is_a?(String)
|
98
|
-
|
98
|
+
#TRANSLATORS 'Property#array_matching', 'first', and 'all' should not be translated
|
99
|
+
raise ArgumentError, _("Supported values for Property#array_matching are 'first' and 'all'") unless [:first, :all].include?(value)
|
99
100
|
@array_matching = value
|
100
101
|
end
|
101
102
|
|
@@ -167,7 +168,7 @@ class Puppet::Property < Puppet::Parameter
|
|
167
168
|
method = value.method.to_sym
|
168
169
|
if value.block
|
169
170
|
if instance_methods(false).include?(method)
|
170
|
-
raise ArgumentError, "Attempt to redefine method
|
171
|
+
raise ArgumentError, _("Attempt to redefine method %{method} with block") % { method: method }
|
171
172
|
end
|
172
173
|
define_method(method, &value.block)
|
173
174
|
else
|
@@ -211,7 +212,7 @@ class Puppet::Property < Puppet::Parameter
|
|
211
212
|
rescue Puppet::Error, Puppet::DevError
|
212
213
|
raise
|
213
214
|
rescue => detail
|
214
|
-
message = "Could not convert change '
|
215
|
+
message = _("Could not convert change '%{name}' to string: %{detail}") % { name: name, detail: detail }
|
215
216
|
Puppet.log_exception(detail, message)
|
216
217
|
raise Puppet::DevError, message, detail.backtrace
|
217
218
|
end
|
@@ -367,7 +368,9 @@ class Puppet::Property < Puppet::Parameter
|
|
367
368
|
rescue
|
368
369
|
# Certain operations may fail, but we don't want to fail the transaction if we can
|
369
370
|
# avoid it
|
370
|
-
|
371
|
+
#TRANSLATORS 'insync_values?' should not be translated
|
372
|
+
msg = _("Unknown failure using insync_values? on type: %{type} / property: %{name} to compare values %{should} and %{is}") %
|
373
|
+
{ type: self.resource.ref, name: self.name, should: should, is: is }
|
371
374
|
Puppet.info(msg)
|
372
375
|
|
373
376
|
# Return nil, ie. unknown
|
@@ -489,7 +492,8 @@ class Puppet::Property < Puppet::Parameter
|
|
489
492
|
rescue Puppet::Error
|
490
493
|
raise
|
491
494
|
rescue => detail
|
492
|
-
error = Puppet::ResourceError.new("Could not set '
|
495
|
+
error = Puppet::ResourceError.new(_("Could not set '%{value}' on %{class_name}: %{detail}") %
|
496
|
+
{ value: value, class_name: self.class.name, detail: detail }, @resource.file, @resource.line, detail)
|
493
497
|
error.set_backtrace detail.backtrace
|
494
498
|
Puppet.log_exception(detail, error.message)
|
495
499
|
raise error
|
@@ -584,7 +588,11 @@ class Puppet::Property < Puppet::Parameter
|
|
584
588
|
if features = self.class.value_option(self.class.value_name(value), :required_features)
|
585
589
|
features = Array(features)
|
586
590
|
needed_features = features.collect { |f| f.to_s }.join(", ")
|
587
|
-
|
591
|
+
unless provider.satisfies?(features)
|
592
|
+
#TRANSLATORS 'Provider' refers to a Puppet provider class
|
593
|
+
raise ArgumentError, _("Provider %{provider} must have features '%{needed_features}' to set '%{property}' to '%{value}'") %
|
594
|
+
{ provider: provider.class.name, needed_features: needed_features, property: self.class.name, value: value }
|
595
|
+
end
|
588
596
|
end
|
589
597
|
end
|
590
598
|
|