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 5 Created Aug. 24, 2017, 6:37 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.
12 #
13 # === Examples:
14 #
15 # adblockplus::mercurial::extension {'example':
16 # name => 'pager',
17 # config => {
18 # content => join([
19 # '[extensions]',
20 # 'pager = ',
21 # '[pager]',
22 # 'pager = LESS=FSRX less',
23 # ], "\n"),
24 # }
25 # }
26 #
27 # adblockplus::mercurial::extension {'hggit':
28 # package => {
29 # 'ensure' => 'latest',
30 # 'name' => 'hg-git',
31 # 'provider' => 'pip',
32 # 'install_options' => ['https://pypi.python.org/pypi/hg-git'],
33 # },
34 # }
35 #
36 # adblockplus::mercurial::extension {'hgext.git':
37 # package => {
38 # 'ensure' => 'absent',
39 # 'name' => 'mercurial-git',
40 # },
41 # }
42 #
43 define adblockplus::mercurial::extension (
44 $config = {},
45 $package = undef,
46 ) {
47
48 include adblockplus::mercurial
49 include stdlib
50
51 # https://docs.puppet.com/puppet/latest/lang_conditional.html#selectors
52 # https://docs.puppet.com/puppet/latest/types/file.html#file-attribute-content
53 # https://docs.puppet.com/puppet/latest/types/file.html#file-attribute-source
54 $default_content = $config['source'] ? {
55 undef => template('adblockplus/mercurial/hgext.erb'),
56 default => undef,
57 }
58
59 # https://forge.puppet.com/puppetlabs/stdlib#ensure_resource
60 # https://forge.puppet.com/puppetlabs/stdlib#merge
61 ensure_resource('file', "$name.rc", merge({
62 content => $default_content,
63 ensure => ensure_file_state($adblockplus::mercurial::ensure),
64 path => "/etc/mercurial/hgrc.d/$name.rc",
65 }, $config))
66
67 # https://docs.puppet.com/puppet/latest/lang_relationships.html
68 File["$name.rc"] <- Package['mercurial']
69
70 # https://docs.puppet.com/puppet/latest/function.html#defined
71 if defined('$package') {
72
73 ensure_resource('package', $name, merge({
74 ensure => $adblockplus::mercurial::ensure,
75 require => Package['python-dev'],
76 }, $package))
77
78 Package[$name] <- Package['mercurial']
79 }
80 }
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