Skip to content

Commit

Permalink
Merge pull request #4 from tPl0ch/exec_user
Browse files Browse the repository at this point in the history
Allow setting exec user for project and exec
  • Loading branch information
andyshinn committed Nov 7, 2013
2 parents b240e04 + 5290e8e commit ac8aab9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ spec/fixtures/modules/*
.bundle/
vendor/
Gemfile.lock
pkg/
2 changes: 2 additions & 0 deletions manifests/exec.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
$logoutput = false,
$verbose = false,
$refreshonly = false,
$user = undef,
) {
require composer
require git

Exec {
path => "/bin:/usr/bin/:/sbin:/usr/sbin:${composer::target_dir}",
environment => "COMPOSER_HOME=${composer::composer_home}",
user => $user,
}

if $cmd != 'install' and $cmd != 'update' {
Expand Down
7 changes: 6 additions & 1 deletion manifests/project.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
# [*php_package*]
# The Package name of the PHP CLI package.
#
# [*user*]
# The user name to exec the composer commands as. Default is undefined.
#
# === Authors
#
# Thomas Ploch <[email protected]>
Expand All @@ -43,14 +46,16 @@
$repository_url = undef,
$keep_vcs = false,
$tries = 3,
$timeout = 1200
$timeout = 1200,
$user = undef,
) {
require git
require composer

Exec {
path => "/bin:/usr/bin/:/sbin:/usr/sbin:${composer::target_dir}",
environment => "COMPOSER_HOME=${composer::composer_home}",
user => $user,
}

$exec_name = "composer_create_project_${title}"
Expand Down
8 changes: 5 additions & 3 deletions spec/defines/composer_exec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@

let(:title) { 'myproject' }
let(:params) { {
:cmd => 'install',
:cwd => '/my/awesome/project',
:cmd => 'install',
:cwd => '/my/awesome/project',
:user => 'linus',
} }

it {
should contain_exec('composer_update_myproject').with({
:command => %r{php /usr/local/bin/composer install --no-plugins --no-scripts --no-interaction},
:cwd => '/my/awesome/project',
:user => 'linus',
:logoutput => false,
})
}
Expand All @@ -39,7 +41,7 @@
} }

it {
should contain_exec('composer_update_yourpr0ject').with({
should contain_exec('composer_update_yourpr0ject').without_user.with({
:command => %r{php /usr/local/bin/composer update --no-plugins --no-scripts --no-interaction package1 packageinf},
:cwd => '/just/in/time',
:logoutput => true,
Expand Down
6 changes: 4 additions & 2 deletions spec/defines/composer_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
it { should include_class('composer') }

it {
should contain_exec('composer_create_project_myproject').with({
should contain_exec('composer_create_project_myproject').without_user.with({
:command => "php /usr/local/bin/composer --stability=dev create-project projectzzz /my/subpar/project",
:tries => 3,
:timeout => 1200,
Expand All @@ -39,7 +39,8 @@
:repository_url => '[email protected]:trollface/whoadawg.git',
:keep_vcs => true,
:tries => 2,
:timeout => 600
:timeout => 600,
:user => 'mrploch',
} }

it { should include_class('git') }
Expand All @@ -51,6 +52,7 @@
:tries => 2,
:timeout => 600,
:creates => '/my/mediocre/project',
:user => 'mrploch',
})
}
end
Expand Down

0 comments on commit ac8aab9

Please sign in to comment.