puppet 4.7.1-universal-darwin → 4.8.0-universal-darwin
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/Gemfile +0 -3
- data/MAINTAINERS +76 -0
- data/README.md +0 -6
- data/Rakefile +2 -2
- data/lib/puppet/agent.rb +3 -3
- data/lib/puppet/application/apply.rb +1 -1
- data/lib/puppet/configurer.rb +2 -2
- data/lib/puppet/data_providers.rb +1 -0
- data/lib/puppet/data_providers/data_adapter.rb +1 -0
- data/lib/puppet/data_providers/data_function_support.rb +1 -0
- data/lib/puppet/data_providers/function_env_data_provider.rb +1 -0
- data/lib/puppet/data_providers/function_module_data_provider.rb +1 -0
- data/lib/puppet/data_providers/hiera_config.rb +1 -0
- data/lib/puppet/data_providers/hiera_env_data_provider.rb +1 -0
- data/lib/puppet/data_providers/hiera_interpolate.rb +1 -0
- data/lib/puppet/data_providers/hiera_module_data_provider.rb +1 -0
- data/lib/puppet/data_providers/hiera_support.rb +1 -2
- data/lib/puppet/data_providers/json_data_provider_factory.rb +2 -0
- data/lib/puppet/data_providers/yaml_data_provider_factory.rb +2 -0
- data/lib/puppet/defaults.rb +20 -1
- data/lib/puppet/environments.rb +5 -2
- data/lib/puppet/face/catalog.rb +1 -1
- data/lib/puppet/face/epp.rb +57 -11
- data/lib/puppet/face/module/install.rb +6 -6
- data/lib/puppet/functions.rb +23 -24
- data/lib/puppet/functions/alert.rb +14 -0
- data/lib/puppet/functions/binary_file.rb +25 -0
- data/lib/puppet/functions/break.rb +22 -0
- data/lib/puppet/functions/contain.rb +33 -0
- data/lib/puppet/functions/crit.rb +14 -0
- data/lib/puppet/functions/debug.rb +14 -0
- data/lib/puppet/functions/emerg.rb +14 -0
- data/lib/puppet/functions/epp.rb +1 -1
- data/lib/puppet/functions/err.rb +14 -0
- data/lib/puppet/functions/find_file.rb +31 -0
- data/lib/puppet/functions/include.rb +21 -0
- data/lib/puppet/functions/info.rb +14 -0
- data/lib/puppet/functions/new.rb +1 -1
- data/lib/puppet/functions/next.rb +23 -0
- data/lib/puppet/functions/notice.rb +14 -0
- data/lib/puppet/functions/regsubst.rb +12 -16
- data/lib/puppet/functions/require.rb +37 -0
- data/lib/puppet/functions/return.rb +22 -0
- data/lib/puppet/functions/strftime.rb +35 -0
- data/lib/puppet/functions/warning.rb +14 -0
- data/lib/puppet/generate/models/type/type.rb +4 -0
- data/lib/puppet/generate/templates/type/pcore.erb +2 -1
- data/lib/puppet/indirector/face.rb +6 -1
- data/lib/puppet/network/http/error.rb +2 -2
- data/lib/puppet/network/http/handler.rb +2 -2
- data/lib/puppet/node/environment.rb +11 -0
- data/lib/puppet/parser/ast.rb +5 -0
- data/lib/puppet/parser/ast/pops_bridge.rb +17 -4
- data/lib/puppet/parser/compiler.rb +29 -1
- data/lib/puppet/parser/functions.rb +6 -0
- data/lib/puppet/parser/functions/assert_type.rb +1 -1
- data/lib/puppet/parser/functions/binary_file.rb +24 -0
- data/lib/puppet/parser/functions/break.rb +39 -0
- data/lib/puppet/parser/functions/contain.rb +7 -15
- data/lib/puppet/parser/functions/defined.rb +2 -2
- data/lib/puppet/parser/functions/dig.rb +1 -1
- data/lib/puppet/parser/functions/each.rb +1 -1
- data/lib/puppet/parser/functions/epp.rb +2 -2
- data/lib/puppet/parser/functions/filter.rb +1 -1
- data/lib/puppet/parser/functions/find_file.rb +28 -0
- data/lib/puppet/parser/functions/hiera.rb +4 -4
- data/lib/puppet/parser/functions/hiera_array.rb +1 -1
- data/lib/puppet/parser/functions/hiera_hash.rb +1 -1
- data/lib/puppet/parser/functions/hiera_include.rb +1 -1
- data/lib/puppet/parser/functions/include.rb +4 -8
- data/lib/puppet/parser/functions/inline_epp.rb +1 -1
- data/lib/puppet/parser/functions/lest.rb +1 -1
- data/lib/puppet/parser/functions/lookup.rb +4 -2
- data/lib/puppet/parser/functions/map.rb +1 -1
- data/lib/puppet/parser/functions/match.rb +1 -1
- data/lib/puppet/parser/functions/new.rb +414 -18
- data/lib/puppet/parser/functions/next.rb +38 -0
- data/lib/puppet/parser/functions/reduce.rb +1 -1
- data/lib/puppet/parser/functions/regsubst.rb +4 -2
- data/lib/puppet/parser/functions/require.rb +4 -27
- data/lib/puppet/parser/functions/return.rb +71 -0
- data/lib/puppet/parser/functions/reverse_each.rb +1 -1
- data/lib/puppet/parser/functions/scanf.rb +13 -8
- data/lib/puppet/parser/functions/slice.rb +1 -1
- data/lib/puppet/parser/functions/split.rb +1 -1
- data/lib/puppet/parser/functions/step.rb +1 -1
- data/lib/puppet/parser/functions/strftime.rb +185 -0
- data/lib/puppet/parser/functions/then.rb +1 -1
- data/lib/puppet/parser/functions/type.rb +1 -1
- data/lib/puppet/parser/functions/with.rb +3 -3
- data/lib/puppet/parser/resource.rb +8 -5
- data/lib/puppet/parser/scope.rb +1 -1
- data/lib/puppet/plugins/configuration.rb +8 -0
- data/lib/puppet/plugins/data_providers.rb +1 -0
- data/lib/puppet/plugins/data_providers/data_provider.rb +7 -28
- data/lib/puppet/plugins/data_providers/registry.rb +1 -0
- data/lib/puppet/pops.rb +4 -0
- data/lib/puppet/pops/evaluator/access_operator.rb +36 -5
- data/lib/puppet/pops/evaluator/closure.rb +81 -12
- data/lib/puppet/pops/evaluator/compare_operator.rb +24 -1
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +29 -5
- data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +53 -62
- data/lib/puppet/pops/evaluator/runtime3_support.rb +15 -6
- data/lib/puppet/pops/functions/dispatch.rb +9 -2
- data/lib/puppet/pops/functions/dispatcher.rb +3 -1
- data/lib/puppet/pops/functions/function.rb +19 -2
- data/lib/puppet/pops/issues.rb +9 -0
- data/lib/puppet/pops/label_provider.rb +2 -2
- data/lib/puppet/pops/loader/loader.rb +17 -0
- data/lib/puppet/pops/loader/static_loader.rb +0 -41
- data/lib/puppet/pops/lookup.rb +12 -0
- data/lib/puppet/pops/lookup/context.rb +86 -0
- data/lib/puppet/pops/lookup/explainer.rb +46 -6
- data/lib/puppet/pops/lookup/invocation.rb +19 -0
- data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
- data/lib/puppet/pops/model/factory.rb +20 -8
- data/lib/puppet/pops/model/model_label_provider.rb +3 -0
- data/lib/puppet/pops/model/model_meta.rb +2 -0
- data/lib/puppet/pops/model/model_tree_dumper.rb +14 -0
- data/lib/puppet/pops/parser/egrammar.ra +11 -6
- data/lib/puppet/pops/parser/eparser.rb +1112 -1086
- data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
- data/lib/puppet/pops/pcore.rb +1 -0
- data/lib/puppet/pops/puppet_stack.rb +3 -3
- data/lib/puppet/pops/resource/param.rb +5 -1
- data/lib/puppet/pops/resource/resource_type_impl.rb +8 -4
- data/lib/puppet/pops/resource/resource_type_set.pcore +1 -0
- data/lib/puppet/pops/serialization/abstract_reader.rb +19 -2
- data/lib/puppet/pops/serialization/abstract_writer.rb +16 -3
- data/lib/puppet/pops/serialization/deserializer.rb +5 -1
- data/lib/puppet/pops/serialization/extension.rb +2 -0
- data/lib/puppet/pops/serialization/json.rb +76 -26
- data/lib/puppet/pops/serialization/serializer.rb +5 -1
- data/lib/puppet/pops/serialization/time_factory.rb +2 -1
- data/lib/puppet/pops/time/timespan.rb +718 -0
- data/lib/puppet/pops/time/timestamp.rb +148 -0
- data/lib/puppet/pops/types/p_binary_type.rb +220 -0
- data/lib/puppet/pops/types/p_object_type.rb +12 -6
- data/lib/puppet/pops/types/p_sensitive_type.rb +5 -1
- data/lib/puppet/pops/types/p_timespan_type.rb +141 -0
- data/lib/puppet/pops/types/p_timestamp_type.rb +69 -0
- data/lib/puppet/pops/types/string_converter.rb +62 -0
- data/lib/puppet/pops/types/type_asserter.rb +1 -1
- data/lib/puppet/pops/types/type_calculator.rb +17 -3
- data/lib/puppet/pops/types/type_factory.rb +35 -1
- data/lib/puppet/pops/types/type_formatter.rb +64 -11
- data/lib/puppet/pops/types/type_mismatch_describer.rb +110 -61
- data/lib/puppet/pops/types/type_parser.rb +18 -4
- data/lib/puppet/pops/types/types.rb +98 -63
- data/lib/puppet/pops/validation.rb +9 -1
- data/lib/puppet/pops/validation/checker4_0.rb +7 -0
- data/lib/puppet/property.rb +1 -1
- data/lib/puppet/provider.rb +3 -6
- data/lib/puppet/provider/mcx/mcxcontent.rb +1 -1
- data/lib/puppet/provider/mount/parsed.rb +18 -4
- data/lib/puppet/provider/nameservice/directoryservice.rb +15 -7
- data/lib/puppet/provider/package/gem.rb +6 -1
- data/lib/puppet/provider/package/pip.rb +0 -1
- data/lib/puppet/provider/package/pkg.rb +5 -1
- data/lib/puppet/provider/package/pkgng.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +10 -0
- data/lib/puppet/provider/service/launchd.rb +1 -0
- data/lib/puppet/provider/user/directoryservice.rb +6 -6
- data/lib/puppet/provider/yumrepo/inifile.rb +1 -1
- data/lib/puppet/provider/zpool/zpool.rb +1 -1
- data/lib/puppet/resource.rb +54 -12
- data/lib/puppet/resource/capability_finder.rb +15 -9
- data/lib/puppet/resource/catalog.rb +25 -6
- data/lib/puppet/resource/type.rb +3 -1
- data/lib/puppet/settings.rb +1 -1
- data/lib/puppet/settings/environment_conf.rb +12 -4
- data/lib/puppet/syntax_checkers/base64.rb +41 -0
- data/lib/puppet/syntax_checkers/json.rb +0 -2
- data/lib/puppet/transaction.rb +6 -0
- data/lib/puppet/transaction/additional_resource_generator.rb +5 -0
- data/lib/puppet/transaction/report.rb +7 -2
- data/lib/puppet/type.rb +2 -1
- data/lib/puppet/type/file/checksum.rb +1 -0
- data/lib/puppet/type/file/content.rb +4 -4
- data/lib/puppet/type/mount.rb +44 -0
- data/lib/puppet/type/ssh_authorized_key.rb +1 -1
- data/lib/puppet/type/tidy.rb +3 -0
- data/lib/puppet/type/user.rb +12 -6
- data/lib/puppet/util/log.rb +25 -0
- data/lib/puppet/util/plist.rb +8 -3
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet_x.rb +7 -1
- data/spec/integration/application/apply_spec.rb +118 -0
- data/spec/integration/parser/compiler_spec.rb +28 -0
- data/spec/integration/parser/pcore_resource_spec.rb +40 -3
- data/spec/integration/provider/mount_spec.rb +2 -1
- data/spec/integration/util/windows/principal_spec.rb +2 -2
- data/spec/integration/util/windows/registry_spec.rb +4 -4
- data/spec/lib/puppet_spec/compiler.rb +5 -1
- data/spec/lib/puppet_spec/unindent.rb +5 -0
- data/spec/shared_contexts/types_setup.rb +6 -0
- data/spec/shared_examples/rhel_package_provider.rb +16 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/agent_spec.rb +11 -0
- data/spec/unit/application/lookup_spec.rb +94 -3
- data/spec/unit/capability_spec.rb +22 -0
- data/spec/unit/configurer_spec.rb +8 -0
- data/spec/unit/face/epp_face_spec.rb +22 -3
- data/spec/unit/functions/assert_type_spec.rb +3 -3
- data/spec/unit/functions/binary_file_spec.rb +46 -0
- data/spec/unit/functions/break_spec.rb +89 -0
- data/spec/unit/{parser/functions → functions}/contain_spec.rb +68 -3
- data/spec/unit/functions/find_file_spec.rb +69 -0
- data/spec/unit/functions/include_spec.rb +175 -0
- data/spec/unit/functions/logging_spec.rb +54 -0
- data/spec/unit/functions/lookup_spec.rb +3 -3
- data/spec/unit/functions/new_spec.rb +105 -5
- data/spec/unit/functions/next_spec.rb +93 -0
- data/spec/unit/functions/require_spec.rb +83 -0
- data/spec/unit/functions/return_spec.rb +105 -0
- data/spec/unit/{parser/functions → functions}/shared.rb +14 -11
- data/spec/unit/functions/strftime_spec.rb +152 -0
- data/spec/unit/functions4_spec.rb +22 -0
- data/spec/unit/indirector/face_spec.rb +10 -2
- data/spec/unit/network/http/error_spec.rb +1 -2
- data/spec/unit/network/http/handler_spec.rb +6 -5
- data/spec/unit/parser/functions/hiera_array_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_hash_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_include_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_spec.rb +1 -1
- data/spec/unit/parser/functions/lookup_spec.rb +1 -1
- data/spec/unit/parser/functions/regsubst_spec.rb +1 -1
- data/spec/unit/parser/functions/split_spec.rb +1 -1
- data/spec/unit/pops/evaluator/access_ops_spec.rb +81 -1
- data/spec/unit/pops/evaluator/arithmetic_ops_spec.rb +170 -0
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +29 -4
- data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +112 -4
- data/spec/unit/pops/loaders/dependency_loader_spec.rb +12 -0
- data/spec/unit/pops/loaders/static_loader_spec.rb +0 -26
- data/spec/unit/pops/lookup/context_spec.rb +149 -0
- data/spec/unit/pops/parser/parse_functions_spec.rb +19 -0
- data/spec/unit/pops/parser/parse_lambda_spec.rb +19 -0
- data/spec/unit/pops/puppet_stack_spec.rb +1 -1
- data/spec/unit/pops/resource/resource_type_impl_spec.rb +74 -0
- data/spec/unit/pops/serialization/packer_spec.rb +34 -14
- data/spec/unit/pops/serialization/serialization_spec.rb +67 -5
- data/spec/unit/pops/time/timespan_spec.rb +121 -0
- data/spec/unit/pops/types/p_binary_type_spec.rb +243 -0
- data/spec/unit/pops/types/p_object_type_spec.rb +7 -7
- data/spec/unit/pops/types/p_sensitive_type_spec.rb +1 -1
- data/spec/unit/pops/types/p_timespan_type_spec.rb +273 -0
- data/spec/unit/pops/types/p_timestamp_type_spec.rb +311 -0
- data/spec/unit/pops/types/p_type_set_type_spec.rb +13 -13
- data/spec/unit/pops/types/ruby_generator_spec.rb +12 -12
- data/spec/unit/pops/types/string_converter_spec.rb +89 -0
- data/spec/unit/pops/types/type_asserter_spec.rb +3 -3
- data/spec/unit/pops/types/type_calculator_spec.rb +113 -5
- data/spec/unit/pops/types/type_formatter_spec.rb +40 -0
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +49 -38
- data/spec/unit/pops/types/type_parser_spec.rb +87 -4
- data/spec/unit/pops/types/types_spec.rb +1 -1
- data/spec/unit/pops/validator/validator_spec.rb +23 -0
- data/spec/unit/provider/mount/parsed_spec.rb +47 -29
- data/spec/unit/provider/package/pkg_spec.rb +109 -99
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -0
- data/spec/unit/provider/user/aix_spec.rb +1 -1
- data/spec/unit/provider/user/directoryservice_spec.rb +101 -30
- data/spec/unit/resource/capability_finder_spec.rb +29 -7
- data/spec/unit/resource/catalog_spec.rb +127 -0
- data/spec/unit/ssl/certificate_request_spec.rb +1 -1
- data/spec/unit/transaction/additional_resource_generator_spec.rb +30 -0
- data/spec/unit/transaction/persistence_spec.rb +1 -6
- data/spec/unit/transaction/report_spec.rb +23 -0
- data/spec/unit/transaction_spec.rb +38 -0
- data/spec/unit/type/mount_spec.rb +5 -0
- data/spec/unit/util/plist_spec.rb +14 -2
- metadata +71 -12
- data/spec/integration/parser/functions/require_spec.rb +0 -43
- data/spec/unit/parser/functions/include_spec.rb +0 -55
- data/spec/unit/parser/functions/require_spec.rb +0 -68
@@ -156,7 +156,7 @@ class Puppet::Parser::Resource < Puppet::Resource
|
|
156
156
|
# Test the resource scope, to make sure the resource is even allowed
|
157
157
|
# to override.
|
158
158
|
unless self.source.object_id == resource.source.object_id || resource.source.child_of?(self.source)
|
159
|
-
raise Puppet::ParseError.new("Only subclasses can override parameters", resource.
|
159
|
+
raise Puppet::ParseError.new("Only subclasses can override parameters", resource.file, resource.line)
|
160
160
|
end
|
161
161
|
# Some of these might fail, but they'll fail in the way we want.
|
162
162
|
resource.parameters.each do |name, param|
|
@@ -176,6 +176,7 @@ class Puppet::Parser::Resource < Puppet::Resource
|
|
176
176
|
# the resource tags with its value.
|
177
177
|
def set_parameter(param, value = nil)
|
178
178
|
if ! param.is_a?(Puppet::Parser::Resource::Param)
|
179
|
+
param = param.name if param.is_a?(Puppet::Pops::Resource::Param)
|
179
180
|
param = Puppet::Parser::Resource::Param.new(
|
180
181
|
:name => param, :value => value, :source => self.source
|
181
182
|
)
|
@@ -191,13 +192,13 @@ class Puppet::Parser::Resource < Puppet::Resource
|
|
191
192
|
def to_hash
|
192
193
|
@parameters.reduce({}) do |result, (_, param)|
|
193
194
|
value = param.value
|
194
|
-
value = (
|
195
|
+
value = (:undef == value) ? nil : value
|
195
196
|
|
196
197
|
unless value.nil?
|
197
198
|
case param.name
|
198
199
|
when :before, :subscribe, :notify, :require
|
199
200
|
if value.is_a?(Array)
|
200
|
-
value = value.flatten.reject {|v| v.nil? ||
|
201
|
+
value = value.flatten.reject {|v| v.nil? || :undef == v }
|
201
202
|
end
|
202
203
|
result[param.name] = value
|
203
204
|
else
|
@@ -244,7 +245,9 @@ class Puppet::Parser::Resource < Puppet::Resource
|
|
244
245
|
raise Puppet::Error, "Invalid consume in #{self.ref}: #{ref} is not a resource" unless ref.is_a?(Puppet::Resource)
|
245
246
|
|
246
247
|
# Resolve references
|
247
|
-
|
248
|
+
t = ref.type
|
249
|
+
t = Puppet::Pops::Evaluator::Runtime3ResourceSupport.find_resource_type(scope, t) unless t == 'class' || t == 'node'
|
250
|
+
cap = catalog.resource(t, ref.title)
|
248
251
|
if cap.nil?
|
249
252
|
raise "Resource #{ref} could not be found; it might not have been produced yet"
|
250
253
|
end
|
@@ -342,7 +345,7 @@ class Puppet::Parser::Resource < Puppet::Resource
|
|
342
345
|
msg += " at #{fields.join(":")}"
|
343
346
|
end
|
344
347
|
msg += "; cannot redefine"
|
345
|
-
raise Puppet::ParseError.new(msg, param.
|
348
|
+
raise Puppet::ParseError.new(msg, param.file, param.line)
|
346
349
|
end
|
347
350
|
|
348
351
|
# If we've gotten this far, we're allowed to override.
|
data/lib/puppet/parser/scope.rb
CHANGED
@@ -710,7 +710,7 @@ class Puppet::Parser::Scope
|
|
710
710
|
|
711
711
|
params.each { |param|
|
712
712
|
if table.include?(param.name)
|
713
|
-
raise Puppet::ParseError.new("Default already defined for #{type} { #{param.name} }; cannot redefine", param.
|
713
|
+
raise Puppet::ParseError.new("Default already defined for #{type} { #{param.name} }; cannot redefine", param.file, param.line)
|
714
714
|
end
|
715
715
|
table[param.name] = param
|
716
716
|
}
|
@@ -65,5 +65,13 @@ module Puppet::Plugins::Configuration
|
|
65
65
|
in_multibind(checkers_name)
|
66
66
|
to_instance('Puppet::SyntaxCheckers::Json')
|
67
67
|
end
|
68
|
+
|
69
|
+
bindings.bind do
|
70
|
+
name('base64')
|
71
|
+
instance_of(checkers_type)
|
72
|
+
in_multibind(checkers_name)
|
73
|
+
to_instance('Puppet::SyntaxCheckers::Base64')
|
74
|
+
end
|
75
|
+
|
68
76
|
Puppet::Plugins::DataProviders::Registry.register_defaults(bindings)
|
69
77
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'puppet/pops/lookup/interpolation'
|
2
2
|
|
3
3
|
module Puppet::Plugins::DataProviders
|
4
|
+
# @api private
|
4
5
|
module DataProvider
|
5
6
|
include Puppet::Pops::Lookup::Interpolation
|
6
7
|
|
@@ -9,8 +10,6 @@ module Puppet::Plugins::DataProviders
|
|
9
10
|
# @param key [String] The key to lookup
|
10
11
|
# @param lookup_invocation [Puppet::Pops::Lookup::Invocation] The current lookup invocation
|
11
12
|
# @param merge [String|Hash<String,Object>|nil] Merge strategy or hash with strategy and options
|
12
|
-
#
|
13
|
-
# @api public
|
14
13
|
def lookup(name, lookup_invocation, merge)
|
15
14
|
lookup_invocation.check(name) { unchecked_lookup(name, lookup_invocation, merge) }
|
16
15
|
end
|
@@ -20,8 +19,6 @@ module Puppet::Plugins::DataProviders
|
|
20
19
|
# @param key [String] The key to lookup
|
21
20
|
# @param lookup_invocation [Puppet::Pops::Lookup::Invocation] The current lookup invocation
|
22
21
|
# @param merge [String|Hash<String,Object>|nil] Merge strategy or hash with strategy and options
|
23
|
-
#
|
24
|
-
# @api public
|
25
22
|
def unchecked_lookup(key, lookup_invocation, merge)
|
26
23
|
segments = split_key(key)
|
27
24
|
root_key = segments.shift
|
@@ -44,8 +41,6 @@ module Puppet::Plugins::DataProviders
|
|
44
41
|
# @param value [Object] The value to perform post processing on
|
45
42
|
# @param lookup_invocation [Puppet::Pops::Lookup::Invocation] The current lookup invocation
|
46
43
|
# @return [Object] The result of post processing the value.
|
47
|
-
#
|
48
|
-
# @api public
|
49
44
|
def post_process(value, lookup_invocation)
|
50
45
|
interpolate(value, lookup_invocation, true)
|
51
46
|
end
|
@@ -61,8 +56,6 @@ module Puppet::Plugins::DataProviders
|
|
61
56
|
# @param lookup_invocation [Puppet::Pops::Lookup::Invocation] The current lookup invocation
|
62
57
|
# @param merge [String|Hash<String,Object>|nil] Merge strategy or hash with strategy and options
|
63
58
|
# @return [Hash] The data hash for the given _key_
|
64
|
-
#
|
65
|
-
# @api public
|
66
59
|
def data(data_key, lookup_invocation)
|
67
60
|
compiler = lookup_invocation.scope.compiler
|
68
61
|
adapter = Puppet::DataProviders::DataAdapter.get(compiler) || Puppet::DataProviders::DataAdapter.adapt(compiler)
|
@@ -74,8 +67,6 @@ module Puppet::Plugins::DataProviders
|
|
74
67
|
#
|
75
68
|
# @param key [String] The key to lookup
|
76
69
|
# @return [String,nil] The data key or nil if not applicable
|
77
|
-
#
|
78
|
-
# @api public
|
79
70
|
def data_key(key, lookup_invocation)
|
80
71
|
nil
|
81
72
|
end
|
@@ -85,8 +76,6 @@ module Puppet::Plugins::DataProviders
|
|
85
76
|
# @param data_key [String] The data key such as the name of a module or the constant 'environment'
|
86
77
|
# @param lookup_invocation [Puppet::Pops::Lookup::Invocation] The current lookup invocation
|
87
78
|
# @return [Hash] The hash of values
|
88
|
-
#
|
89
|
-
# @api public
|
90
79
|
def initialize_data(data_key, lookup_invocation)
|
91
80
|
{}
|
92
81
|
end
|
@@ -102,6 +91,7 @@ module Puppet::Plugins::DataProviders
|
|
102
91
|
end
|
103
92
|
end
|
104
93
|
|
94
|
+
# @api private
|
105
95
|
class ModuleDataProvider
|
106
96
|
LOOKUP_OPTIONS = Puppet::Pops::Lookup::LOOKUP_OPTIONS
|
107
97
|
include DataProvider
|
@@ -142,6 +132,7 @@ module Puppet::Plugins::DataProviders
|
|
142
132
|
end
|
143
133
|
end
|
144
134
|
|
135
|
+
# @api private
|
145
136
|
class EnvironmentDataProvider
|
146
137
|
include DataProvider
|
147
138
|
|
@@ -153,13 +144,12 @@ module Puppet::Plugins::DataProviders
|
|
153
144
|
# Class that keeps track of the original path (as it appears in the declaration, before interpolation),
|
154
145
|
# the fully resolved path, and whether or the resolved path exists.
|
155
146
|
#
|
156
|
-
# @api
|
147
|
+
# @api private
|
157
148
|
class ResolvedPath
|
158
149
|
attr_reader :original_path, :path
|
159
150
|
|
160
151
|
# @param original_path [String] path as found in declaration. May contain interpolation expressions
|
161
152
|
# @param path [Pathname] the expanded absolute path
|
162
|
-
# @api public
|
163
153
|
def initialize(original_path, path)
|
164
154
|
@original_path = original_path
|
165
155
|
@path = path
|
@@ -179,7 +169,7 @@ module Puppet::Plugins::DataProviders
|
|
179
169
|
# will be merged according to a given (optional) merge strategy.
|
180
170
|
#
|
181
171
|
# @abstract
|
182
|
-
# @api
|
172
|
+
# @api private
|
183
173
|
class PathBasedDataProvider
|
184
174
|
include DataProvider
|
185
175
|
|
@@ -188,8 +178,6 @@ module Puppet::Plugins::DataProviders
|
|
188
178
|
# @param name [String] The name of the data provider
|
189
179
|
# @param paths [Array<ResolvedPath>] Paths used by this provider
|
190
180
|
# @param parent_data_provider [DataProvider] The data provider that is the container of this data provider
|
191
|
-
#
|
192
|
-
# @api public
|
193
181
|
def initialize(name, paths, parent_data_provider = nil)
|
194
182
|
@name = name
|
195
183
|
@paths = paths
|
@@ -208,8 +196,6 @@ module Puppet::Plugins::DataProviders
|
|
208
196
|
# @param lookup_invocation [Puppet::Pops::Lookup::Invocation] The current lookup invocation
|
209
197
|
# @param merge [String|Hash<String,Object>|nil] Merge strategy or hash with strategy and options
|
210
198
|
# @return [Hash] The data hash for the given _key_
|
211
|
-
#
|
212
|
-
# @api public
|
213
199
|
def load_data(path, data_key, lookup_invocation)
|
214
200
|
compiler = lookup_invocation.scope.compiler
|
215
201
|
adapter = Puppet::DataProviders::DataAdapter.get(compiler) || Puppet::DataProviders::DataAdapter.adapt(compiler)
|
@@ -227,8 +213,6 @@ module Puppet::Plugins::DataProviders
|
|
227
213
|
# @param key [String] The key to lookup
|
228
214
|
# @param lookup_invocation [Puppet::Pops::Lookup::Invocation] The current lookup invocation
|
229
215
|
# @param merge [Puppet::Pops::MergeStrategy,String,Hash<String,Object>,nil] Merge strategy or hash with strategy and options
|
230
|
-
#
|
231
|
-
# @api public
|
232
216
|
def unchecked_lookup(key, lookup_invocation, merge)
|
233
217
|
segments = split_key(key)
|
234
218
|
root_key = segments.shift
|
@@ -264,7 +248,7 @@ module Puppet::Plugins::DataProviders
|
|
264
248
|
# Factory for creating path based data providers
|
265
249
|
#
|
266
250
|
# @abstract
|
267
|
-
# @api
|
251
|
+
# @api private
|
268
252
|
class PathBasedDataProviderFactory
|
269
253
|
# Create a path based data provider with the given _name_ and _paths_
|
270
254
|
#
|
@@ -272,8 +256,6 @@ module Puppet::Plugins::DataProviders
|
|
272
256
|
# @param paths [Array<String>] array of resolved paths
|
273
257
|
# @param parent_data_provider [DataProvider] The data provider that is the container of this data provider
|
274
258
|
# @return [DataProvider] The created data provider
|
275
|
-
#
|
276
|
-
# @api public
|
277
259
|
def create(name, paths, parent_data_provider)
|
278
260
|
raise NotImplementedError, "Subclass of PathBasedDataProviderFactory must implement 'create' method"
|
279
261
|
end
|
@@ -289,8 +271,6 @@ module Puppet::Plugins::DataProviders
|
|
289
271
|
# @param paths [Array<String>] paths that have been preprocessed (interpolations resolved)
|
290
272
|
# @param lookup_invocation [Puppet::Pops::Lookup::Invocation] The current lookup invocation
|
291
273
|
# @return [Array<ResolvedPath>] Array of resolved paths
|
292
|
-
#
|
293
|
-
# @api public
|
294
274
|
def resolve_paths(datadir, declared_paths, paths, lookup_invocation)
|
295
275
|
[]
|
296
276
|
end
|
@@ -298,7 +278,6 @@ module Puppet::Plugins::DataProviders
|
|
298
278
|
# Returns the data provider factory version.
|
299
279
|
#
|
300
280
|
# return [Integer] the version of this data provider factory
|
301
|
-
# @api public
|
302
281
|
def version
|
303
282
|
2
|
304
283
|
end
|
@@ -309,7 +288,7 @@ module Puppet::Plugins::DataProviders
|
|
309
288
|
# file system.
|
310
289
|
#
|
311
290
|
# @abstract
|
312
|
-
# @api
|
291
|
+
# @api private
|
313
292
|
class FileBasedDataProviderFactory < PathBasedDataProviderFactory
|
314
293
|
# @param datadir [Pathname] The base when creating absolute paths
|
315
294
|
# @param declared_paths [Array<String>] paths as found in declaration. May contain interpolation expressions
|
data/lib/puppet/pops.rb
CHANGED
@@ -41,9 +41,13 @@ module Puppet
|
|
41
41
|
|
42
42
|
require 'puppet/pops/model/model'
|
43
43
|
|
44
|
+
require 'puppet/pops/time/timespan'
|
45
|
+
require 'puppet/pops/time/timestamp'
|
46
|
+
|
44
47
|
# (the Types module initializes itself)
|
45
48
|
require 'puppet/pops/types/types'
|
46
49
|
require 'puppet/pops/types/string_converter'
|
50
|
+
require 'puppet/pops/lookup/context'
|
47
51
|
|
48
52
|
require 'puppet/pops/merge_strategy'
|
49
53
|
|
@@ -30,6 +30,10 @@ class AccessOperator
|
|
30
30
|
fail(Issues::OPERATOR_NOT_APPLICABLE, @semantic.left_expr, :operator=>'[]', :left_value => o)
|
31
31
|
end
|
32
32
|
|
33
|
+
def access_Binary(o, scope, keys)
|
34
|
+
Puppet::Pops::Types::PBinaryType::Binary.from_binary_string(access_String(o.binary_buffer, scope, keys))
|
35
|
+
end
|
36
|
+
|
33
37
|
def access_String(o, scope, keys)
|
34
38
|
keys.flatten!
|
35
39
|
result = case keys.size
|
@@ -37,8 +41,8 @@ class AccessOperator
|
|
37
41
|
fail(Issues::BAD_STRING_SLICE_ARITY, @semantic.left_expr, {:actual => keys.size})
|
38
42
|
when 1
|
39
43
|
# Note that Ruby 1.8.7 requires a length of 1 to produce a String
|
40
|
-
k1 =
|
41
|
-
|
44
|
+
k1 = Utils.to_n(keys[0])
|
45
|
+
bad_string_access_key_type(o, 0, k1.nil? ? keys[0] : k1) unless k1.is_a?(Integer)
|
42
46
|
k2 = 1
|
43
47
|
k1 = k1 < 0 ? o.length + k1 : k1 # abs pos
|
44
48
|
# if k1 is outside, a length of 1 always produces an empty string
|
@@ -48,9 +52,9 @@ class AccessOperator
|
|
48
52
|
o[ k1, k2 ]
|
49
53
|
end
|
50
54
|
when 2
|
51
|
-
k1 =
|
52
|
-
k2 =
|
53
|
-
[k1, k2].each_with_index { |k,i|
|
55
|
+
k1 = Utils.to_n(keys[0])
|
56
|
+
k2 = Utils.to_n(keys[1])
|
57
|
+
[k1, k2].each_with_index { |k,i| bad_string_access_key_type(o, i, k.nil? ? keys[i] : k) unless k.is_a?(Integer) }
|
54
58
|
|
55
59
|
k1 = k1 < 0 ? o.length + k1 : k1 # abs pos (negative is count from end)
|
56
60
|
k2 = k2 < 0 ? o.length - k1 + k2 + 1 : k2 # abs length (negative k2 is length from pos to end count)
|
@@ -158,6 +162,18 @@ class AccessOperator
|
|
158
162
|
Types::TypeFactory.sem_ver(*keys)
|
159
163
|
end
|
160
164
|
|
165
|
+
def access_PTimestampType(o, scope, keys)
|
166
|
+
keys.flatten!
|
167
|
+
fail(Issues::BAD_TYPE_SLICE_ARITY, @semantic, :base_type => o, :min=>0, :max => 2, :actual => keys.size) if keys.size > 2
|
168
|
+
Types::TypeFactory.timestamp(*keys)
|
169
|
+
end
|
170
|
+
|
171
|
+
def access_PTimespanType(o, scope, keys)
|
172
|
+
keys.flatten!
|
173
|
+
fail(Issues::BAD_TYPE_SLICE_ARITY, @semantic, :base_type => o, :min=>0, :max => 2, :actual => keys.size) if keys.size > 2
|
174
|
+
Types::TypeFactory.timespan(*keys)
|
175
|
+
end
|
176
|
+
|
161
177
|
def access_PTupleType(o, scope, keys)
|
162
178
|
keys.flatten!
|
163
179
|
if Types::TypeFactory.is_range_parameter?(keys[-2]) && Types::TypeFactory.is_range_parameter?(keys[-1])
|
@@ -172,6 +188,14 @@ class AccessOperator
|
|
172
188
|
end
|
173
189
|
|
174
190
|
def access_PCallableType(o, scope, keys)
|
191
|
+
if keys.size > 0 && keys[0].is_a?(Array)
|
192
|
+
unless keys.size == 2
|
193
|
+
fail(Issues::BAD_TYPE_SLICE_ARITY, @semantic, :base_type => o, :min=>2, :max => 2, :actual => keys.size)
|
194
|
+
end
|
195
|
+
unless keys[1].is_a?(Types::PAnyType)
|
196
|
+
bad_type_specialization_key_type(o, 1, k, Types::PAnyType)
|
197
|
+
end
|
198
|
+
end
|
175
199
|
Types::TypeFactory.callable(*keys)
|
176
200
|
end
|
177
201
|
|
@@ -221,6 +245,13 @@ class AccessOperator
|
|
221
245
|
})
|
222
246
|
end
|
223
247
|
|
248
|
+
def bad_string_access_key_type(lhs, key_index, actual)
|
249
|
+
fail(Issues::BAD_STRING_SLICE_KEY_TYPE, @semantic.keys[key_index], {
|
250
|
+
:left_value => lhs,
|
251
|
+
:actual_type => bad_key_type_name(actual),
|
252
|
+
})
|
253
|
+
end
|
254
|
+
|
224
255
|
def bad_key_type_name(actual)
|
225
256
|
case actual
|
226
257
|
when nil
|
@@ -1,5 +1,44 @@
|
|
1
1
|
module Puppet::Pops
|
2
2
|
module Evaluator
|
3
|
+
class Jumper < Exception
|
4
|
+
attr_reader :value
|
5
|
+
attr_reader :file
|
6
|
+
attr_reader :line
|
7
|
+
def initialize(value, file, line)
|
8
|
+
@value = value
|
9
|
+
@file = file
|
10
|
+
@line = line
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Next < Jumper
|
15
|
+
def initialize(value, file, line)
|
16
|
+
super
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Return < Jumper
|
21
|
+
def initialize(value, file, line)
|
22
|
+
super
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class PuppetStopIteration < StopIteration
|
27
|
+
attr_reader :file
|
28
|
+
attr_reader :line
|
29
|
+
attr_reader :pos
|
30
|
+
|
31
|
+
def initialize(file, line, pos = nil)
|
32
|
+
@file = file
|
33
|
+
@line = line
|
34
|
+
@pos = pos
|
35
|
+
end
|
36
|
+
|
37
|
+
def message
|
38
|
+
"break() from context where this is illegal"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
3
42
|
# A Closure represents logic bound to a particular scope.
|
4
43
|
# As long as the runtime (basically the scope implementation) has the behavior of Puppet 3x it is not
|
5
44
|
# safe to return and later use this closure.
|
@@ -63,9 +102,15 @@ class Closure < CallableSignature
|
|
63
102
|
args_hash = param_scope.to_hash
|
64
103
|
end
|
65
104
|
Types::TypeMismatchDescriber.validate_parameters(closure_name, params_struct, args_hash)
|
105
|
+
result = catch(:next) do
|
106
|
+
@evaluator.evaluate_block_with_bindings(closure_scope, args_hash, @model.body)
|
107
|
+
end
|
108
|
+
Types::TypeAsserter.assert_instance_of(nil, return_type, result) do
|
109
|
+
"value returned from #{closure_name}"
|
110
|
+
end
|
111
|
+
else
|
112
|
+
@evaluator.evaluate_block_with_bindings(closure_scope, args_hash, @model.body)
|
66
113
|
end
|
67
|
-
|
68
|
-
@evaluator.evaluate_block_with_bindings(closure_scope, args_hash, @model.body)
|
69
114
|
end
|
70
115
|
|
71
116
|
def parameters
|
@@ -84,6 +129,10 @@ class Closure < CallableSignature
|
|
84
129
|
@model.parameters.collect(&:name)
|
85
130
|
end
|
86
131
|
|
132
|
+
def return_type
|
133
|
+
@return_type ||= create_return_type
|
134
|
+
end
|
135
|
+
|
87
136
|
# @api public
|
88
137
|
def type
|
89
138
|
@callable ||= create_callable_type
|
@@ -122,6 +171,16 @@ class Closure < CallableSignature
|
|
122
171
|
def enclosing_scope
|
123
172
|
@enclosing_scope
|
124
173
|
end
|
174
|
+
|
175
|
+
def call(*args)
|
176
|
+
# A return from an unnamed closure is treated as a return from the context evaluating
|
177
|
+
# calling this closure - that is, as if it was the return call itself.
|
178
|
+
#
|
179
|
+
jumper = catch(:return) do
|
180
|
+
return call_with_scope(enclosing_scope, args)
|
181
|
+
end
|
182
|
+
raise jumper
|
183
|
+
end
|
125
184
|
end
|
126
185
|
|
127
186
|
class Named < Closure
|
@@ -162,7 +221,12 @@ class Closure < CallableSignature
|
|
162
221
|
end)
|
163
222
|
|
164
223
|
if type.callable?(final_args)
|
165
|
-
|
224
|
+
result = catch(:next) do
|
225
|
+
@evaluator.evaluate_block_with_bindings(scope, variable_bindings, @model.body)
|
226
|
+
end
|
227
|
+
Types::TypeAsserter.assert_instance_of(nil, return_type, result) do
|
228
|
+
"value returned from #{closure_name}"
|
229
|
+
end
|
166
230
|
else
|
167
231
|
raise ArgumentError, Types::TypeMismatchDescriber.describe_signatures(closure_name, [self], final_args)
|
168
232
|
end
|
@@ -217,7 +281,8 @@ class Closure < CallableSignature
|
|
217
281
|
|
218
282
|
def create_callable_type()
|
219
283
|
types = []
|
220
|
-
|
284
|
+
from = 0
|
285
|
+
to = 0
|
221
286
|
in_optional_parameters = false
|
222
287
|
closure_scope = enclosing_scope
|
223
288
|
|
@@ -232,15 +297,11 @@ class Closure < CallableSignature
|
|
232
297
|
@evaluator.fail(Issues::REQUIRED_PARAMETER_AFTER_OPTIONAL, param, { :param_name => param.name })
|
233
298
|
end
|
234
299
|
|
235
|
-
|
236
|
-
|
237
|
-
end
|
238
|
-
|
239
|
-
if range[1] == Float::INFINITY
|
240
|
-
range[1] = :default
|
300
|
+
from += param_range[0]
|
301
|
+
to += param_range[1]
|
241
302
|
end
|
242
|
-
|
243
|
-
Types::
|
303
|
+
param_types = Types::PTupleType.new(types, Types::PIntegerType.new(from, to))
|
304
|
+
Types::PCallableType.new(param_types, nil, return_type)
|
244
305
|
end
|
245
306
|
|
246
307
|
def create_params_struct
|
@@ -257,6 +318,14 @@ class Closure < CallableSignature
|
|
257
318
|
type_factory.struct(members)
|
258
319
|
end
|
259
320
|
|
321
|
+
def create_return_type
|
322
|
+
if @model.return_type
|
323
|
+
@evaluator.evaluate(@model.return_type, @enclosing_scope)
|
324
|
+
else
|
325
|
+
Types::PAnyType::DEFAULT
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
260
329
|
def create_param_type(param, closure_scope)
|
261
330
|
type = if param.type_expr
|
262
331
|
@evaluator.evaluate(param.type_expr, closure_scope)
|