Add Puppet helpers functions
== Fetch ==
This function can be used to extract a value from a deeply nested structure by it's path.
$data = {
'a' => {
'b' => [
'b1',
'b2',
'b3',
]
}
}
$value = fetch($data, 'a/b/2', 'not_found', '/')
=> $value = 'b3'
== Store ==
This function can set a value inside a structure
$data = {
'a' => {
'b' => [
'b1',
'b2',
'b3',
]
}
}
store($data, 'a/b/2', 'new_value', '/')
=> $data = {
'a' => {
'b' => [
'b1',
'b2',
'new_value',
]
}
}
== Setvar ==
Puppet is known to have immutable "variables" inside it's manifests. This function allows a developer to update the value as he expects to be able in other programming languages.
$message = 'msg1'
notify { 'before' :
message => $message,
}
setvar('message', 'msg2')
notify { 'after' :
message => $message,
}
=> Notice: /Stage[
=> Notice: /Stage[
Blueprint information
- Status:
- Not started
- Approver:
- None
- Priority:
- Undefined
- Drafter:
- Dmitry Ilyin
- Direction:
- Needs approval
- Assignee:
- None
- Definition:
- New
- Series goal:
- None
- Implementation:
- Unknown
- Milestone target:
- None
- Started by
- Completed by
Related branches
Related bugs
Sprints
Whiteboard
Gerrit topic: https:/
Addressed by: https:/
Add fetch, store and setvar functions