Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add global_config_entries parameter #457

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
nodejs::global_config_entries: {}
fe80 marked this conversation as resolved.
Show resolved Hide resolved

lookup_options:
nodejs::global_config_entries:
merge:
strategy: deep
12 changes: 12 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
version: 5
defaults:
datadir: 'data'
data_hash: 'yaml_data'
hierarchy:
- name: 'Major Version'
path: '%{facts.os.name}-%{facts.os.release.major}.yaml'
- name: 'Distribution Name'
path: '%{facts.os.name}.yaml'
- name: 'common'
path: 'common.yaml'
9 changes: 9 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# == Class: nodejs: See README.md for documentation.
#
# @param global_config_entries Create resources with nodejs::npm::global_config_entry
class nodejs (
$cmd_exe_path = $nodejs::params::cmd_exe_path,
Boolean $manage_nodejs_package = true,
Expand Down Expand Up @@ -26,6 +28,7 @@
$repo_url_suffix = $nodejs::params::repo_url_suffix,
Array $use_flags = $nodejs::params::use_flags,
Optional[String] $package_provider = $nodejs::params::package_provider,
Hash[String[1], Hash, 0] $global_config_entries = {},
) inherits nodejs::params {
if $manage_package_repo and !$repo_class {
fail("${module_name}: The manage_package_repo parameter was set to true but no repo_class was provided.")
Expand All @@ -39,4 +42,10 @@
Class[$repo_class]
-> Class['nodejs::install']
}

$global_config_entries.each |$setting, $params| {
nodejs::npm::global_config_entry { $setting:
* => $params,
}
}
}
16 changes: 16 additions & 0 deletions spec/classes/nodejs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,22 @@
is_expected.not_to contain_package('npm')
end
end

context 'with global_config_entries' do
let :params do
{
global_config_entries: {
'proxy' => { 'value' => 'https://proxy.com' }
}
}
end

it do
is_expected.to contain_nodejs__npm__global_config_entry('proxy').with(
value: 'https://proxy.com'
)
end
end
end
end

Expand Down