This repository was archived by the owner on Jun 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathconfig.pp
More file actions
62 lines (57 loc) · 1.31 KB
/
config.pp
File metadata and controls
62 lines (57 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# = Define a git config
#
# This sets configuration paramenters for github
# It can be used to set system wide configs or user specific configs
#
# == Parameters:
#
# [*section*]
# The section of the config
# [*key*]
# The name of the config
# [*value*]
# The value for the config
# [*user*]
# The user to save the config (defaults to system config)
#
# == Examples:
#
# - Minimal setup for system config
# github::config { 'color.status' :
# value => 'auto'
# }
#
# - Full setup for user specific config
# github::config { 'color-status' :
# section => 'color',
# key => 'status',
# value => 'auto',
# user => $::id
# }
define git::config(
$section = '',
$key = '',
$value,
$user = ''
) {
include git
if empty($user) {
$real_command = "git config --system"
}
else {
validate_string($user)
$real_command = "sudo -u ${user} git config --global"
}
if empty($section) and empty($key) {
validate_re($name, '^\w+\.\w+$')
$real_section_key = $name
}
else {
$real_section_key = "${section}.${key}"
}
exec { $real_section_key:
command => "${real_command} ${real_section_key} \"${value}\"",
unless => "${real_command} ${real_section_key} | grep -c '${value}'",
require => Package['git'],
}
}