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

python::requirements: make cwd optional (again) #587

Merged
merged 1 commit into from
Dec 3, 2020
Merged
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
24 changes: 12 additions & 12 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@

### Data types

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

## Classes
Expand Down Expand Up @@ -433,7 +433,7 @@ Default value: `'/etc/gunicorn.d'`

##### `manage_config_dir`

Data type: `Booloean`
Data type: `Boolean`

Set if the gunicorn config directory should be created.

Expand Down Expand Up @@ -872,7 +872,7 @@ Data type: `Array[Stdlib::Absolutepath]`

Specifies the PATH variable.

Default value: `[ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin', ]`
Default value: `['/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin',]`

##### `environment`

Expand Down Expand Up @@ -977,7 +977,7 @@ Default value: ``false``

##### `cwd`

Data type: `Stdlib::Absolutepath`
Data type: `Optional[Stdlib::Absolutepath]`

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

Expand Down Expand Up @@ -1156,7 +1156,7 @@ Data type: `Array[Stdlib::Absolutepath]`

Specifies the PATH variable

Default value: `[ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin', ]`
Default value: `['/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin',]`

##### `cwd`

Expand Down Expand Up @@ -1202,25 +1202,25 @@ Default value: ``undef``

### `Python::Loglevel`

A version type to match all valid versions for python
A version type to match all valid loglevels for python

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

### `Python::Package::Ensure`

A version type to match all valid versions for python
A version type to match all valid package ensures for python

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

### `Python::Provider`

A version type to match all valid versions for python
A version type to match all valid provider for python

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

### `Python::Umask`

A version type to match all valid versions for python
A version type to match valid umask for python

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

Expand Down
4 changes: 2 additions & 2 deletions manifests/requirements.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# @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.
# @param environment Additional environment variables required to install the packages.
# @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)
# @param cwd The directory from which to run the "pip install" command.
# @param cwd The directory from which to run the "pip install" command.
# @param extra_pip_args Extra arguments to pass to pip after the requirements file
# @param manage_requirements Create the requirements file if it doesn't exist.
# @param fix_requirements_owner Change owner and group of requirements file.
Expand All @@ -35,7 +35,7 @@
Any $src = false,
Array $environment = [],
Boolean $forceupdate = false,
Stdlib::Absolutepath $cwd = undef,
Optional[Stdlib::Absolutepath] $cwd = undef,
String $extra_pip_args = '',
Boolean $manage_requirements = true,
Boolean $fix_requirements_owner = true,
Expand Down
32 changes: 18 additions & 14 deletions spec/defines/requirements_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

describe 'python::requirements', type: :define do
on_supported_os.each do |os, facts|
next if os == 'gentoo-3-x86_64'
context "on #{os}" do
let :facts do
facts
Expand All @@ -15,8 +14,7 @@
context 'with /requirements.txt' do
let :params do
{
requirements: '/requirements.txt',
cwd: '/foo'
requirements: '/requirements.txt'
}
end

Expand All @@ -35,26 +33,32 @@
let :params do
{
owner: 'bob',
group: 'bob',
cwd: '/foo'
group: 'bob'
}
end

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

context 'default' do
let :params do
{
'cwd': '/foo'
}
end
context 'without parameters' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('python::config') }
it { is_expected.to contain_class('python::install') }
it { is_expected.to contain_class('python::params') }
it { is_expected.to contain_class('python') }
it { is_expected.to contain_exec('python_requirements/requirements.txt') }
it { is_expected.to contain_package('pip') }
it { is_expected.to contain_package('python') }
it { is_expected.to contain_package('virtualenv') }
it { is_expected.to contain_package('gunicorn') }
it { is_expected.to contain_file('/requirements.txt').with_owner('root').with_group('root') }
end

describe 'without cwd' do
it { is_expected.to compile.and_raise_error(%r{parameter 'cwd' expects a Stdlib::Absolutepath}) }
if facts[:os]['name'] == 'Gentoo'
it { is_expected.not_to contain_package('python-dev') }
else
it { is_expected.to contain_package('python-dev') }
end
end
end
end
Expand Down