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
|
# File 'manifests/custom_hook.pp', line 17
define gitlab::custom_hook (
String $namespace,
String $project,
Enum['update', 'post-receive', 'pre-receive'] $type,
Optional[String] $content = undef,
Optional[String] $source = undef,
Optional[Stdlib::Absolutepath] $repos_path = undef,
) {
if $repos_path {
$_repos_path = $repos_path
} elsif $gitlab::git_data_dir {
$_repos_path = "${gitlab::git_data_dir}/repositories"
} else {
$_repos_path = '/var/opt/gitlab/git-data/repositories'
}
if ! ($content) and ! ($source) {
fail("gitlab::custom_hook[${name}]: Must specify either content or source")
}
if ($content) and ($source) {
fail("gitlab::custom_hook[${name}]: Must specify either content or source, but not both")
}
$hook_path = "${_repos_path}/${namespace}/${project}.git/custom_hooks"
File {
owner => $gitlab::service_user,
group => $gitlab::service_group,
mode => '0755',
}
# Create the custom_hooks directory for this project, if it doesn't exist
if !defined(File[$hook_path]) {
file { $hook_path:
ensure => directory,
}
}
file { "${hook_path}/${type}":
ensure => file,
content => $content,
source => $source,
}
}
|