summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md36
-rw-r--r--lib/puppet/type/file_line.rb10
-rw-r--r--spec/aliases/integer_spec.rb4
-rw-r--r--spec/functions/ensure_resources_spec.rb (renamed from spec/unit/ensure_resources_spec.rb)0
-rwxr-xr-xspec/functions/is_integer_spec.rb3
-rwxr-xr-xspec/unit/puppet/provider/file_line/ruby_spec.rb3
6 files changed, 35 insertions, 21 deletions
diff --git a/README.md b/README.md
index c5a7471..61318ea 100644
--- a/README.md
+++ b/README.md
@@ -178,7 +178,7 @@ Default value: 'present'.
Sets the line to be added to the file located by the `path` parameter.
Values: String.
-
+
##### `match`
Specifies a regular expression to compare against existing lines in the file; if a match is found, it is replaced rather than adding a new line. A regex comparison is performed against the line value, and if it does not match, an exception is raised.
@@ -207,7 +207,7 @@ Default value: `false`.
##### `name`
-Specifies the name to use as the identity of the resource. If you want the resource namevar to differ from the supplied `title` of the resource, specify it with `name`.
+Specifies the name to use as the identity of the resource. If you want the resource namevar to differ from the supplied `title` of the resource, specify it with `name`.
Values: String.
@@ -217,7 +217,7 @@ Default value: The value of the title.
**Required.**
-Specifies the file in which Puppet ensures the line specified by `line`.
+Specifies the file in which Puppet ensures the line specified by `line`.
Value: String specifying an absolute path to the file.
@@ -311,7 +311,7 @@ C:/whatever
Matches paths on Windows operating systems.
-Acceptable input example:
+Acceptable input example:
```shell
C:\\WINDOWS\\System32
@@ -468,9 +468,9 @@ Converts a Boolean to a number. Converts values:
* `false`, 'f', '0', 'n', and 'no' to 0.
* `true`, 't', '1', 'y', and 'yes' to 1.
-
+
Argument: a single Boolean or string as an input.
-
+
*Type*: rvalue.
#### `bool2str`
@@ -538,8 +538,8 @@ Keeps value within the range [Min, X, Max] by sort based on integer value (param
* `clamp('24', [575, 187])` returns 187.
* `clamp(16, 88, 661)` returns 88.
* `clamp([4, 3, '99'])` returns 4.
-
-Arguments: strings, arrays, or numerics.
+
+Arguments: strings, arrays, or numerics.
*Type*: rvalue.
@@ -690,7 +690,7 @@ Other settings in Puppet affect the stdlib `deprecation` function:
Specifies whether or not to log deprecation warnings. This is especially useful for automated tests to avoid flooding your logs before you are ready to migrate.
This variable is Boolean, with the following effects:
-
+
* `true`: Functions log a warning.
* `false`: No warnings are logged.
* No value set: Puppet 4 emits warnings, but Puppet 3 does not.
@@ -1253,7 +1253,7 @@ Joins an array into a string using a separator. For example, `join(['a','b','c']
#### `join_keys_to_values`
-Joins each key of a hash to that key's corresponding value with a separator, returning the result as strings.
+Joins each key of a hash to that key's corresponding value with a separator, returning the result as strings.
If a value is an array, the key is prefixed to each element. The return value is a flattened array.
@@ -1407,7 +1407,7 @@ Arguments:
* The YAML string to convert, as a first argument.
* Optionally, the result to return if conversion fails, as a second error.
-*Type*: rvalue.
+*Type*: rvalue.
#### `pick`
@@ -1696,7 +1696,7 @@ For example, `time()` returns something like '1311972653'.
Converts the argument into bytes.
-For example, "4 kB" becomes "4096".
+For example, "4 kB" becomes "4096".
Arguments: A single string.
@@ -1708,7 +1708,7 @@ Arguments: A single string.
Retrieves a value within multiple layers of hashes and arrays.
-Arguments:
+Arguments:
* A string containing a path, as the first argument. Provide this argument as a string of hash keys or array indexes starting with zero and separated by the path separator character (default "/"). This function goes through the structure by each path component and tries to return the value at the end of the path.
@@ -1819,7 +1819,7 @@ For example, `upcase('abcd')` returns 'ABCD'.
#### `uriescape`
-URLEncodes a string or array of strings.
+URLEncodes a string or array of strings.
Arguments: Either a single string or an array of strings.
@@ -1915,7 +1915,7 @@ validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
-Validates that all passed values are either `true` or `false`.
+Validates that all passed values are either `true` or `false`.
Terminates catalog compilation if any value fails this check.
The following values pass:
@@ -1992,7 +1992,7 @@ Arguments:
* An integer or an array of integers, as the first argument.
* Optionally, a maximum, as the second argument. (All elements of) the first argument must be equal to or less than this maximum.
-* Optionally, a minimum, as the third argument. (All elements of) the first argument must be equal to or greater than than this maximum.
+* Optionally, a minimum, as the third argument. (All elements of) the first argument must be equal to or greater than than this maximum.
This function fails if the first argument is not an integer or array of integers, or if the second or third arguments are not convertable to an integer. However, if (and only if) a minimum is given, the second argument may be an empty string or `undef`, which serves as a placeholder to ensure the minimum check.
@@ -2046,7 +2046,7 @@ validate_integer(1, 3, true)
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
-Validates that the argument is an IP address, regardless of whether it is an IPv4 or an IPv6 address. It also validates IP address with netmask.
+Validates that the argument is an IP address, regardless of whether it is an IPv4 or an IPv6 address. It also validates IP address with netmask.
Arguments: A string specifying an IP address.
@@ -2117,7 +2117,7 @@ The deprecation messages you get can vary, depending on the modules and data tha
The `validate_legacy` function helps you move from Puppet 3 style validation to Puppet 4 validation without breaking functionality your module's users depend on.
-Moving to Puppet 4 type validation allows much better defined type checking using [data types](https://docs.puppet.com/puppet/latest/reference/lang_data.html). Many of Puppet 3's `validate_*` functions have surprising holes in their validation. For example, [validate_numeric](#validate_numeric) allows not only numbers, but also arrays of numbers or strings that look like numbers, without giving you any control over the specifics.
+Moving to Puppet 4 type validation allows much better defined type checking using [data types](https://docs.puppet.com/puppet/latest/reference/lang_data.html). Many of Puppet 3's `validate_*` functions have surprising holes in their validation. For example, [validate_numeric](#validate_numeric) allows not only numbers, but also arrays of numbers or strings that look like numbers, without giving you any control over the specifics.
For each parameter of your classes and defined types, choose a new Puppet 4 data type to use. In most cases, the new data type allows a different set of values than the original `validate_*` function. The situation then looks like this:
diff --git a/lib/puppet/type/file_line.rb b/lib/puppet/type/file_line.rb
index e82b246..3d691bf 100644
--- a/lib/puppet/type/file_line.rb
+++ b/lib/puppet/type/file_line.rb
@@ -104,8 +104,16 @@ Puppet::Type.newtype(:file_line) do
' This is also takes a regex.'
end
- newparam(:line) do
+ # The line property never changes; the type only ever performs a create() or
+ # destroy(). line is a property in order to allow it to correctly handle
+ # Sensitive type values. Because it is a property which will never change,
+ # it should never be considered out of sync.
+ newproperty(:line) do
desc 'The line to be appended to the file or used to replace matches found by the match attribute.'
+
+ def retrieve
+ @resource[:line]
+ end
end
newparam(:path) do
diff --git a/spec/aliases/integer_spec.rb b/spec/aliases/integer_spec.rb
index bd00c2a..8cb4658 100644
--- a/spec/aliases/integer_spec.rb
+++ b/spec/aliases/integer_spec.rb
@@ -8,6 +8,8 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
'3',
-3,
'-3',
+ "123\nfoo",
+ "foo\n123",
].each do |value|
describe value.inspect do
let(:params) {{ value: value }}
@@ -17,7 +19,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
end
describe 'rejects other values' do
- [ true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x', 3.7, '3.7',-3.7, '-342.2315e-12' ].each do |value|
+ [ "foo\nbar", true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x', 3.7, '3.7',-3.7, '-342.2315e-12' ].each do |value|
describe value.inspect do
let(:params) {{ value: value }}
it { is_expected.to compile.and_raise_error(/parameter 'value' expects a value of type Integer, Pattern(\[.*\]+)?, or Array/) }
diff --git a/spec/unit/ensure_resources_spec.rb b/spec/functions/ensure_resources_spec.rb
index aea723e..aea723e 100644
--- a/spec/unit/ensure_resources_spec.rb
+++ b/spec/functions/ensure_resources_spec.rb
diff --git a/spec/functions/is_integer_spec.rb b/spec/functions/is_integer_spec.rb
index b296830..8118ef4 100755
--- a/spec/functions/is_integer_spec.rb
+++ b/spec/functions/is_integer_spec.rb
@@ -11,6 +11,8 @@ describe 'is_integer' do
it { is_expected.to run.with_params('3').and_return(true) }
it { is_expected.to run.with_params(-3).and_return(true) }
it { is_expected.to run.with_params('-3').and_return(true) }
+ it { is_expected.to run.with_params("123\nfoo").and_return(true) }
+ it { is_expected.to run.with_params("foo\n123").and_return(true) }
it { is_expected.to run.with_params(3.7).and_return(false) }
it { is_expected.to run.with_params('3.7').and_return(false) }
@@ -24,6 +26,7 @@ describe 'is_integer' do
it { is_expected.to run.with_params(true).and_return(false) }
it { is_expected.to run.with_params(false).and_return(false) }
it { is_expected.to run.with_params('0001234').and_return(false) }
+ it { is_expected.to run.with_params("foo\nbar").and_return(false) }
context 'Checking for deprecation warning' do
after(:all) do
diff --git a/spec/unit/puppet/provider/file_line/ruby_spec.rb b/spec/unit/puppet/provider/file_line/ruby_spec.rb
index 0e12aa2..dcf8509 100755
--- a/spec/unit/puppet/provider/file_line/ruby_spec.rb
+++ b/spec/unit/puppet/provider/file_line/ruby_spec.rb
@@ -2,7 +2,8 @@
require 'spec_helper'
require 'tempfile'
provider_class = Puppet::Type.type(:file_line).provider(:ruby)
-describe provider_class do
+# These tests fail on windows when run as part of the rake task. Individually they pass
+describe provider_class, :unless => Puppet::Util::Platform.windows? do
context "when adding" do
let :tmpfile do
tmp = Tempfile.new('tmp')