Skip to content

Commit 88e0e24

Browse files
committed
Merge pull request #393 from cyberious/DeleteDocUpdates
Update docs to reflect new behavior of delete function taking array in second argument
2 parents 69c42b7 + f6e20d2 commit 88e0e24

File tree

2 files changed

+40
-37
lines changed

2 files changed

+40
-37
lines changed

README.markdown

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
##Overview
1616

17-
Adds a standard library of resources for Puppet modules.
17+
Adds a standard library of resources for Puppet modules.
1818

1919
##Module Description
2020

@@ -27,22 +27,22 @@ modules. Puppet modules make heavy use of this standard library. The stdlib modu
2727
* Defined resource types
2828
* Types
2929
* Providers
30-
30+
3131
> *Note:* As of version 3.7, Puppet Enterprise no longer includes the stdlib module. If you're running Puppet Enterprise, you should install the most recent release of stdlib for compatibility with Puppet modules.
3232
3333
##Setup
3434

35-
Installing the stdlib module adds the functions, facts, and resources of this standard library to Puppet.
35+
Installing the stdlib module adds the functions, facts, and resources of this standard library to Puppet.
3636

3737
##Usage
3838

39-
After you've installed stdlib, all of its functions, facts, and resources are available for module use or development.
39+
After you've installed stdlib, all of its functions, facts, and resources are available for module use or development.
4040

41-
If you want to use a standardized set of run stages for Puppet, `include stdlib` in your manifest.
41+
If you want to use a standardized set of run stages for Puppet, `include stdlib` in your manifest.
4242

4343
## Reference
4444

45-
### Classes
45+
### Classes
4646

4747
#### Public Classes
4848

@@ -75,11 +75,11 @@ If you want to use a standardized set of run stages for Puppet, `include stdlib`
7575
class { java: stage => 'runtime' }
7676
}
7777
```
78-
78+
7979
### Resources
8080

81-
* `file_line`: This resource ensures that a given line, including whitespace at the beginning and end, is contained within a file. If the line is not contained in the given file, Puppet will add the line. Multiple resources can be declared to manage multiple lines in the same file. You can also use match to replace existing lines.
82-
81+
* `file_line`: This resource ensures that a given line, including whitespace at the beginning and end, is contained within a file. If the line is not contained in the given file, Puppet will add the line. Multiple resources can be declared to manage multiple lines in the same file. You can also use match to replace existing lines.
82+
8383
```
8484
file_line { 'sudo_rule':
8585
path => '/etc/sudoers',
@@ -90,15 +90,15 @@ If you want to use a standardized set of run stages for Puppet, `include stdlib`
9090
line => '%sudonopw ALL=(ALL) NOPASSWD: ALL',
9191
}
9292
```
93-
93+
9494
* `after`: Specify the line after which Puppet will add any new lines. (Existing lines are added in place.) Optional.
9595
* `ensure`: Ensures whether the resource is present. Valid values are 'present', 'absent'.
9696
* `line`: The line to be added to the file located by the `path` parameter.
9797
* `match`: A regular expression to run against existing lines in the file; if a match is found, we replace that line rather than adding a new line. Optional.
9898
* `multiple`: Determine if match can change multiple lines. Valid values are 'true', 'false'. Optional.
9999
* `name`: An arbitrary name used as the identity of the resource.
100100
* `path`: The file in which Puppet will ensure the line specified by the line parameter.
101-
101+
102102
### Functions
103103

104104
* `abs`: Returns the absolute value of a number; for example, '-34.56' becomes '34.56'. Takes a single integer and float value as an argument. *Type*: rvalue
@@ -144,11 +144,11 @@ strings; for example, 'hello\n' becomes 'hello'. Requires a single string or arr
144144
user { 'dan': ensure => present, }
145145
}
146146
```
147-
147+
148148
*Type*: rvalue
149149

150150
* `delete`: Deletes all instances of a given element from an array, substring from a
151-
string, or key from a hash. For example, `delete(['a','b','c','b'], 'b')` returns ['a','c']; `delete('abracadabra', 'bra')` returns 'acada'. *Type*: rvalue
151+
string, or key from a hash. For example, `delete(['a','b','c','b'], 'b')` returns ['a','c']; `delete('abracadabra', 'bra')` returns 'acada'. `delete({'a' => 1,'b' => 2,'c' => 3},['b','c'])` returns {'a'=> 1} *Type*: rvalue
152152

153153
* `delete_at`: Deletes a determined indexed value from an array. For example, `delete_at(['a','b','c'], 1)` returns ['a','c']. *Type*: rvalue
154154

@@ -252,7 +252,7 @@ returns the value of the resource's parameter. For example, the following code r
252252
has_interface_with("macaddress", "x:x:x:x:x:x")
253253
has_interface_with("ipaddress", "127.0.0.1") => true
254254
```
255-
255+
256256
If no kind is given, then the presence of the interface is checked:
257257

258258
```
@@ -278,7 +278,7 @@ returns the value of the resource's parameter. For example, the following code r
278278
notice('this will be printed')
279279
}
280280
```
281-
281+
282282
*Type*: rvalue
283283

284284
* `hash`: This function converts an array into a hash. For example, `hash(['a',1,'b',2,'c',3])` returns {'a'=>1,'b'=>2,'c'=>3}. *Type*: rvalue
@@ -330,15 +330,15 @@ returns the value of the resource's parameter. For example, the following code r
330330
* `merge`: Merges two or more hashes together and returns the resulting hash.
331331

332332
*Example*:
333-
333+
334334
```
335335
$hash1 = {'one' => 1, 'two' => 2}
336336
$hash2 = {'two' => 'dos', 'three' => 'tres'}
337337
$merged_hash = merge($hash1, $hash2)
338338
# The resulting hash is equivalent to:
339339
# $merged_hash = {'one' => 1, 'two' => 'dos', 'three' => 'tres'}
340340
```
341-
341+
342342
When there is a duplicate key, the key in the rightmost hash "wins." *Type*: rvalue
343343

344344
* `min`: Returns the lowest value of all arguments. Requires at least one argument. *Type*: rvalue
@@ -354,7 +354,7 @@ returns the value of the resource's parameter. For example, the following code r
354354
```
355355
$real_jenkins_version = pick($::jenkins_version, '1.449')
356356
```
357-
357+
358358
*Type*: rvalue
359359

360360
* `prefix`: This function applies a prefix to all elements in an array. For example, `prefix(['a','b','c'], 'p')` returns ['pa','pb','pc']. *Type*: rvalue
@@ -366,9 +366,9 @@ Calling the class or definition from outside the current module will fail. For e
366366
```
367367
Class foo::bar is private
368368
```
369-
369+
370370
You can specify the error message you want to use:
371-
371+
372372
```
373373
private("You're not supposed to do that!")
374374
```
@@ -377,8 +377,8 @@ Calling the class or definition from outside the current module will fail. For e
377377

378378
* `range`: When given range in the form of '(start, stop)', `range` extrapolates a range as an array. For example, `range("0", "9")` returns [0,1,2,3,4,5,6,7,8,9]. Zero-padded strings are converted to integers automatically, so `range("00", "09")` returns [0,1,2,3,4,5,6,7,8,9].
379379

380-
Non-integer strings are accepted; `range("a", "c")` returns ["a","b","c"], and `range("host01", "host10")` returns ["host01", "host02", ..., "host09", "host10"].
381-
380+
Non-integer strings are accepted; `range("a", "c")` returns ["a","b","c"], and `range("host01", "host10")` returns ["host01", "host02", ..., "host09", "host10"].
381+
382382
*Type*: rvalue
383383

384384
* `reject`: This function searches through an array and rejects all elements that match the provided regular expression. For example, `reject(['aaa','bbb','ccc','aaaddd'], 'aaa')` returns ['bbb','ccc']. *Type*: rvalue
@@ -403,7 +403,7 @@ manifests as a valid password attribute. *Type*: rvalue
403403
* `strftime`: This function returns formatted time. For example, `strftime("%s")` returns the time since epoch, and `strftime("%Y=%m-%d")` returns the date. *Type*: rvalue
404404

405405
*Format:*
406-
406+
407407
* `%a`: The abbreviated weekday name ('Sun')
408408
* `%A`: The full weekday name ('Sunday')
409409
* `%b`: The abbreviated month name ('Jan')
@@ -501,9 +501,9 @@ You can also use this with arrays. For example, `unique(["a","a","b","b","c","c"
501501
validate_absolute_path($undefined)
502502
```
503503
504-
*Type*: statement
504+
*Type*: statement
505505
506-
* `validate_array`: Validate that all passed values are array data structures. Abort catalog compilation if any value fails this check.
506+
* `validate_array`: Validate that all passed values are array data structures. Abort catalog compilation if any value fails this check.
507507
508508
The following values will pass:
509509
@@ -533,13 +533,13 @@ The first argument of this function should be the string to test, and the second
533533
```
534534
validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo'])
535535
```
536-
536+
537537
To ensure that no users use the '/bin/barsh' shell:
538538
539539
```
540540
validate_augeas($passwdcontent, 'Passwd.lns', ['$file/*[shell="/bin/barsh"]']
541541
```
542-
542+
543543
You can pass a fourth argument as the error message raised and shown to the user:
544544
545545
```
@@ -551,13 +551,13 @@ The first argument of this function should be the string to test, and the second
551551
* `validate_bool`: Validate that all passed values are either true or false. Abort catalog compilation if any value fails this check.
552552
553553
The following values will pass:
554-
554+
555555
```
556556
$iamtrue = true
557557
validate_bool(true)
558558
validate_bool(true, true, false, $iamtrue)
559559
```
560-
560+
561561
The following values will fail, causing compilation to abort:
562562
563563
```
@@ -576,7 +576,7 @@ The first argument of this function should be the string to test, and the second
576576
```
577577
validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content')
578578
```
579-
579+
580580
*Type*: statement
581581
582582
* `validate_hash`: Validates that all passed values are hash data structures. Abort catalog compilation if any value fails this check.
@@ -596,7 +596,7 @@ The first argument of this function should be the string to test, and the second
596596
$undefined = undef
597597
validate_hash($undefined)
598598
```
599-
599+
600600
*Type*: statement
601601
602602
* `validate_re`: Performs simple validation of a string against one or more regular expressions. The first argument of this function should be the string to
@@ -619,8 +619,8 @@ of the regular expressions match the string passed in, compilation aborts with a
619619
validate_re('one', [ '^two', '^three' ])
620620
```
621621
622-
To set the error message:
623-
622+
To set the error message:
623+
624624
```
625625
validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7')
626626
```
@@ -630,19 +630,19 @@ of the regular expressions match the string passed in, compilation aborts with a
630630
* `validate_slength`: Validates that the first argument is a string (or an array of strings), and is less than or equal to the length of the second argument. It fails if the first argument is not a string or array of strings, or if arg 2 is not convertable to a number.
631631
632632
The following values pass:
633-
633+
634634
```
635635
validate_slength("discombobulate",17)
636636
validate_slength(["discombobulate","moo"],17)
637637
```
638-
638+
639639
The following values fail:
640640
641641
```
642642
validate_slength("discombobulate",1)
643643
validate_slength(["discombobulate","thermometer"],5)
644644
```
645-
645+
646646
*Type*: statement
647647
648648
* `validate_string`: Validates that all passed values are string data structures. Aborts catalog compilation if any value fails this check.
@@ -700,7 +700,7 @@ As of Puppet Enterprise version 3.7, the stdlib module is no longer included in
700700
701701
###Version Compatibility
702702
703-
Versions | Puppet 2.6 | Puppet 2.7 | Puppet 3.x | Puppet 4.x |
703+
Versions | Puppet 2.6 | Puppet 2.7 | Puppet 3.x | Puppet 4.x |
704704
:---------------|:-----:|:---:|:---:|:----:
705705
**stdlib 2.x** | **yes** | **yes** | no | no
706706
**stdlib 3.x** | no | **yes** | **yes** | no

lib/puppet/parser/functions/delete.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ module Puppet::Parser::Functions
1717
delete({'a'=>1,'b'=>2,'c'=>3}, 'b')
1818
Would return: {'a'=>1,'c'=>3}
1919
20+
delete({'a'=>1,'b'=>2,'c'=>3}, ['b','c'])
21+
Would return: {'a'=>1}
22+
2023
delete('abracadabra', 'bra')
2124
Would return: 'acada'
2225
EOS

0 commit comments

Comments
 (0)