Skip to content

Commit

Permalink
Manage option to use a custom lookup function (#80)
Browse files Browse the repository at this point in the history
* Manage option to use a custom lookup function

Some people have written their own custom lookup function.
HDM needs to know if the function returns yaml or eyaml.

* switch from if ! to unless

* Parameter from optional to empty hash

* Update reference to new data type
  • Loading branch information
tuxmea authored Mar 14, 2024
1 parent 49aa8ab commit 5a0a720
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ The following parameters are available in the `hdm` class:
* [`ldap_settings`](#-hdm--ldap_settings)
* [`ldap_bind_dn_password`](#-hdm--ldap_bind_dn_password)
* [`hdm_hiera_config_file`](#-hdm--hdm_hiera_config_file)
* [`custom_lookup_function`](#-hdm--custom_lookup_function)

##### <a name="-hdm--method"></a>`method`

Expand Down Expand Up @@ -321,6 +322,21 @@ want HDM to not use hiera.yaml.

Default value: `'hiera.yaml'`

##### <a name="-hdm--custom_lookup_function"></a>`custom_lookup_function`

Data type: `Hash[String[1],Enum['yaml', 'eyaml']]`

If you use your own developed hiera
lookup function, HDM needs to know if the function returns yaml
or eyaml data.
Example:
```
{
'functon_name' => '<yaml|eyaml>'
}
Default value: `{}`
## Data types
### <a name="Hdm--Gitdata"></a>`Hdm::Gitdata`
Expand Down
10 changes: 10 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@
# @param hdm_hiera_config_file Set to another file if you
# want HDM to not use hiera.yaml.
#
# @param custom_lookup_function If you use your own developed hiera
# lookup function, HDM needs to know if the function returns yaml
# or eyaml data.
# Example:
# ```
# {
# 'functon_name' => '<yaml|eyaml>'
# }
#
# @example
# include hdm
class hdm (
Expand Down Expand Up @@ -151,6 +160,7 @@
Optional[Hdm::Gitdata] $git_data = undef,
Optional[Hdm::Ldap_settings] $ldap_settings = undef,
Optional[Sensitive[String[1]]] $ldap_bind_dn_password = undef,
Hash[String[1],Enum['yaml', 'eyaml']] $custom_lookup_function = {},
) {
if $ldap_settings {
if $ldap_bind_dn_password {
Expand Down
6 changes: 6 additions & 0 deletions templates/hdm.yml.epp
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@
<%= $key %>: <%= $value %>
<%- } -%>
<%- } -%>
<%- unless $hdm::custom_lookup_function.empty { -%>
custom_lookup_function_mapping:
<%- $hdm::custom_lookup_function.each |String $key, String $value| { -%>
<%= $key %>: <%= $value %>
<%- } -%>
<%- } -%>

0 comments on commit 5a0a720

Please sign in to comment.