Skip to content

Commit c395751

Browse files
committed
add global_config_entries parameter
1 parent ae7df2d commit c395751

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

data/common.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
nodejs::global_config_entries: {}
3+
4+
lookup_options:
5+
nodejs::global_config_entries:
6+
merge:
7+
strategy: deep

hiera.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
version: 5
3+
defaults:
4+
datadir: 'data'
5+
data_hash: 'yaml_data'
6+
hierarchy:
7+
- name: 'Major Version'
8+
path: '%{facts.os.name}-%{facts.os.release.major}.yaml'
9+
- name: 'Distribution Name'
10+
path: '%{facts.os.name}.yaml'
11+
- name: 'common'
12+
path: 'common.yaml'

manifests/init.pp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# == Class: nodejs: See README.md for documentation.
2+
#
3+
# @param global_config_entries Create resources with nodejs::npm::global_config_entry
24
class nodejs (
35
$cmd_exe_path = $nodejs::params::cmd_exe_path,
46
Boolean $manage_nodejs_package = true,
@@ -26,6 +28,7 @@
2628
$repo_url_suffix = $nodejs::params::repo_url_suffix,
2729
Array $use_flags = $nodejs::params::use_flags,
2830
Optional[String] $package_provider = $nodejs::params::package_provider,
31+
Hash $global_config_entries,
2932
) inherits nodejs::params {
3033
if $manage_package_repo and !$repo_class {
3134
fail("${module_name}: The manage_package_repo parameter was set to true but no repo_class was provided.")
@@ -39,4 +42,6 @@
3942
Class[$repo_class]
4043
-> Class['nodejs::install']
4144
}
45+
46+
create_resources('nodejs::npm::global_config_entry', $global_config_entries)
4247
}

spec/classes/nodejs_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,22 @@
309309
is_expected.not_to contain_package('npm')
310310
end
311311
end
312+
313+
context 'with global_config_entries' do
314+
let :params do
315+
{
316+
global_config_entries: {
317+
'proxy' => { 'value' => 'https://proxy.com' }
318+
}
319+
}
320+
end
321+
322+
it do
323+
is_expected.to contain_nodejs__npm__global_config_entry('proxy').with(
324+
value: 'https://proxy.com',
325+
)
326+
end
327+
end
312328
end
313329
end
314330

0 commit comments

Comments
 (0)