Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: modules/adblockplus/manifests/mercurial/extension.pp

Issue 29526640: #3044 - Introduce class adblockplus::mercurial (Closed)
Patch Set: For comment 2 Created Aug. 24, 2017, 6:23 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # == Type: adblockplus::mercurial::extension
2 #
3 # Setup rotation for a particular log file.
4 #
5 # === Parameters:
6 #
7 # [*config*]
8 # Overwrite the default hgrc.d/$name file for Mercurial extensions.
9 #
10 # [*package*]
11 # Overwrite the default package/extension options, to fine-tune the target
mathias 2017/08/24 18:28:38 One can do more with that parameter than fine-tuni
12 # version.
13 #
14 # === Examples:
15 #
16 # adblockplus::mercurial::extension {'example':
17 # name => 'pager',
18 # config => {
19 # content => join([
20 # '[extensions]',
21 # 'pager = ',
22 # '[pager]',
23 # 'pager = LESS=FSRX less',
24 # ], "\n"),
25 # }
26 # }
27 #
28 # adblockplus::mercurial::extension {'hggit':
29 # package => {
30 # 'ensure' => 'latest',
31 # 'name' => 'hg-git',
32 # 'provider' => 'pip',
33 # 'install_options' => ['https://pypi.python.org/pypi/hg-git'],
34 # },
35 # }
36 #
37 # adblockplus::mercurial::extension {'hgext.git':
38 # package => {
39 # 'ensure' => 'absent',
40 # 'name' => 'mercurial-git',
41 # },
42 # }
43 #
44 define adblockplus::mercurial::extension (
45 $config = {},
46 $package = undef,
47 ) {
48
49 include adblockplus::mercurial
50 include stdlib
51
52 # https://docs.puppet.com/puppet/latest/lang_conditional.html#selectors
53 # https://docs.puppet.com/puppet/latest/types/file.html#file-attribute-content
54 # https://docs.puppet.com/puppet/latest/types/file.html#file-attribute-source
55 $default_content = $config['source'] ? {
56 undef => template('adblockplus/mercurial/hgext.erb'),
57 default => undef,
58 }
59
60 # https://forge.puppet.com/puppetlabs/stdlib#ensure_resource
61 # https://forge.puppet.com/puppetlabs/stdlib#merge
62 ensure_resource('file', "$name.rc", merge({
63 content => $default_content,
64 ensure => ensure_file_state($adblockplus::mercurial::ensure),
65 path => "/etc/mercurial/hgrc.d/$name.rc",
66 }, $config))
67
68 # https://docs.puppet.com/puppet/latest/lang_relationships.html
69 File["$name.rc"] <- Package['mercurial']
70
71 # https://docs.puppet.com/puppet/latest/function.html#defined
72 if defined('$package') {
73
74 ensure_resource('package', $name, merge({
75 ensure => $adblockplus::mercurial::ensure,
76 require => Package['python-dev'],
77 }, $package))
78
79 Package[$name] <- Package['mercurial']
80 }
81 }
OLDNEW
« no previous file with comments | « modules/adblockplus/manifests/mercurial.pp ('k') | modules/adblockplus/templates/mercurial/hgext.erb » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld