Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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: {}

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'
5 changes: 5 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 $global_config_entries,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make the datatype a bit stricter? Do we only allow strings?

Suggested change
Hash $global_config_entries,
Hash[String[1],String[1]] $global_config_entries = {},

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hash[String[1], Hash, 0] instead of Hash[String[1],String[1]] no ?

) 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,6 @@
Class[$repo_class]
-> Class['nodejs::install']
}

create_resources('nodejs::npm::global_config_entry', $global_config_entries)
}
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