Shallow merge
Bolt already shallow merges plugin_hooks
in a few locations. [1, 2, 3, 4]
Global config:
plugin_hooks:
foo:
key1: value1
bar:
key1: value1
Local config:
plugin_hooks:
foo:
key2: value2
Resolved config:
plugin_hooks:
foo:
key2: value2
bar:
key1: value1
Overwrite
The puppetfile
config option is a hash that points to proxy servers and a Forge host. I'm not sure there would be an instance where only one of these would need to be changed on a per-user or per-project basis.
puppetfile:
proxy: <proxy>
forge:
proxy: <proxy>
baseurl: <baseurl>
Shallow merge
It makes sense to preserve log configuration set at a global or user-level while allowing for further configuration at the user or project-level. Since the hash for this option only has the level
and append
keys, I don't think there's any reason to do a deep merge.
Global config:
log:
console:
level: info
Local config:
log:
~/.puppetlabs/bolt/logfile.log:
level: debug
append: false
Project config:
log:
~/.puppetlabs/bolt/logfile.log:
level: warn
Resolved config:
log:
console:
level: notice
~/.puppetlabs/bolt/logfile.log:
level: warn
Shallow merge individual plugins
Deep merging would be inappropriate, as plugin config can have hash values that shouldn't be merged. For example, the Vault plugin has an auth
field that has different fields depending on which auth method is used.
Global config:
vault:
auth:
method: userpass
user: <user>
pass: <password>
Local config:
vault:
auth:
method: token
token: <token>
Resolved config:
vault:
auth:
method: token
user: <user>
pass: <password>
token: <token>
In this instance, a deep merge is undesirable. However, doing a shallow merge for each plugin's config would allow for setting certain values (such as a Vault server URL) at the global level, while allowing a user to add onto their config (such as setting their Vault credentials) at the local level.
Global config:
plugins:
vault:
server_url: <server_url>
cacert: <path_to_cert>
Local config:
plugins:
vault:
auth:
method: userpass
user: <user>
pass: <password>
Resolved config:
plugins:
vault:
server_url: <server_url>
cacert: <path_to_cert>
auth:
method: userpass
user: <user>
pass: <password>
Deep merge
Bolt already performs a deep merge on transport config. [1, 2]