Skip to content

Commit 22c5f8d

Browse files
authored
Merge pull request #587 from bastelfreak/cwd
python::requirements: make cwd optional (again)
2 parents 0ca4bd8 + af69f6b commit 22c5f8d

File tree

3 files changed

+32
-28
lines changed

3 files changed

+32
-28
lines changed

REFERENCE.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828

2929
### Data types
3030

31-
* [`Python::Loglevel`](#pythonloglevel): A version type to match all valid versions for python
32-
* [`Python::Package::Ensure`](#pythonpackageensure): A version type to match all valid versions for python
33-
* [`Python::Provider`](#pythonprovider): A version type to match all valid versions for python
34-
* [`Python::Umask`](#pythonumask): A version type to match all valid versions for python
31+
* [`Python::Loglevel`](#pythonloglevel): A version type to match all valid loglevels for python
32+
* [`Python::Package::Ensure`](#pythonpackageensure): A version type to match all valid package ensures for python
33+
* [`Python::Provider`](#pythonprovider): A version type to match all valid provider for python
34+
* [`Python::Umask`](#pythonumask): A version type to match valid umask for python
3535
* [`Python::Version`](#pythonversion): A version type to match all valid versions for python
3636

3737
## Classes
@@ -433,7 +433,7 @@ Default value: `'/etc/gunicorn.d'`
433433

434434
##### `manage_config_dir`
435435

436-
Data type: `Booloean`
436+
Data type: `Boolean`
437437

438438
Set if the gunicorn config directory should be created.
439439

@@ -872,7 +872,7 @@ Data type: `Array[Stdlib::Absolutepath]`
872872

873873
Specifies the PATH variable.
874874

875-
Default value: `[ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin', ]`
875+
Default value: `['/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin',]`
876876

877877
##### `environment`
878878

@@ -977,7 +977,7 @@ Default value: ``false``
977977

978978
##### `cwd`
979979

980-
Data type: `Stdlib::Absolutepath`
980+
Data type: `Optional[Stdlib::Absolutepath]`
981981

982982
The directory from which to run the "pip install" command.
983983

@@ -1156,7 +1156,7 @@ Data type: `Array[Stdlib::Absolutepath]`
11561156

11571157
Specifies the PATH variable
11581158

1159-
Default value: `[ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin', ]`
1159+
Default value: `['/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin',]`
11601160

11611161
##### `cwd`
11621162

@@ -1202,25 +1202,25 @@ Default value: ``undef``
12021202

12031203
### `Python::Loglevel`
12041204

1205-
A version type to match all valid versions for python
1205+
A version type to match all valid loglevels for python
12061206

12071207
Alias of `Enum['debug', 'info', 'warning', 'error', 'critical']`
12081208

12091209
### `Python::Package::Ensure`
12101210

1211-
A version type to match all valid versions for python
1211+
A version type to match all valid package ensures for python
12121212

12131213
Alias of `Enum['absent', 'present', 'latest']`
12141214

12151215
### `Python::Provider`
12161216

1217-
A version type to match all valid versions for python
1217+
A version type to match all valid provider for python
12181218

12191219
Alias of `Enum['pip', 'scl', 'rhscl', 'anaconda', '']`
12201220

12211221
### `Python::Umask`
12221222

1223-
A version type to match all valid versions for python
1223+
A version type to match valid umask for python
12241224

12251225
Alias of `Pattern[/[0-7]{1,4}/]`
12261226

manifests/requirements.pp

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# @param src Pip --src parameter to; if the requirements file contains --editable resources, this parameter specifies where they will be installed. See the pip documentation for more.
1111
# @param environment Additional environment variables required to install the packages.
1212
# @param forceupdate Run a pip install requirements even if we don't receive an event from the requirements file - Useful for when the requirements file is written as part of a resource other than file (E.g vcsrepo)
13-
# @param cwd The directory from which to run the "pip install" command.
13+
# @param cwd The directory from which to run the "pip install" command.
1414
# @param extra_pip_args Extra arguments to pass to pip after the requirements file
1515
# @param manage_requirements Create the requirements file if it doesn't exist.
1616
# @param fix_requirements_owner Change owner and group of requirements file.
@@ -35,7 +35,7 @@
3535
Any $src = false,
3636
Array $environment = [],
3737
Boolean $forceupdate = false,
38-
Stdlib::Absolutepath $cwd = undef,
38+
Optional[Stdlib::Absolutepath] $cwd = undef,
3939
String $extra_pip_args = '',
4040
Boolean $manage_requirements = true,
4141
Boolean $fix_requirements_owner = true,

spec/defines/requirements_spec.rb

+18-14
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
describe 'python::requirements', type: :define do
44
on_supported_os.each do |os, facts|
5-
next if os == 'gentoo-3-x86_64'
65
context "on #{os}" do
76
let :facts do
87
facts
@@ -15,8 +14,7 @@
1514
context 'with /requirements.txt' do
1615
let :params do
1716
{
18-
requirements: '/requirements.txt',
19-
cwd: '/foo'
17+
requirements: '/requirements.txt'
2018
}
2119
end
2220

@@ -35,26 +33,32 @@
3533
let :params do
3634
{
3735
owner: 'bob',
38-
group: 'bob',
39-
cwd: '/foo'
36+
group: 'bob'
4037
}
4138
end
4239

4340
it { is_expected.to compile.and_raise_error(%r{root user must be used when virtualenv is system}) }
4441
end
4542
end
4643

47-
context 'default' do
48-
let :params do
49-
{
50-
'cwd': '/foo'
51-
}
52-
end
44+
context 'without parameters' do
45+
it { is_expected.to compile.with_all_deps }
46+
it { is_expected.to contain_class('python::config') }
47+
it { is_expected.to contain_class('python::install') }
48+
it { is_expected.to contain_class('python::params') }
49+
it { is_expected.to contain_class('python') }
50+
it { is_expected.to contain_exec('python_requirements/requirements.txt') }
51+
it { is_expected.to contain_package('pip') }
52+
it { is_expected.to contain_package('python') }
53+
it { is_expected.to contain_package('virtualenv') }
54+
it { is_expected.to contain_package('gunicorn') }
5355
it { is_expected.to contain_file('/requirements.txt').with_owner('root').with_group('root') }
54-
end
5556

56-
describe 'without cwd' do
57-
it { is_expected.to compile.and_raise_error(%r{parameter 'cwd' expects a Stdlib::Absolutepath}) }
57+
if facts[:os]['name'] == 'Gentoo'
58+
it { is_expected.not_to contain_package('python-dev') }
59+
else
60+
it { is_expected.to contain_package('python-dev') }
61+
end
5862
end
5963
end
6064
end

0 commit comments

Comments
 (0)