Skip to content

Commit

Permalink
replace git execs with vcsrepo
Browse files Browse the repository at this point in the history
puppetlabs/vcsrepo provides advanced handling of multiple VCSes. Rather
than relying on fragile execs, we replace them with calls to vcsrepo.
  • Loading branch information
igalic committed Dec 5, 2013
1 parent a656d83 commit 3e37a44
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 35 deletions.
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ fixtures:
"gitlab": "#{source_dir}"
repositories:
"stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
"vcsrepo": "git://github.com/puppetlabs/puppetlabs-vcsrepo.git"
1 change: 1 addition & 0 deletions Modulefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ summary 'Puppet GitLab Module'
description 'Module to install GitLab using puppet'
project_page 'https://github.com/sbadia/puppet-gitlab/'
dependency 'puppetlabs/stdlib', '>= 3.1.0'
dependency 'puppetlabs/vcsrepo', '>= 0.2.0'
#dependency 'sbadia/gitlab_requirements', '>= 0.2.0'
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#
# === Parameters
#
# [*ensure*]
# Ensure present, latest. absent is not yet supported
# default: present
#
# [*git_user*]
# Name of gitlab user
# default: git
Expand Down Expand Up @@ -173,6 +177,7 @@
# Andrew Tomaka, Sebastien Badia, Steffen Roegner (c) 2013
#
class gitlab(
$ensure = $gitlab::params::ensure,
$git_user = $gitlab::params::git_user,
$git_home = $gitlab::params::git_home,
$git_email = $gitlab::params::git_email,
Expand Down Expand Up @@ -238,6 +243,7 @@
validate_re($ldap_method, '(ssl|tls)', 'ldap_method is not supported (ssl or tls)')
validate_re($gitlab_projects, '^\d+$', 'gitlab_projects is not valid')
validate_re($gitlab_unicorn_port, '^\d+$', 'gitlab_unicorn_port is not valid')
validate_re($ensure, '(present|latest)', 'ensure is not valid (present|latest)')

validate_string($git_user)
validate_string($git_email)
Expand Down
21 changes: 10 additions & 11 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
#
#
class gitlab::package inherits gitlab {
Exec {
cwd => $git_home,
user => $git_user,
path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
Vcsrepo {
ensure => $ensure,
provider => 'git',
user => $git_user,
}

exec { 'download gitlab':
command => "git clone -b ${gitlab_branch} ${gitlab_sources} ./gitlab",
creates => "${git_home}/gitlab",
vcsrepo { "${git_home}/gitlab":
source => $gitlab_sources,
revision => $gitlab_branch,
}

exec { 'download gitlab-shell':
command => "git clone -b ${gitlabshell_branch} ${gitlabshell_sources} ./gitlab-shell",
creates => "${git_home}/gitlab-shell",
vcsrepo { "${git_home}/gitlab-shell":
source => $gitlabshell_sources,
revision => $gitlabshell_branch,
}
}
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
class gitlab::params {

$ensure = 'present'
$git_user = 'git'
$git_home = '/home/git'
$git_email = 'git@someserver.net'
Expand Down
48 changes: 24 additions & 24 deletions spec/classes/gitlab_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,36 +193,36 @@
describe 'gitlab::package' do
describe 'get gitlab{-shell} sources' do
context 'with default params' do
it { should contain_exec('download gitlab').with(
:cwd => '/home/git',
:user => 'git',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:command => 'git clone -b 6-3-stable git://github.com/gitlabhq/gitlabhq.git ./gitlab',
:creates => '/home/git/gitlab'
it { should contain_vcsrepo('/home/git/gitlab').with(
:ensure => 'present',
:user => 'git',
:provider => 'git',
:source => 'git://github.com/gitlabhq/gitlabhq.git',
:revision => '6-3-stable'
)}
it { should contain_exec('download gitlab-shell').with(
:cwd => '/home/git',
:user => 'git',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:command => 'git clone -b v1.7.9 git://github.com/gitlabhq/gitlab-shell.git ./gitlab-shell',
:creates => '/home/git/gitlab-shell'
it { should contain_vcsrepo('/home/git/gitlab-shell').with(
:ensure => 'present',
:user => 'git',
:provider => 'git',
:source => 'git://github.com/gitlabhq/gitlab-shell.git',
:revision => 'v1.7.9'
)}
end
context 'with specifics params' do
let(:params) { params_set }
it { should contain_exec('download gitlab').with(
:cwd => params_set[:git_home],
:command => "git clone -b #{params_set[:gitlab_branch]} #{params_set[:gitlab_sources]} ./gitlab",
:user => params_set[:git_user],
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:creates => "#{params_set[:git_home]}/gitlab"
it { should contain_vcsrepo("#{params_set[:git_home]}/gitlab").with(
:ensure => 'present',
:user => params_set[:git_user],
:provider => 'git',
:source => params_set[:gitlab_sources],
:revision => params_set[:gitlab_branch]
)}
it { should contain_exec('download gitlab-shell').with(
:cwd => params_set[:git_home],
:command => "git clone -b #{params_set[:gitlabshell_branch]} #{params_set[:gitlabshell_sources]} ./gitlab-shell",
:user => params_set[:git_user],
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:creates => "#{params_set[:git_home]}/gitlab-shell"
it { should contain_vcsrepo("#{params_set[:git_home]}/gitlab-shell").with(
:ensure => 'present',
:user => params_set[:git_user],
:provider => 'git',
:source => params_set[:gitlabshell_sources],
:revision => params_set[:gitlabshell_branch]
)}
end
end # get gitlab sources
Expand Down

0 comments on commit 3e37a44

Please sign in to comment.