Skip to content

Commit

Permalink
Merge pull request puppetlabs-toy-chest#67 from mckern/master
Browse files Browse the repository at this point in the history
(maint) Add global cleanup option for mock stubs
  • Loading branch information
mckern committed May 15, 2014
2 parents 09d180e + f38ca57 commit 04f1a1c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
11 changes: 9 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
$use_tmpfs = false,
$tmpfs_req_ram = '4096',
$tmpfs_max_size = '2048m',
$cleanup_on_failure = true,
$cleanup_on_success = true,
) {

Class['Rpmbuilder::Packages::Essential']->Class['Rpmbuilder::Mock::Puppetlabs_mocks']
Expand Down Expand Up @@ -39,8 +41,13 @@
mock_root => $mock_root,
}
}

if $use_tmpfs {
include rpmbuilder::mock::tmpfs_plugin
}
}

class { rpmbuilder::mock::cleanup:
on_success => $cleanup_on_success,
on_failure => $cleanup_on_failure,
}
}
37 changes: 37 additions & 0 deletions manifests/mock/cleanup.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
class rpmbuilder::mock::cleanup(
$on_success = true,
$on_failure = true,
) {


# Python is awesome, in that it's true and false boolean
# values are Camel-cased: True and False. Subsequently,
# any values you pass in to a boolean configuration options
# must respect the aforementioned camel-casing. Might be worth
# adding a camel method for strings into stdlib?
$failure = $on_failure ? {
/(?i:false)/ => 'False',
/(?i:true)/ => 'True',
}

$success = $on_success ? {
/(?i:false)/ => 'False',
/(?i:true)/ => 'True',
}

ini_setting { "Cleanup on success":
ensure => present,
path => '/etc/mock/site-defaults.cfg',
section => '',
setting => "config_opts['cleanup_on_success']",
value => $cleanup_on_success,
}

ini_setting { "Cleanup on failure":
ensure => present,
path => '/etc/mock/site-defaults.cfg',
section => '',
setting => "config_opts['cleanup_on_failure']",
value => $cleanup_on_failure,
}
}

0 comments on commit 04f1a1c

Please sign in to comment.