puppet 4.10.10 → 4.10.11

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.

Files changed (84) hide show
  1. data/CONTRIBUTING.md +15 -15
  2. data/Gemfile +3 -0
  3. data/README.md +11 -11
  4. data/ext/project_data.yaml +4 -2
  5. data/lib/puppet/application/agent.rb +1 -3
  6. data/lib/puppet/application/apply.rb +1 -3
  7. data/lib/puppet/application/cert.rb +6 -1
  8. data/lib/puppet/application/lookup.rb +11 -1
  9. data/lib/puppet/configurer.rb +17 -4
  10. data/lib/puppet/environments.rb +1 -1
  11. data/lib/puppet/functions/map.rb +1 -1
  12. data/lib/puppet/indirector/indirection.rb +3 -3
  13. data/lib/puppet/indirector/request.rb +6 -2
  14. data/lib/puppet/network/http/connection.rb +8 -0
  15. data/lib/puppet/parser/functions/new.rb +29 -44
  16. data/lib/puppet/parser/functions/return.rb +22 -1
  17. data/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
  18. data/lib/puppet/provider/group/windows_adsi.rb +4 -7
  19. data/lib/puppet/provider/package/dnf.rb +1 -1
  20. data/lib/puppet/provider/service/systemd.rb +1 -1
  21. data/lib/puppet/provider/user/aix.rb +1 -1
  22. data/lib/puppet/provider/user/windows_adsi.rb +1 -1
  23. data/lib/puppet/reference/configuration.rb +2 -0
  24. data/lib/puppet/type/tidy.rb +8 -1
  25. data/lib/puppet/type/user.rb +34 -3
  26. data/lib/puppet/util/reference.rb +2 -9
  27. data/lib/puppet/util/windows/adsi.rb +28 -31
  28. data/lib/puppet/util/windows/file.rb +61 -9
  29. data/lib/puppet/util/windows/principal.rb +9 -7
  30. data/lib/puppet/util/windows/sid.rb +60 -7
  31. data/lib/puppet/version.rb +1 -1
  32. data/locales/puppet.pot +79 -11
  33. data/man/man5/puppet.conf.5 +6 -8
  34. data/man/man8/extlookup2hiera.8 +1 -1
  35. data/man/man8/puppet-agent.8 +1 -1
  36. data/man/man8/puppet-apply.8 +1 -1
  37. data/man/man8/puppet-ca.8 +1 -1
  38. data/man/man8/puppet-catalog.8 +1 -1
  39. data/man/man8/puppet-cert.8 +1 -1
  40. data/man/man8/puppet-certificate.8 +1 -1
  41. data/man/man8/puppet-certificate_request.8 +1 -1
  42. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  43. data/man/man8/puppet-config.8 +1 -1
  44. data/man/man8/puppet-describe.8 +1 -1
  45. data/man/man8/puppet-device.8 +1 -1
  46. data/man/man8/puppet-doc.8 +1 -1
  47. data/man/man8/puppet-epp.8 +1 -1
  48. data/man/man8/puppet-facts.8 +1 -1
  49. data/man/man8/puppet-file.8 +1 -1
  50. data/man/man8/puppet-filebucket.8 +1 -1
  51. data/man/man8/puppet-generate.8 +1 -1
  52. data/man/man8/puppet-help.8 +1 -1
  53. data/man/man8/puppet-inspect.8 +1 -1
  54. data/man/man8/puppet-key.8 +1 -1
  55. data/man/man8/puppet-lookup.8 +1 -1
  56. data/man/man8/puppet-man.8 +1 -1
  57. data/man/man8/puppet-master.8 +1 -1
  58. data/man/man8/puppet-module.8 +1 -1
  59. data/man/man8/puppet-node.8 +1 -1
  60. data/man/man8/puppet-parser.8 +1 -1
  61. data/man/man8/puppet-plugin.8 +1 -1
  62. data/man/man8/puppet-report.8 +1 -1
  63. data/man/man8/puppet-resource.8 +1 -1
  64. data/man/man8/puppet-resource_type.8 +1 -1
  65. data/man/man8/puppet-status.8 +1 -1
  66. data/man/man8/puppet.8 +2 -2
  67. data/spec/integration/application/lookup_spec.rb +21 -0
  68. data/spec/integration/parser/pcore_resource_spec.rb +1 -1
  69. data/spec/integration/util/windows/adsi_spec.rb +86 -1
  70. data/spec/integration/util/windows/principal_spec.rb +10 -1
  71. data/spec/unit/application/agent_spec.rb +0 -9
  72. data/spec/unit/application/apply_spec.rb +0 -9
  73. data/spec/unit/application/cert_spec.rb +40 -1
  74. data/spec/unit/configurer_spec.rb +14 -0
  75. data/spec/unit/indirector/indirection_spec.rb +24 -2
  76. data/spec/unit/provider/group/windows_adsi_spec.rb +79 -22
  77. data/spec/unit/provider/service/systemd_spec.rb +1 -1
  78. data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
  79. data/spec/unit/type/tidy_spec.rb +14 -0
  80. data/spec/unit/util/windows/adsi_spec.rb +31 -27
  81. data/spec/unit/util/windows/sid_spec.rb +86 -15
  82. data/tasks/manpages.rake +1 -1
  83. metadata +3621 -3609
  84. checksums.yaml +0 -7
@@ -22,18 +22,17 @@ be added in modules. Exceptions would be things like new cross-OS providers
22
22
  and updates to existing core types.
23
23
 
24
24
  If you are unsure of whether your contribution should be implemented as a
25
- module or part of Puppet Core, you may visit
26
- [#puppet-dev on Freenode IRC](https://freenode.net) or ask on the
27
- [puppet-dev mailing list](https://groups.google.com/forum/#!forum/puppet-dev)
28
- for advice.
25
+ module or part of Puppet Core, you may visit [#puppet-dev on slack](https://puppetcommunity.slack.com/), or ask on
26
+ the [puppet-dev mailing list](https://groups.google.com/forum/#!forum/puppet-dev) for advice.
29
27
 
30
28
  ## Getting Started
31
29
 
32
30
  * Make sure you have a [Jira account](https://tickets.puppetlabs.com)
33
31
  * Make sure you have a [GitHub account](https://github.com/signup/free)
34
- * Submit a ticket for your issue, assuming one does not already exist.
35
- * Clearly describe the issue including steps to reproduce when it is a bug.
32
+ * Submit a Jira ticket for your issue if one does not already exist.
33
+ * Clearly describe the issue including steps to reproduce when it is a bug
36
34
  * Make sure you fill in the earliest version that you know has the issue.
35
+ * A ticket is not necessary for [trivial changes](https://docs.puppet.com/community/trivial_patch_exemption.html)
37
36
  * Fork the repository on GitHub
38
37
 
39
38
  ## Making Changes
@@ -45,7 +44,7 @@ for advice.
45
44
  * To quickly create a topic branch based on master; `git checkout -b
46
45
  fix/master/my_contribution master`. Please avoid working directly on the
47
46
  `master` branch.
48
- * Make commits of logical units.
47
+ * Make commits of logical and atomic units.
49
48
  * Check for unnecessary whitespace with `git diff --check` before committing.
50
49
  * Make sure your commit messages are in the proper format.
51
50
 
@@ -64,19 +63,20 @@ for advice.
64
63
  ````
65
64
 
66
65
  * Make sure you have added the necessary tests for your changes.
67
- * Run _all_ the tests to assure nothing else was accidentally broken.
66
+ * Run _all_ the tests to assure nothing else was accidentally broken. First
67
+ install all the test dependencies with `bundle install --path .bundle`. Then
68
+ either run all the tests serially with `bundle exec rspec spec` or in parallel
69
+ with `bundle exec rake parallel:spec[process_count]`
68
70
 
69
71
  ## Making Trivial Changes
70
72
 
71
- ### Documentation
72
-
73
- For changes of a trivial nature to comments and documentation, it is not
74
- always necessary to create a new ticket in Jira. In this case, it is
75
- appropriate to start the first line of a commit with '(doc)' instead of
76
- a ticket number.
73
+ For [changes of a trivial nature](https://docs.puppet.com/community/trivial_patch_exemption.html), it is not always necessary to create a new
74
+ ticket in Jira. In this case, it is appropriate to start the first line of a
75
+ commit with one of `(docs)`, `(maint)`, or `(packaging)` instead of a ticket
76
+ number.
77
77
 
78
78
  ````
79
- (doc) Add documentation commit example to CONTRIBUTING
79
+ (docs) Add documentation commit example to CONTRIBUTING
80
80
 
81
81
  There is no example for contributing a documentation commit
82
82
  to the Puppet repository. This is a problem because the contributor
data/Gemfile CHANGED
@@ -58,6 +58,9 @@ group(:development, :test) do
58
58
  gem 'rdoc', "~> 4.1", :platforms => [:ruby]
59
59
  gem 'yard'
60
60
 
61
+ # ronn is used for generating manpages.
62
+ gem 'ronn', '~> 0.7.3', :platforms => [:ruby]
63
+
61
64
  # webmock requires addressable as as of 2.5.0 addressable started
62
65
  # requiring the public_suffix gem which requires Ruby 2
63
66
  gem 'addressable', '< 2.5.0'
data/README.md CHANGED
@@ -12,41 +12,41 @@ Documentation
12
12
  -------------
13
13
 
14
14
  Documentation for Puppet and related projects can be found online at the
15
- [Puppet Docs site](https://docs.puppetlabs.com).
15
+ [Puppet Docs site](https://puppet.com/docs).
16
16
 
17
17
  HTTP API
18
18
  --------
19
- [HTTP API Index](https://docs.puppetlabs.com/puppet/latest/reference/http_api/http_api_index.html)
19
+ [HTTP API Index](https://puppet.com/docs/puppet/4.10/http_api/http_api_index.html)
20
20
 
21
21
  Installation
22
22
  ------------
23
23
 
24
- The best way to run Puppet is with [Puppet Enterprise](https://puppetlabs.com/puppet/puppet-enterprise),
24
+ The best way to run Puppet is with [Puppet Enterprise](https://puppet.com/puppet/puppet-enterprise),
25
25
  which also includes orchestration features, a web console, and professional support.
26
- [The PE documentation is available here.](https://docs.puppetlabs.com/pe/latest)
26
+ [The PE documentation is available here.](https://puppet.com/docs/pe/latest)
27
27
 
28
28
  To install an open source release of Puppet,
29
- [see the installation guide on the docs site.](http://docs.puppetlabs.com/puppet/latest/reference/install_pre.html)
29
+ [see the installation guide on the docs site.](http://puppet.com/docs/puppet/4.10/install_pre.html)
30
30
 
31
31
  If you need to run Puppet from source as a tester or developer,
32
- [see the running from source guide on the docs site.](https://docs.puppetlabs.com/guides/from_source.html)
32
+ [see the running from source guide on the docs site.](https://docs.puppet.com/puppet/3.8/from_source.html)
33
33
 
34
34
  Developing and Contributing
35
35
  ------
36
36
 
37
37
  We'd love to get contributions from you! For a quick guide to getting your
38
38
  system setup for developing take a look at our [Quickstart
39
- Guide](docs/quickstart.md). Once you are up and running, take a look at the
40
- [Contribution Documents](CONTRIBUTING.md) to see how to get your changes merged
39
+ Guide](https://github.com/puppetlabs/puppet/blob/master/docs/quickstart.md). Once you are up and running, take a look at the
40
+ [Contribution Documents](https://github.com/puppetlabs/puppet/blob/master/CONTRIBUTING.md) to see how to get your changes merged
41
41
  in.
42
42
 
43
43
  For more complete docs on developing with puppet you can take a look at the
44
- rest of the [developer documents](docs/index.md).
44
+ rest of the [developer documents](https://github.com/puppetlabs/puppet/blob/master/docs/index.md).
45
45
 
46
46
  License
47
47
  -------
48
48
 
49
- See [LICENSE](LICENSE) file.
49
+ See [LICENSE](https://github.com/puppetlabs/puppet/blob/master/LICENSE) file.
50
50
 
51
51
  Support
52
52
  -------
@@ -71,4 +71,4 @@ a best effort to backport that fix onto the latest Puppet 3 release.
71
71
  Long-term support, including security patches and bug fixes, is available for
72
72
  commercial customers. Please see the following page for more details:
73
73
 
74
- [Puppet Enterprise Support Lifecycle](https://puppetlabs.com/misc/puppet-enterprise-lifecycle)
74
+ [Puppet Enterprise Support Lifecycle](https://puppet.com/misc/puppet-enterprise-lifecycle)
@@ -37,7 +37,8 @@ gem_platform_dependencies:
37
37
  x86-mingw32:
38
38
  gem_runtime_dependencies:
39
39
  # Pinning versions that require native extensions
40
- ffi: '~> 1.9.6'
40
+ # ffi is pinned due to PUP-8438
41
+ ffi: '<= 1.9.18'
41
42
  # win32-xxxx gems are pinned due to PUP-6445
42
43
  win32-dir: '= 0.4.9'
43
44
  win32-eventlog: '= 0.6.5'
@@ -48,7 +49,8 @@ gem_platform_dependencies:
48
49
  minitar: '~> 0.6.1'
49
50
  x64-mingw32:
50
51
  gem_runtime_dependencies:
51
- ffi: '~> 1.9.6'
52
+ # ffi is pinned due to PUP-8438
53
+ ffi: '<= 1.9.18'
52
54
  # win32-xxxx gems are pinned due to PUP-6445
53
55
  win32-dir: '= 0.4.9'
54
56
  win32-eventlog: '= 0.6.5'
@@ -411,9 +411,7 @@ Copyright (c) 2011 Puppet Inc., LLC Licensed under the Apache 2.0 License
411
411
  # we want the last report to be persisted locally
412
412
  Puppet::Transaction::Report.indirection.cache_class = :yaml
413
413
 
414
- if Puppet[:noop]
415
- Puppet::Resource::Catalog.indirection.cache_class = nil
416
- elsif Puppet[:catalog_cache_terminus]
414
+ if Puppet[:catalog_cache_terminus]
417
415
  Puppet::Resource::Catalog.indirection.cache_class = Puppet[:catalog_cache_terminus]
418
416
  end
419
417
 
@@ -316,9 +316,7 @@ Copyright (c) 2011 Puppet Inc., LLC Licensed under the Apache 2.0 License
316
316
  Puppet.settings.use :main, :agent, :ssl
317
317
 
318
318
 
319
- if Puppet[:noop]
320
- Puppet::Resource::Catalog.indirection.cache_class = nil
321
- elsif Puppet[:catalog_cache_terminus]
319
+ if Puppet[:catalog_cache_terminus]
322
320
  Puppet::Resource::Catalog.indirection.cache_class = Puppet[:catalog_cache_terminus]
323
321
  end
324
322
 
@@ -264,7 +264,12 @@ Copyright (c) 2011 Puppet Inc., LLC Licensed under the Apache 2.0 License
264
264
  hosts = command_line.args.collect { |h| h.downcase }
265
265
  end
266
266
  begin
267
- apply(@ca, :revoke, options.merge(:to => hosts)) if subcommand == :destroy
267
+ if subcommand == :destroy
268
+ raise _("Refusing to destroy all certs, provide an explicit list of certs to destroy") if hosts == :all
269
+
270
+ signed_hosts = hosts - @ca.waiting?
271
+ apply(@ca, :revoke, options.merge(:to => signed_hosts)) unless signed_hosts.empty?
272
+ end
268
273
  apply(@ca, subcommand, options.merge(:to => hosts, :digest => @digest))
269
274
  rescue => detail
270
275
  Puppet.log_exception(detail)
@@ -318,7 +318,17 @@ Copyright (c) 2015 Puppet Inc., LLC Licensed under the Apache 2.0 License
318
318
  Puppet.settings[:node_cache_terminus] = nil
319
319
  end
320
320
 
321
- node = Puppet::Node.indirection.find(node) unless node.is_a?(Puppet::Node) # to allow unit tests to pass a node instance
321
+ unless node.is_a?(Puppet::Node) # to allow unit tests to pass a node instance
322
+ ni = Puppet::Node.indirection
323
+ tc = ni.terminus_class
324
+ if tc == :plain || options[:compile]
325
+ node = ni.find(node)
326
+ else
327
+ ni.terminus_class = :plain
328
+ node = ni.find(node)
329
+ ni.terminus_class = tc
330
+ end
331
+ end
322
332
 
323
333
  fact_file = options[:fact_file]
324
334
 
@@ -419,8 +419,13 @@ class Puppet::Configurer
419
419
  def retrieve_catalog_from_cache(query_options)
420
420
  result = nil
421
421
  @duration = thinmark do
422
- result = Puppet::Resource::Catalog.indirection.find(Puppet[:node_name_value],
423
- query_options.merge(:ignore_terminus => true, :environment => Puppet::Node::Environment.remote(@environment)))
422
+ result = Puppet::Resource::Catalog.indirection.find(
423
+ Puppet[:node_name_value],
424
+ query_options.merge(
425
+ :ignore_terminus => true,
426
+ :environment => Puppet::Node::Environment.remote(@environment)
427
+ )
428
+ )
424
429
  end
425
430
  result
426
431
  rescue => detail
@@ -431,8 +436,16 @@ class Puppet::Configurer
431
436
  def retrieve_new_catalog(query_options)
432
437
  result = nil
433
438
  @duration = thinmark do
434
- result = Puppet::Resource::Catalog.indirection.find(Puppet[:node_name_value],
435
- query_options.merge(:ignore_cache => true, :environment => Puppet::Node::Environment.remote(@environment), :fail_on_404 => true))
439
+ result = Puppet::Resource::Catalog.indirection.find(
440
+ Puppet[:node_name_value],
441
+ query_options.merge(
442
+ :ignore_cache => true,
443
+ # We never want to update the cached Catalog if we're running in noop mode.
444
+ :ignore_cache_save => Puppet[:noop],
445
+ :environment => Puppet::Node::Environment.remote(@environment),
446
+ :fail_on_404 => true
447
+ )
448
+ )
436
449
  end
437
450
  result
438
451
  rescue StandardError => detail
@@ -297,7 +297,7 @@ module Puppet::Environments
297
297
  end
298
298
 
299
299
  # Returns the end of time (the next Mesoamerican Long Count cycle-end after 2012 (5125+2012) = 7137,
300
- # of for a 32 bit machine using Ruby < 1.9.3, the year 2038.
300
+ # or for a 32 bit machine using Ruby < 1.9.3, the year 2038.
301
301
  def self.end_of_time
302
302
  begin
303
303
  Time.gm(7137)
@@ -123,7 +123,7 @@ Puppet::Functions.create_function(:map) do
123
123
  begin
124
124
  loop do
125
125
  result << yield(index, enum.next)
126
- index = index +1
126
+ index = index + 1
127
127
  end
128
128
  rescue StopIteration
129
129
  end
@@ -161,7 +161,7 @@ class Puppet::Indirector::Indirection
161
161
  def expire(key, options={})
162
162
  request = request(:expire, key, nil, options)
163
163
 
164
- return nil unless cache?
164
+ return nil unless cache? && !request.ignore_cache_save?
165
165
 
166
166
  return nil unless instance = cache.find(request(:find, key, nil, options))
167
167
 
@@ -194,7 +194,7 @@ class Puppet::Indirector::Indirection
194
194
  result = terminus.find(request)
195
195
  if not result.nil?
196
196
  result.expiration ||= self.expiration if result.respond_to?(:expiration)
197
- if cache?
197
+ if cache? && !request.ignore_cache_save?
198
198
  Puppet.info "Caching #{self.name} for #{request.key}"
199
199
  begin
200
200
  cache.save request(:save, key, result, options)
@@ -285,7 +285,7 @@ class Puppet::Indirector::Indirection
285
285
  result = terminus.save(request)
286
286
 
287
287
  # If caching is enabled, save our document there
288
- cache.save(request) if cache?
288
+ cache.save(request) if cache? && !request.ignore_cache_save?
289
289
 
290
290
  result
291
291
  end
@@ -10,7 +10,7 @@ require 'puppet/util/psych_support'
10
10
  class Puppet::Indirector::Request
11
11
  include Puppet::Util::PsychSupport
12
12
 
13
- attr_accessor :key, :method, :options, :instance, :node, :ip, :authenticated, :ignore_cache, :ignore_terminus
13
+ attr_accessor :key, :method, :options, :instance, :node, :ip, :authenticated, :ignore_cache, :ignore_cache_save, :ignore_terminus
14
14
 
15
15
  attr_accessor :server, :port, :uri, :protocol
16
16
 
@@ -18,7 +18,7 @@ class Puppet::Indirector::Request
18
18
 
19
19
  # trusted_information is specifically left out because we can't serialize it
20
20
  # and keep it "trusted"
21
- OPTION_ATTRIBUTES = [:ip, :node, :authenticated, :ignore_terminus, :ignore_cache, :instance, :environment]
21
+ OPTION_ATTRIBUTES = [:ip, :node, :authenticated, :ignore_terminus, :ignore_cache, :ignore_cache_save, :instance, :environment]
22
22
 
23
23
  # Is this an authenticated request?
24
24
  def authenticated?
@@ -58,6 +58,10 @@ class Puppet::Indirector::Request
58
58
  ignore_cache
59
59
  end
60
60
 
61
+ def ignore_cache_save?
62
+ ignore_cache_save
63
+ end
64
+
61
65
  def ignore_terminus?
62
66
  ignore_terminus
63
67
  end
@@ -4,6 +4,7 @@ require 'puppet/ssl/configuration'
4
4
  require 'puppet/ssl/validator'
5
5
  require 'puppet/network/http'
6
6
  require 'uri'
7
+ require 'time'
7
8
 
8
9
  module Puppet::Network::HTTP
9
10
 
@@ -205,7 +206,14 @@ module Puppet::Network::HTTP
205
206
  end
206
207
 
207
208
  def execute_request(connection, request)
209
+ start = Time.now
208
210
  connection.request(request)
211
+ rescue EOFError => e
212
+ elapsed = (Time.now - start).to_f.round(3)
213
+ uri = @site.addr + request.path.split('?')[0]
214
+ eof = EOFError.new(_('request %{uri} interrupted after %{elapsed} seconds') % {uri: uri, elapsed: elapsed})
215
+ eof.set_backtrace(e.backtrace) unless e.backtrace.empty?
216
+ raise eof
209
217
  end
210
218
 
211
219
  def with_connection(site, &block)
@@ -56,16 +56,14 @@ Would fail with an assertion error (since value is less than 0).
56
56
  The following sections show the arguments and conversion rules
57
57
  per data type built into the Puppet Type System.
58
58
 
59
- Conversion to Optional[T] and NotUndef[T]
60
- -----------------------------------------
59
+ ### Conversion to Optional[T] and NotUndef[T]
61
60
 
62
61
  Conversion to these data types is the same as a conversion to the type argument `T`.
63
62
  In the case of `Optional[T]` it is accepted that the argument to convert may be `undef`.
64
63
  It is however not acceptable to give other arguments (than `undef`) that cannot be
65
64
  converted to `T`.
66
65
 
67
- Conversion to Integer
68
- ---------------------
66
+ ### Conversion to Integer
69
67
 
70
68
  A new `Integer` can be created from `Integer`, `Float`, `Boolean`, and `String` values.
71
69
  For conversion from `String` it is possible to specify the radix (base).
@@ -113,8 +111,7 @@ $a_number = Integer(true) # results in 1
113
111
  $a_number = Integer(-38, 10, true) # results in 38
114
112
  ```
115
113
 
116
- Conversion to Float
117
- -------------------
114
+ ### Conversion to Float
118
115
 
119
116
  A new `Float` can be created from `Integer`, `Float`, `Boolean`, and `String` values.
120
117
  For conversion from `String` both float and integer formats are supported.
@@ -126,15 +123,13 @@ function Float.new(
126
123
  )
127
124
  ```
128
125
 
129
-
130
126
  * For an integer, the floating point fraction of `.0` is added to the value.
131
127
  * A `Boolean` `true` is converted to 1.0, and a `false` to 0.0
132
128
  * In `String` format, integer prefixes for hex and binary are understood (but not octal since
133
129
  floating point in string format may start with a '0').
134
130
  * When `abs` is set to `true`, the result will be an absolute floating point value.
135
131
 
136
- Conversion to Numeric
137
- ---------------------
132
+ ### Conversion to Numeric
138
133
 
139
134
  A new `Integer` or `Float` can be created from `Integer`, `Float`, `Boolean` and
140
135
  `String` values.
@@ -163,8 +158,7 @@ $a_number = Numeric(-42.3, true) # results in 42.3
163
158
  $a_number = Numeric(-42, true) # results in 42
164
159
  ```
165
160
 
166
- Conversion to Timespan
167
- -------------------
161
+ ### Conversion to Timespan
168
162
 
169
163
  A new `Timespan` can be created from `Integer`, `Float`, `String`, and `Hash` values. Several variants of the constructor are provided.
170
164
 
@@ -281,8 +275,7 @@ $duration = Timespan('10:03.5', '%M:%S.%L') # 10 minutes, 3 seconds, and 5 milli
281
275
  $duration = Timespan('10:03.5', '%M:%S.%N') # 10 minutes, 3 seconds, and 5 nano-seconds
282
276
  ```
283
277
 
284
- Conversion to Timestamp
285
- -------------------
278
+ ### Conversion to Timestamp
286
279
 
287
280
  A new `Timestamp` can be created from `Integer`, `Float`, `String`, and `Hash` values. Several variants of the constructor are provided.
288
281
 
@@ -475,8 +468,7 @@ $ts = Timestamp('2016-08-24T12:13:14', default, 'PST') # 2016-08-24 20:13:14.0
475
468
 
476
469
  ```
477
470
 
478
- Conversion to String
479
- --------------------
471
+ ### Conversion to String
480
472
 
481
473
  Conversion to `String` is the most comprehensive conversion as there are many
482
474
  use cases where a string representation is wanted. The defaults for the many options
@@ -519,7 +511,7 @@ included in a string format.
519
511
  Note that all data type supports the formats `s` and `p` with the meaning "default string representation" and
520
512
  "default programmatic string representation" (which for example means that a String is quoted in 'p' format).
521
513
 
522
- ### Signatures of String conversion
514
+ #### Signatures of String conversion
523
515
 
524
516
  ```puppet
525
517
  type Format = Pattern[/^%([\s\+\-#0\[\{<\(\|]*)([1-9][0-9]*)?(?:\.([0-9]+))?([a-zA-Z])/]
@@ -577,7 +569,7 @@ $str = String([1,2,3], $formats) # produces '(0x1, 0x2, 0x3)'
577
569
  The given formats are merged with the default formats, and matching of values to convert against format is based on
578
570
  the specificity of the mapped type; for example, different formats can be used for short and long arrays.
579
571
 
580
- ### Integer to String
572
+ #### Integer to String
581
573
 
582
574
  | Format | Integer Formats
583
575
  | ------ | ---------------
@@ -592,7 +584,7 @@ the specificity of the mapped type; for example, different formats can be used f
592
584
 
593
585
  Defaults to `d`.
594
586
 
595
- ### Float to String
587
+ #### Float to String
596
588
 
597
589
  | Format | Float formats
598
590
  | ------ | -------------
@@ -606,7 +598,7 @@ Defaults to `d`.
606
598
 
607
599
  Defaults to `p`.
608
600
 
609
- ### String to String
601
+ #### String to String
610
602
 
611
603
  | Format | String
612
604
  | ------ | ------
@@ -620,7 +612,7 @@ Defaults to `p`.
620
612
 
621
613
  Defaults to `s` at top level and `p` inside array or hash.
622
614
 
623
- ### Boolean to String
615
+ #### Boolean to String
624
616
 
625
617
  | Format | Boolean Formats
626
618
  | ---- | -------------------
@@ -631,14 +623,14 @@ Defaults to `s` at top level and `p` inside array or hash.
631
623
  | s | String 'true' / 'false'.
632
624
  | p | String 'true' / 'false'.
633
625
 
634
- ### Regexp to String
626
+ #### Regexp to String
635
627
 
636
628
  | Format | Regexp Formats
637
629
  | ---- | --------------
638
630
  | s | No delimiters, quoted if alternative flag `#` is used.
639
631
  | p | Delimiters `/ /`.
640
632
 
641
- ### Undef to String
633
+ #### Undef to String
642
634
 
643
635
  | Format | Undef formats
644
636
  | ------ | -------------
@@ -651,7 +643,7 @@ Defaults to `s` at top level and `p` inside array or hash.
651
643
  | V | String 'N/A'.
652
644
  | u | String 'undef', or 'undefined' if alternative `#` flag is used.
653
645
 
654
- ### Default value to String
646
+ #### Default value to String
655
647
 
656
648
  | Format | Default formats
657
649
  | ------ | ---------------
@@ -659,7 +651,7 @@ Defaults to `s` at top level and `p` inside array or hash.
659
651
  | s | Same as d.
660
652
  | p | Same as d.
661
653
 
662
- ### Binary value to String
654
+ #### Binary value to String
663
655
 
664
656
  | Format | Default formats
665
657
  | ------ | ---------------
@@ -676,7 +668,7 @@ Defaults to `s` at top level and `p` inside array or hash.
676
668
  as hex escaped characters on the form `\\xHH` where `H` is a hex digit.
677
669
  * The width and precision values are applied to the text part only in `%p` format.
678
670
 
679
- ### Array & Tuple to String
671
+ #### Array & Tuple to String
680
672
 
681
673
  | Format | Array/Tuple Formats
682
674
  | ------ | -------------
@@ -691,7 +683,7 @@ The alternate form flag `#` will cause indentation of nested array or hash conta
691
683
  it is taken as the maximum allowed length of a sequence of elements (not including delimiters). If this max length
692
684
  is exceeded, each element will be indented.
693
685
 
694
- ### Hash & Struct to String
686
+ #### Hash & Struct to String
695
687
 
696
688
  | Format | Hash/Struct Formats
697
689
  | ------ | -------------
@@ -705,14 +697,14 @@ more information about options.
705
697
 
706
698
  The alternate form flag `#` will format each hash key/value entry indented on a separate line.
707
699
 
708
- ### Type to String
700
+ #### Type to String
709
701
 
710
702
  | Format | Array/Tuple Formats
711
703
  | ------ | -------------
712
704
  | s | The same as `p`, quoted if alternative flag `#` is used.
713
705
  | p | Outputs the type in string form as specified by the Puppet Language.
714
706
 
715
- ### Flags
707
+ #### Flags
716
708
 
717
709
  | Flag | Effect
718
710
  | ------ | ------
@@ -723,8 +715,7 @@ The alternate form flag `#` will format each hash key/value entry indented on a
723
715
  | 0 | Pad with 0 instead of space for widths larger than value.
724
716
  | <[({\| | Defines an enclosing pair <> [] () {} or \| \| when used with a container type.
725
717
 
726
- Conversion to Boolean
727
- ---
718
+ ### Conversion to Boolean
728
719
 
729
720
  Accepts a single value as argument:
730
721
 
@@ -735,8 +726,7 @@ Accepts a single value as argument:
735
726
  * `false` if 'false', 'no', 'n' (case independent compare)
736
727
  * Boolean is already boolean and is simply returned
737
728
 
738
- Conversion to Array and Tuple
739
- ---
729
+ ### Conversion to Array and Tuple
740
730
 
741
731
  When given a single value as argument:
742
732
 
@@ -761,8 +751,7 @@ $arr = Array($value, true)
761
751
  Conversion to a `Tuple` works exactly as conversion to an `Array`, only that the constructed array is
762
752
  asserted against the given tuple type.
763
753
 
764
- Conversion to Hash and Struct
765
- ---
754
+ ### Conversion to Hash and Struct
766
755
 
767
756
  Accepts a single value as argument:
768
757
 
@@ -775,8 +764,8 @@ Accepts a single value as argument:
775
764
  Conversion to a `Struct` works exactly as conversion to a `Hash`, only that the constructed hash is
776
765
  asserted against the given struct type.
777
766
 
778
- Conversion to a Regexp
779
- ---
767
+ ### Conversion to a Regexp
768
+
780
769
  A `String` can be converted into a `Regexp`
781
770
 
782
771
  **Example**: Converting a String into a Regexp
@@ -788,8 +777,7 @@ if('foo.com' =~ $r) {
788
777
  }
789
778
  ```
790
779
 
791
- Creating a SemVer
792
- ---
780
+ ### Creating a SemVer
793
781
 
794
782
  A SemVer object represents a single [Semantic Version](http://semver.org/).
795
783
  It can be created from a String, individual values for its parts, or a hash specifying the value per part.
@@ -838,8 +826,7 @@ notice(SemVer('2.3.4') =~ $t) # false
838
826
  notice(SemVer('3.4.5') =~ $t) # true
839
827
  ```
840
828
 
841
- Creating a SemVerRange
842
- ---
829
+ ### Creating a SemVerRange
843
830
 
844
831
  A `SemVerRange` object represents a range of `SemVer`. It can be created from
845
832
  a `String`, or from two `SemVer` instances, where either end can be given as
@@ -873,10 +860,9 @@ function SemVerRange.new(
873
860
  )
874
861
  ```
875
862
 
876
- For examples of `SemVerRange` use see "Creating a SemVer"
863
+ For examples of `SemVerRange` use, see "Creating a SemVer".
877
864
 
878
- Creating a Binary
879
- ---
865
+ ### Creating a Binary
880
866
 
881
867
  A `Binary` object represents a sequence of bytes and it can be created from a String in Base64 format,
882
868
  an Array containing byte values. A Binary can also be created from a Hash containing the value to convert to
@@ -896,7 +882,6 @@ function Binary.new(
896
882
  Optional[Base64Format] $format
897
883
  )
898
884
 
899
-
900
885
  function Binary.new(
901
886
  Array[ByteInteger] $byte_array
902
887
  }