puppet 6.6.0-x86-mingw32 → 6.7.0-x86-mingw32
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +8 -8
- data/ext/solaris/smf/puppet.xml +2 -0
- data/ext/yaml_nodes.rb +7 -7
- data/lib/hiera_puppet.rb +2 -1
- data/lib/puppet/application/apply.rb +2 -3
- data/lib/puppet/application/doc.rb +2 -1
- data/lib/puppet/application/face_base.rb +22 -15
- data/lib/puppet/application/script.rb +4 -6
- data/lib/puppet/configurer.rb +10 -5
- data/lib/puppet/confine_collection.rb +2 -1
- data/lib/puppet/daemon.rb +3 -2
- data/lib/puppet/defaults.rb +8 -0
- data/lib/puppet/environments.rb +9 -7
- data/lib/puppet/etc.rb +1 -1
- data/lib/puppet/external/pson/pure/parser.rb +2 -1
- data/lib/puppet/face/epp.rb +4 -2
- data/lib/puppet/face/help.rb +3 -2
- data/lib/puppet/face/module/changes.rb +2 -1
- data/lib/puppet/file_bucket/dipper.rb +2 -1
- data/lib/puppet/file_serving/configuration.rb +2 -1
- data/lib/puppet/file_serving/fileset.rb +1 -1
- data/lib/puppet/file_serving/http_metadata.rb +4 -2
- data/lib/puppet/file_serving/metadata.rb +2 -1
- data/lib/puppet/file_serving/mount/file.rb +2 -1
- data/lib/puppet/file_serving/mount/locales.rb +2 -1
- data/lib/puppet/file_serving/mount/modules.rb +4 -2
- data/lib/puppet/file_serving/mount/pluginfacts.rb +2 -1
- data/lib/puppet/file_serving/mount/plugins.rb +2 -1
- data/lib/puppet/file_serving/mount/tasks.rb +4 -2
- data/lib/puppet/file_system/uniquefile.rb +4 -2
- data/lib/puppet/functions/match.rb +2 -3
- data/lib/puppet/generate/type.rb +2 -1
- data/lib/puppet/graph/relationship_graph.rb +2 -1
- data/lib/puppet/graph/simple_graph.rb +3 -2
- data/lib/puppet/indirector/catalog/compiler.rb +16 -8
- data/lib/puppet/indirector/certificate/rest.rb +2 -1
- data/lib/puppet/indirector/face.rb +2 -2
- data/lib/puppet/indirector/file_server.rb +4 -2
- data/lib/puppet/indirector/indirection.rb +12 -6
- data/lib/puppet/indirector/node/exec.rb +2 -1
- data/lib/puppet/indirector/report/processor.rb +2 -1
- data/lib/puppet/indirector/request.rb +9 -5
- data/lib/puppet/indirector/ssl_file.rb +10 -8
- data/lib/puppet/indirector/terminus.rb +6 -3
- data/lib/puppet/info_service.rb +9 -0
- data/lib/puppet/info_service/plan_information_service.rb +36 -0
- data/lib/puppet/interface.rb +2 -1
- data/lib/puppet/interface/action.rb +10 -5
- data/lib/puppet/interface/action_manager.rb +2 -1
- data/lib/puppet/interface/documentation.rb +10 -7
- data/lib/puppet/interface/face_collection.rb +6 -3
- data/lib/puppet/interface/option.rb +4 -2
- data/lib/puppet/interface/option_manager.rb +4 -2
- data/lib/puppet/module.rb +35 -1
- data/lib/puppet/module/plan.rb +160 -0
- data/lib/puppet/module_tool.rb +2 -1
- data/lib/puppet/module_tool/applications/application.rb +2 -1
- data/lib/puppet/module_tool/applications/installer.rb +4 -2
- data/lib/puppet/module_tool/applications/upgrader.rb +4 -2
- data/lib/puppet/module_tool/contents_description.rb +2 -1
- data/lib/puppet/module_tool/metadata.rb +2 -3
- data/lib/puppet/module_tool/shared_behaviors.rb +2 -1
- data/lib/puppet/network/authconfig.rb +4 -2
- data/lib/puppet/network/authstore.rb +2 -1
- data/lib/puppet/network/formats.rb +2 -1
- data/lib/puppet/network/http/api/indirected_routes.rb +6 -4
- data/lib/puppet/network/http/handler.rb +2 -1
- data/lib/puppet/network/http/request.rb +2 -1
- data/lib/puppet/network/http/route.rb +2 -1
- data/lib/puppet/network/resolver.rb +3 -2
- data/lib/puppet/network/rights.rb +2 -1
- data/lib/puppet/node.rb +8 -4
- data/lib/puppet/pal/catalog_compiler.rb +8 -1
- data/lib/puppet/pal/compiler.rb +2 -1
- data/lib/puppet/pal/pal_impl.rb +8 -0
- data/lib/puppet/pal/script_compiler.rb +4 -2
- data/lib/puppet/parameter.rb +4 -2
- data/lib/puppet/parameter/value_collection.rb +8 -8
- data/lib/puppet/parser/ast/pops_bridge.rb +2 -1
- data/lib/puppet/parser/compiler.rb +10 -5
- data/lib/puppet/parser/files.rb +2 -1
- data/lib/puppet/parser/functions.rb +2 -1
- data/lib/puppet/parser/relationship.rb +2 -1
- data/lib/puppet/parser/resource.rb +6 -3
- data/lib/puppet/parser/scope.rb +6 -4
- data/lib/puppet/parser/templatewrapper.rb +2 -1
- data/lib/puppet/parser/type_loader.rb +2 -1
- data/lib/puppet/pops/adaptable.rb +2 -5
- data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +2 -1
- data/lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb +2 -1
- data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +2 -1
- data/lib/puppet/pops/evaluator/runtime3_support.rb +8 -4
- data/lib/puppet/pops/loader/base_loader.rb +4 -2
- data/lib/puppet/pops/loader/dependency_loader.rb +4 -2
- data/lib/puppet/pops/loader/gem_support.rb +4 -2
- data/lib/puppet/pops/loader/loader.rb +4 -2
- data/lib/puppet/pops/loader/loader_paths.rb +2 -1
- data/lib/puppet/pops/loader/static_loader.rb +1 -1
- data/lib/puppet/pops/lookup/interpolation.rb +2 -1
- data/lib/puppet/pops/model/factory.rb +4 -2
- data/lib/puppet/pops/parser/epp_support.rb +2 -1
- data/lib/puppet/pops/parser/heredoc_support.rb +2 -1
- data/lib/puppet/pops/parser/interpolation_support.rb +10 -5
- data/lib/puppet/pops/parser/lexer2.rb +6 -3
- data/lib/puppet/pops/parser/locator.rb +2 -1
- data/lib/puppet/pops/types/type_calculator.rb +1 -1
- data/lib/puppet/pops/types/type_parser.rb +4 -2
- data/lib/puppet/pops/validation.rb +2 -1
- data/lib/puppet/pops/validation/checker4_0.rb +6 -3
- data/lib/puppet/pops/visitor.rb +12 -6
- data/lib/puppet/property.rb +19 -16
- data/lib/puppet/property/ensure.rb +2 -1
- data/lib/puppet/property/keyvalue.rb +2 -1
- data/lib/puppet/property/list.rb +2 -1
- data/lib/puppet/provider.rb +10 -8
- data/lib/puppet/provider/exec.rb +7 -4
- data/lib/puppet/provider/file/posix.rb +6 -3
- data/lib/puppet/provider/group/groupadd.rb +2 -1
- data/lib/puppet/provider/group/ldap.rb +7 -4
- data/lib/puppet/provider/group/pw.rb +4 -2
- data/lib/puppet/provider/ldap.rb +8 -4
- data/lib/puppet/provider/nameservice.rb +8 -5
- data/lib/puppet/provider/nameservice/directoryservice.rb +8 -4
- data/lib/puppet/provider/network_device.rb +4 -2
- data/lib/puppet/provider/package.rb +2 -1
- data/lib/puppet/provider/package/aix.rb +4 -2
- data/lib/puppet/provider/package/appdmg.rb +4 -2
- data/lib/puppet/provider/package/apple.rb +2 -1
- data/lib/puppet/provider/package/apt.rb +4 -2
- data/lib/puppet/provider/package/blastwave.rb +2 -1
- data/lib/puppet/provider/package/dpkg.rb +6 -3
- data/lib/puppet/provider/package/fink.rb +2 -1
- data/lib/puppet/provider/package/gem.rb +4 -2
- data/lib/puppet/provider/package/macports.rb +6 -3
- data/lib/puppet/provider/package/nim.rb +8 -4
- data/lib/puppet/provider/package/openbsd.rb +14 -8
- data/lib/puppet/provider/package/opkg.rb +2 -1
- data/lib/puppet/provider/package/pacman.rb +2 -1
- data/lib/puppet/provider/package/pip.rb +2 -1
- data/lib/puppet/provider/package/pkgdmg.rb +4 -2
- data/lib/puppet/provider/package/pkgng.rb +4 -2
- data/lib/puppet/provider/package/pkgutil.rb +2 -1
- data/lib/puppet/provider/package/portupgrade.rb +2 -1
- data/lib/puppet/provider/package/rpm.rb +8 -4
- data/lib/puppet/provider/package/windows/package.rb +2 -1
- data/lib/puppet/provider/parsedfile.rb +14 -7
- data/lib/puppet/provider/service/base.rb +7 -4
- data/lib/puppet/provider/service/launchd.rb +4 -2
- data/lib/puppet/provider/service/service.rb +2 -1
- data/lib/puppet/provider/service/upstart.rb +11 -8
- data/lib/puppet/provider/user/directoryservice.rb +2 -1
- data/lib/puppet/provider/user/hpux.rb +1 -1
- data/lib/puppet/provider/user/ldap.rb +8 -4
- data/lib/puppet/provider/user/openbsd.rb +2 -1
- data/lib/puppet/provider/user/pw.rb +2 -1
- data/lib/puppet/provider/user/user_role_add.rb +4 -2
- data/lib/puppet/provider/user/useradd.rb +7 -4
- data/lib/puppet/reference/providers.rb +2 -3
- data/lib/puppet/reference/type.rb +4 -2
- data/lib/puppet/relationship.rb +4 -9
- data/lib/puppet/resource.rb +16 -9
- data/lib/puppet/resource/capability_finder.rb +12 -8
- data/lib/puppet/resource/catalog.rb +36 -40
- data/lib/puppet/resource/type.rb +7 -3
- data/lib/puppet/resource/type_collection.rb +4 -2
- data/lib/puppet/settings.rb +36 -19
- data/lib/puppet/settings/base_setting.rb +2 -1
- data/lib/puppet/settings/config_file.rb +2 -1
- data/lib/puppet/settings/file_setting.rb +2 -1
- data/lib/puppet/settings/ini_file.rb +2 -1
- data/lib/puppet/ssl/base.rb +2 -1
- data/lib/puppet/ssl/host.rb +16 -8
- data/lib/puppet/ssl/key.rb +2 -2
- data/lib/puppet/ssl/state_machine.rb +22 -3
- data/lib/puppet/transaction/event.rb +2 -1
- data/lib/puppet/transaction/event_manager.rb +4 -2
- data/lib/puppet/transaction/report.rb +10 -10
- data/lib/puppet/transaction/resource_harness.rb +4 -2
- data/lib/puppet/type.rb +84 -48
- data/lib/puppet/type/component.rb +2 -1
- data/lib/puppet/type/exec.rb +11 -7
- data/lib/puppet/type/file.rb +15 -9
- data/lib/puppet/type/file/content.rb +7 -3
- data/lib/puppet/type/file/ctime.rb +2 -1
- data/lib/puppet/type/file/data_sync.rb +2 -1
- data/lib/puppet/type/file/ensure.rb +10 -7
- data/lib/puppet/type/file/mode.rb +2 -1
- data/lib/puppet/type/file/mtime.rb +2 -1
- data/lib/puppet/type/file/selcontext.rb +2 -1
- data/lib/puppet/type/file/source.rb +6 -7
- data/lib/puppet/type/file/target.rb +2 -1
- data/lib/puppet/type/file/type.rb +2 -1
- data/lib/puppet/type/package.rb +6 -3
- data/lib/puppet/type/resources.rb +2 -1
- data/lib/puppet/type/service.rb +2 -1
- data/lib/puppet/type/tidy.rb +14 -7
- data/lib/puppet/type/user.rb +19 -7
- data/lib/puppet/util.rb +6 -3
- data/lib/puppet/util/checksums.rb +1 -1
- data/lib/puppet/util/classgen.rb +12 -6
- data/lib/puppet/util/command_line.rb +8 -4
- data/lib/puppet/util/connection.rb +4 -2
- data/lib/puppet/util/diff.rb +4 -2
- data/lib/puppet/util/execution.rb +4 -2
- data/lib/puppet/util/feature.rb +7 -4
- data/lib/puppet/util/fileparsing.rb +57 -46
- data/lib/puppet/util/filetype.rb +2 -1
- data/lib/puppet/util/http_proxy.rb +2 -1
- data/lib/puppet/util/instance_loader.rb +2 -1
- data/lib/puppet/util/ldap/connection.rb +4 -2
- data/lib/puppet/util/ldap/manager.rb +6 -3
- data/lib/puppet/util/log.rb +6 -3
- data/lib/puppet/util/metric.rb +2 -1
- data/lib/puppet/util/posix.rb +4 -2
- data/lib/puppet/util/rdoc/code_objects.rb +2 -1
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +4 -2
- data/lib/puppet/util/selinux.rb +2 -1
- data/lib/puppet/version.rb +2 -5
- data/locales/puppet.pot +713 -685
- data/man/man5/puppet.conf.5 +9 -2
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +1 -1
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-key.8 +1 -1
- data/man/man8/puppet-lookup.8 +1 -1
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-module.8 +1 -1
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-script.8 +1 -1
- data/man/man8/puppet-ssl.8 +1 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/lib/puppet_spec/modules.rb +16 -2
- data/spec/unit/indirector/request_spec.rb +5 -6
- data/spec/unit/info_service_spec.rb +48 -0
- data/spec/unit/module_spec.rb +73 -0
- data/spec/unit/plan_spec.rb +65 -0
- data/spec/unit/puppet_pal_catalog_spec.rb +12 -0
- data/spec/unit/ssl/state_machine_spec.rb +68 -5
- metadata +6 -2
@@ -139,17 +139,19 @@ class Puppet::Indirector::SslFile < Puppet::Indirector::Terminus
|
|
139
139
|
# All types serialized to disk contain only ASCII content:
|
140
140
|
# * SSL::Key may be a .export(OpenSSL::Cipher::DES.new(:EDE3, :CBC), pass) or .to_pem
|
141
141
|
# * All other classes are translated to strings by calling .to_pem
|
142
|
-
|
143
142
|
if file_location
|
144
143
|
Puppet.settings.setting(self.class.file_setting).open('w:ASCII') { |f| yield f }
|
145
|
-
elsif setting = self.class.directory_setting
|
146
|
-
begin
|
147
|
-
Puppet.settings.setting(setting).open_file(path, 'w:ASCII') { |f| yield f }
|
148
|
-
rescue => detail
|
149
|
-
raise Puppet::Error, _("Could not write %{path} to %{setting}: %{detail}") % { path: path, setting: setting, detail: detail }, detail.backtrace
|
150
|
-
end
|
151
144
|
else
|
152
|
-
|
145
|
+
setting = self.class.directory_setting
|
146
|
+
if setting
|
147
|
+
begin
|
148
|
+
Puppet.settings.setting(setting).open_file(path, 'w:ASCII') { |f| yield f }
|
149
|
+
rescue => detail
|
150
|
+
raise Puppet::Error, _("Could not write %{path} to %{setting}: %{detail}") % { path: path, setting: setting, detail: detail }, detail.backtrace
|
151
|
+
end
|
152
|
+
else
|
153
|
+
raise Puppet::DevError, _("You must provide a setting to determine where the files are stored")
|
154
|
+
end
|
153
155
|
end
|
154
156
|
end
|
155
157
|
end
|
@@ -29,10 +29,13 @@ class Puppet::Indirector::Terminus
|
|
29
29
|
def indirection=(name)
|
30
30
|
if name.is_a?(Puppet::Indirector::Indirection)
|
31
31
|
@indirection = name
|
32
|
-
elsif ind = Puppet::Indirector::Indirection.instance(name)
|
33
|
-
@indirection = ind
|
34
32
|
else
|
35
|
-
|
33
|
+
ind = Puppet::Indirector::Indirection.instance(name)
|
34
|
+
if ind
|
35
|
+
@indirection = ind
|
36
|
+
else
|
37
|
+
raise ArgumentError, _("Could not find indirection instance %{name} for %{terminus}") % { name: name, terminus: self.name }
|
38
|
+
end
|
36
39
|
end
|
37
40
|
end
|
38
41
|
|
data/lib/puppet/info_service.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
module Puppet::InfoService
|
3
3
|
require 'puppet/info_service/class_information_service'
|
4
4
|
require 'puppet/info_service/task_information_service'
|
5
|
+
require 'puppet/info_service/plan_information_service'
|
5
6
|
|
6
7
|
def self.classes_per_environment(env_file_hash)
|
7
8
|
Puppet::InfoService::ClassInformationService.new.classes_per_environment(env_file_hash)
|
@@ -14,4 +15,12 @@ module Puppet::InfoService
|
|
14
15
|
def self.task_data(environment_name, module_name, task_name)
|
15
16
|
Puppet::InfoService::TaskInformationService.task_data(environment_name, module_name, task_name)
|
16
17
|
end
|
18
|
+
|
19
|
+
def self.plans_per_environment(environment_name)
|
20
|
+
Puppet::InfoService::PlanInformationService.plans_per_environment(environment_name)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.plan_data(environment_name, module_name, plan_name)
|
24
|
+
Puppet::InfoService::PlanInformationService.plan_data(environment_name, module_name, plan_name)
|
25
|
+
end
|
17
26
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class Puppet::InfoService::PlanInformationService
|
2
|
+
require 'puppet/module'
|
3
|
+
|
4
|
+
def self.plans_per_environment(environment_name)
|
5
|
+
# get the actual environment object, raise error if the named env doesn't exist
|
6
|
+
env = Puppet.lookup(:environments).get!(environment_name)
|
7
|
+
env.modules.map do |mod|
|
8
|
+
mod.plans.map do |plan|
|
9
|
+
{:module => {:name => plan.module.name}, :name => plan.name}
|
10
|
+
end
|
11
|
+
end.flatten
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.plan_data(environment_name, module_name, plan_name)
|
15
|
+
# raise EnvironmentNotFound if applicable
|
16
|
+
Puppet.lookup(:environments).get!(environment_name)
|
17
|
+
|
18
|
+
pup_module = Puppet::Module.find(module_name, environment_name)
|
19
|
+
if pup_module.nil?
|
20
|
+
raise Puppet::Module::MissingModule, _("Module %{module_name} not found in environment %{environment_name}.") %
|
21
|
+
{module_name: module_name, environment_name: environment_name}
|
22
|
+
end
|
23
|
+
|
24
|
+
plan = pup_module.plans.find { |t| t.name == plan_name }
|
25
|
+
if plan.nil?
|
26
|
+
raise Puppet::Module::Plan::PlanNotFound.new(plan_name, module_name)
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
plan.validate
|
31
|
+
{:metadata => plan.metadata, :files => plan.files}
|
32
|
+
rescue Puppet::Module::Plan::Error => err
|
33
|
+
{ :metadata => nil, :files => [], :error => err.to_h }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/puppet/interface.rb
CHANGED
@@ -91,7 +91,8 @@ class Puppet::Interface
|
|
91
91
|
#
|
92
92
|
# @api public
|
93
93
|
def [](name, version)
|
94
|
-
|
94
|
+
face = Puppet::Interface::FaceCollection[name, version]
|
95
|
+
unless face
|
95
96
|
# REVISIT (#18042) no sense in rechecking if version == :current -- josh
|
96
97
|
if Puppet::Interface::FaceCollection[name, :current]
|
97
98
|
raise Puppet::Error, "Could not find version #{version} of #{name}"
|
@@ -277,12 +277,16 @@ WRAPPER
|
|
277
277
|
|
278
278
|
def add_option(option)
|
279
279
|
option.aliases.each do |name|
|
280
|
-
|
280
|
+
conflict = get_option(name)
|
281
|
+
if conflict
|
281
282
|
raise ArgumentError, _("Option %{option} conflicts with existing option %{conflict}") %
|
282
283
|
{ option: option, conflict: conflict }
|
283
|
-
|
284
|
-
|
285
|
-
|
284
|
+
else
|
285
|
+
conflict = @face.get_option(name)
|
286
|
+
if conflict
|
287
|
+
raise ArgumentError, _("Option %{option} conflicts with existing option %{conflict} on %{face}") %
|
288
|
+
{ option: option, conflict: conflict, face: @face }
|
289
|
+
end
|
286
290
|
end
|
287
291
|
end
|
288
292
|
|
@@ -340,7 +344,8 @@ WRAPPER
|
|
340
344
|
overlap = Hash.new do |h, k| h[k] = [] end
|
341
345
|
unknown = []
|
342
346
|
original.keys.each do |name|
|
343
|
-
|
347
|
+
option = get_option(name)
|
348
|
+
if option
|
344
349
|
canonical = option.name
|
345
350
|
if result.has_key? canonical
|
346
351
|
overlap[canonical] << name
|
@@ -22,7 +22,8 @@ module Puppet::Interface::ActionManager
|
|
22
22
|
action = Puppet::Interface::ActionBuilder.build(self, name, &block)
|
23
23
|
|
24
24
|
# REVISIT: (#18042) doesn't this mean we can't redefine the default action? -- josh
|
25
|
-
if action.default
|
25
|
+
current = get_default_action if action.default
|
26
|
+
if current
|
26
27
|
raise "Actions #{current.name} and #{name} cannot both be default"
|
27
28
|
end
|
28
29
|
|
@@ -318,17 +318,20 @@ class Puppet::Interface
|
|
318
318
|
when String then
|
319
319
|
input.strip.split(/,/).map do |part|
|
320
320
|
part = part.strip
|
321
|
-
if part
|
321
|
+
if part.match(/^\d+$/)
|
322
322
|
part.to_i
|
323
|
-
|
324
|
-
|
323
|
+
else
|
324
|
+
found = part.split(/-/)
|
325
|
+
if found
|
326
|
+
unless found.length == 2 and found.all? {|x| x.strip =~ /^\d+$/ }
|
327
|
+
#TRANSLATORS 'copyright' is an attribute name and should not be translated
|
328
|
+
raise ArgumentError, _("%{value} is not a good copyright year or range") % { value: part.inspect }
|
329
|
+
end
|
330
|
+
Range.new(found[0].to_i, found[1].to_i)
|
331
|
+
else
|
325
332
|
#TRANSLATORS 'copyright' is an attribute name and should not be translated
|
326
333
|
raise ArgumentError, _("%{value} is not a good copyright year or range") % { value: part.inspect }
|
327
334
|
end
|
328
|
-
Range.new(found[0].to_i, found[1].to_i)
|
329
|
-
else
|
330
|
-
#TRANSLATORS 'copyright' is an attribute name and should not be translated
|
331
|
-
raise ArgumentError, _("%{value} is not a good copyright year or range") % { value: part.inspect }
|
332
335
|
end
|
333
336
|
end
|
334
337
|
|
@@ -24,13 +24,16 @@ module Puppet::Interface::FaceCollection
|
|
24
24
|
|
25
25
|
# If the version they request specifically doesn't exist, don't search
|
26
26
|
# elsewhere. Usually this will start from :current and all...
|
27
|
-
|
28
|
-
|
27
|
+
face = self[name, version]
|
28
|
+
return nil unless face
|
29
|
+
action = face.get_action(action_name)
|
30
|
+
unless action
|
29
31
|
# ...we need to search for it bound to an o{lder,ther} version. Since
|
30
32
|
# we load all actions when the face is first references, this will be in
|
31
33
|
# memory in the known set of versions of the face.
|
32
34
|
(@faces[name].keys - [ :current ]).sort.reverse_each do |vers|
|
33
|
-
|
35
|
+
action = @faces[name][vers].get_action(action_name)
|
36
|
+
break if action
|
34
37
|
end
|
35
38
|
end
|
36
39
|
|
@@ -35,7 +35,8 @@ class Puppet::Interface::Option
|
|
35
35
|
if Puppet.settings.include? name then
|
36
36
|
raise ArgumentError, _("%{option}: already defined in puppet") % { option: item.inspect }
|
37
37
|
end
|
38
|
-
|
38
|
+
dup = dups[name]
|
39
|
+
if dup
|
39
40
|
raise ArgumentError, _("%{option}: duplicates existing alias %{duplicate} in %{parent}") %
|
40
41
|
{ option: item.inspect, duplicate: dup.inspect, parent: @parent }
|
41
42
|
else
|
@@ -84,7 +85,8 @@ class Puppet::Interface::Option
|
|
84
85
|
|
85
86
|
# @api private
|
86
87
|
def optparse_to_optionname(declaration)
|
87
|
-
|
88
|
+
found = declaration.match(/^-+(?:\[no-\])?([^ =]+)/)
|
89
|
+
unless found
|
88
90
|
raise ArgumentError, _("Can't find a name in the declaration %{declaration}") % { declaration: declaration.inspect }
|
89
91
|
end
|
90
92
|
found.captures.first
|
@@ -53,14 +53,16 @@ module Puppet::Interface::OptionManager
|
|
53
53
|
@options_hash ||= {}
|
54
54
|
|
55
55
|
option.aliases.each do |name|
|
56
|
-
|
56
|
+
conflict = get_option(name)
|
57
|
+
if conflict
|
57
58
|
raise ArgumentError, _("Option %{option} conflicts with existing option %{conflict}") %
|
58
59
|
{ option: option, conflict: conflict }
|
59
60
|
end
|
60
61
|
|
61
62
|
actions.each do |action|
|
62
63
|
action = get_action(action)
|
63
|
-
|
64
|
+
conflict = action.get_option(name)
|
65
|
+
if conflict
|
64
66
|
raise ArgumentError, _("Option %{option} conflicts with existing option %{conflict} on %{action}") %
|
65
67
|
{ option: option, conflict: conflict, action: action }
|
66
68
|
end
|
data/lib/puppet/module.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'puppet/util/logging'
|
2
2
|
require 'puppet/module/task'
|
3
|
+
require 'puppet/module/plan'
|
3
4
|
require 'puppet/util/json'
|
4
5
|
require 'semantic_puppet/gem_version'
|
5
6
|
|
@@ -60,7 +61,7 @@ class Puppet::Module
|
|
60
61
|
SemanticPuppet::VersionRange.parse(range)
|
61
62
|
end
|
62
63
|
|
63
|
-
attr_reader :name, :environment, :path, :metadata, :tasks
|
64
|
+
attr_reader :name, :environment, :path, :metadata, :tasks, :plans
|
64
65
|
attr_writer :environment
|
65
66
|
|
66
67
|
attr_accessor :dependencies, :forge_name
|
@@ -171,6 +172,39 @@ class Puppet::Module
|
|
171
172
|
end
|
172
173
|
end
|
173
174
|
|
175
|
+
def plans_directory
|
176
|
+
subpath("plans")
|
177
|
+
end
|
178
|
+
|
179
|
+
def plans
|
180
|
+
return @plans if instance_variable_defined?(:@plans)
|
181
|
+
|
182
|
+
if Puppet::FileSystem.exist?(plans_directory)
|
183
|
+
@plans = Puppet::Module::Plan.plans_in_module(self)
|
184
|
+
else
|
185
|
+
@plans = []
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
# This is a re-implementation of the Filetypes singular type method (e.g.
|
190
|
+
# `manifest('my/manifest.pp')`. We don't implement the full filetype "API" for
|
191
|
+
# plans.
|
192
|
+
def plan_file(name)
|
193
|
+
# If 'file' is nil then they're asking for the base path.
|
194
|
+
# This is used for things like fileserving.
|
195
|
+
if name
|
196
|
+
full_path = File.join(plans_directory, name)
|
197
|
+
else
|
198
|
+
full_path = plans_directory
|
199
|
+
end
|
200
|
+
|
201
|
+
if Puppet::FileSystem.exist?(full_path)
|
202
|
+
return full_path
|
203
|
+
else
|
204
|
+
return nil
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
174
208
|
def license_file
|
175
209
|
return @license_file if defined?(@license_file)
|
176
210
|
|
@@ -0,0 +1,160 @@
|
|
1
|
+
require 'puppet/util/logging'
|
2
|
+
|
3
|
+
class Puppet::Module
|
4
|
+
class Plan
|
5
|
+
class Error < Puppet::Error
|
6
|
+
attr_accessor :kind, :details
|
7
|
+
def initialize(message, kind, details = nil)
|
8
|
+
super(message)
|
9
|
+
@details = details || {}
|
10
|
+
@kind = kind
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_h
|
14
|
+
{
|
15
|
+
msg: message,
|
16
|
+
kind: kind,
|
17
|
+
details: details
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class InvalidName < Error
|
23
|
+
def initialize(name, msg)
|
24
|
+
super(msg, 'puppet.plans/invalid-name')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class InvalidFile < Error
|
29
|
+
def initialize(msg)
|
30
|
+
super(msg, 'puppet.plans/invalid-file')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class InvalidPlan < Error
|
35
|
+
end
|
36
|
+
class InvalidMetadata < Error
|
37
|
+
end
|
38
|
+
class PlanNotFound < Error
|
39
|
+
def initialize(plan_name, module_name)
|
40
|
+
msg = _("Plan %{plan_name} not found in module %{module_name}.") %
|
41
|
+
{plan_name: plan_name, module_name: module_name}
|
42
|
+
super(msg, 'puppet.plans/plan-not-found', { 'name' => plan_name })
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
ALLOWED_EXTENSIONS = %w{.pp .yaml}
|
47
|
+
RESERVED_WORDS = %w{and application attr case class consumes default else
|
48
|
+
elsif environment false function if import in inherits node or private
|
49
|
+
produces site true type undef unless}
|
50
|
+
RESERVED_DATA_TYPES = %w{any array boolean catalogentry class collection
|
51
|
+
callable data default enum float hash integer numeric optional pattern
|
52
|
+
resource runtime scalar string struct tuple type undef variant}
|
53
|
+
MOUNTS = %w[lib files plans]
|
54
|
+
|
55
|
+
def self.is_plan_name?(name)
|
56
|
+
return true if name =~ /^[a-z][a-z0-9_]*$/
|
57
|
+
return false
|
58
|
+
end
|
59
|
+
|
60
|
+
# Determine whether a plan file has a legal name and extension
|
61
|
+
def self.is_plans_filename?(path)
|
62
|
+
name = File.basename(path, '.*')
|
63
|
+
ext = File.extname(path)
|
64
|
+
return [false, _("Plan names must start with a lowercase letter and be composed of only lowercase letters, numbers, and underscores")] unless is_plan_name?(name)
|
65
|
+
unless ALLOWED_EXTENSIONS.include? ext
|
66
|
+
return [false, _("Plan name cannot have extension %{ext}, must be .pp or .yaml") % { ext: ext }]
|
67
|
+
end
|
68
|
+
if RESERVED_WORDS.include?(name)
|
69
|
+
return [false, _("Plan name cannot be a reserved word, but was '%{name}'") % { name: name }]
|
70
|
+
end
|
71
|
+
if RESERVED_DATA_TYPES.include?(name)
|
72
|
+
return [false, _("Plan name cannot be a Puppet data type, but was '%{name}'") % { name: name }]
|
73
|
+
end
|
74
|
+
return [true]
|
75
|
+
end
|
76
|
+
|
77
|
+
# Executables list should contain the full path of all possible implementation files
|
78
|
+
def self.find_implementations(name, plan_files)
|
79
|
+
basename = name.split('::')[1] || 'init'
|
80
|
+
|
81
|
+
# If implementations isn't defined, then we use executables matching the
|
82
|
+
# plan name, and only one may exist.
|
83
|
+
implementations = plan_files.select { |impl| File.basename(impl, '.*') == basename }
|
84
|
+
|
85
|
+
# Select .pp before .yaml, since .pp comes before .yaml alphabetically.
|
86
|
+
chosen = implementations.sort.first
|
87
|
+
|
88
|
+
[{ "name" => File.basename(chosen), "path" => chosen }]
|
89
|
+
end
|
90
|
+
private_class_method :find_implementations
|
91
|
+
|
92
|
+
def self.find_files(name, plan_files)
|
93
|
+
find_implementations(name, plan_files)
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.plans_in_module(pup_module)
|
97
|
+
# Search e.g. 'modules/<pup_module>/plans' for all plans
|
98
|
+
plan_files = Dir.glob(File.join(pup_module.plans_directory, '*'))
|
99
|
+
.keep_if { |f| valid, _ = is_plans_filename?(f); valid }
|
100
|
+
|
101
|
+
plans = plan_files.group_by { |f| plan_name_from_path(f) }
|
102
|
+
|
103
|
+
plans.map do |plan, plan_filenames|
|
104
|
+
new_with_files(pup_module, plan, plan_filenames)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
attr_reader :name, :module, :metadata_file, :metadata
|
109
|
+
|
110
|
+
# file paths must be relative to the modules plan directory
|
111
|
+
def initialize(pup_module, plan_name, plan_files)
|
112
|
+
valid, reason = Puppet::Module::Plan.is_plans_filename?(plan_files.first)
|
113
|
+
unless valid
|
114
|
+
raise InvalidName.new(plan_name, reason)
|
115
|
+
end
|
116
|
+
|
117
|
+
name = plan_name == "init" ? pup_module.name : "#{pup_module.name}::#{plan_name}"
|
118
|
+
|
119
|
+
@module = pup_module
|
120
|
+
@name = name
|
121
|
+
@metadata_file = metadata_file
|
122
|
+
@plan_files = plan_files || []
|
123
|
+
end
|
124
|
+
|
125
|
+
def metadata
|
126
|
+
# Nothing to go here unless plans eventually support metadata.
|
127
|
+
@metadata ||= {}
|
128
|
+
end
|
129
|
+
|
130
|
+
def files
|
131
|
+
@files ||= self.class.find_files(@name, @plan_files)
|
132
|
+
end
|
133
|
+
|
134
|
+
def validate
|
135
|
+
files
|
136
|
+
true
|
137
|
+
end
|
138
|
+
|
139
|
+
def ==(other)
|
140
|
+
self.name == other.name &&
|
141
|
+
self.module == other.module
|
142
|
+
end
|
143
|
+
|
144
|
+
def environment_name
|
145
|
+
@module.environment.respond_to?(:name) ? @module.environment.name : 'production'
|
146
|
+
end
|
147
|
+
private :environment_name
|
148
|
+
|
149
|
+
def self.new_with_files(pup_module, name, plan_files)
|
150
|
+
Puppet::Module::Plan.new(pup_module, name, plan_files)
|
151
|
+
end
|
152
|
+
private_class_method :new_with_files
|
153
|
+
|
154
|
+
# Abstracted here so we can add support for subdirectories later
|
155
|
+
def self.plan_name_from_path(path)
|
156
|
+
return File.basename(path, '.*')
|
157
|
+
end
|
158
|
+
private_class_method :plan_name_from_path
|
159
|
+
end
|
160
|
+
end
|