diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-10-11 01:20:53 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-10-11 01:20:53 +0200 |
commit | e738981089accbfb39bad1cb313281d966c07ed7 (patch) | |
tree | 1ddaa05a1c9a60a785719e09a6bd7aca3f0548c7 /manifests | |
parent | Re-flow metadata.json. (diff) | |
download | cgit-e738981089accbfb39bad1cb313281d966c07ed7.tar.gz cgit-e738981089accbfb39bad1cb313281d966c07ed7.tar.xz |
Rewrote filter system.
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/filter.pp | 53 | ||||
-rw-r--r-- | manifests/filter_setup.pp | 11 | ||||
-rw-r--r-- | manifests/init.pp | 46 |
3 files changed, 83 insertions, 27 deletions
diff --git a/manifests/filter.pp b/manifests/filter.pp new file mode 100644 index 0000000..2dda015 --- /dev/null +++ b/manifests/filter.pp @@ -0,0 +1,53 @@ +define cgit::filter ( + String $filtername = $name, + Optional[String] $source = undef, + Optional[String] $content = undef, + Hash $file_props = {}, + Enum['lua', 'exec'] $type = stdlib::extname($source) ? { + '.lua' => 'lua', + default => 'exec', + } +) { + + $valid_filters = [ + 'about', + 'auth', + 'commit', + 'email', + 'owner', + 'source', + ] + + if ! member($valid_filters, $filtername) { + crit("${filtername} not a valid cgit filter") + } + + $dest = "${cgit::filterpath}/${filtername}-filter" + + file { $dest: + ensure => file, + mode => type ? { + 'lua' => '0444', + 'exec' => '0555', + } + source => $source, + content => $content, + * => $file_props, + } + + concat::fragment { "cgit config ${}": + target => $::cgit::cgitrc, + content => "${filter_name}-filter=${type}:${dest}\n", + } + + [$about_filter, $source_filter].each |$f| { + file { "${filterpath}/${f}": + ensure => file, + source => "puppet:///modules/cgit/filters/${f}", + mode => stdlib::extname($f) ? { + '.lua' => '0444', + default => '0555', + }, + } + } +} diff --git a/manifests/filter_setup.pp b/manifests/filter_setup.pp new file mode 100644 index 0000000..8f42537 --- /dev/null +++ b/manifests/filter_setup.pp @@ -0,0 +1,11 @@ +class cgit::filter_setup ( + String $filterpath = $::cgit::filterpath, +) { + file { dirname($filterpath): + ensure => directory, + } + + file { $filterpath: + ensure => directory, + } +} diff --git a/manifests/init.pp b/manifests/init.pp index 62cb2a3..bbd8edb 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,6 +1,6 @@ class cgit ( String $root = '/var/www/cgit', - String $filterpath = '/usr/lib/cgit/extra-filters', + String $filterpath = '/usr/lib/cgit/puppet-controlled-filters', String $root_title, String $root_desc, String $root_readme_source = "puppet:///modules/${module_name}/root_readme", @@ -20,6 +20,8 @@ class cgit ( Optional[String] $server_name = undef, Optional[String] $certname = undef, String $htpasswd = '/var/lib/nginx/cgit-htpasswd', + String $cgitrc = '/etc/cgitrc', + Hash[String, Hash] $filters = {}, ) { # TODO figure out where CSS comes from @@ -29,11 +31,24 @@ class cgit ( 'cgit', ], { ensure => installed }) - file { '/etc/cgitrc': - ensure => file, - content => epp('cgit/cgitrc.epp'), + + concat { $cgitrc: + ensure => present, + } + concat::fragment { 'cgit config upper half': + order => 0, + content => epp('cgit/upper.epp'), + target => $::cgit::cgitrc, + } + + concat::fragment { 'cgit config lower half': + order => 99, + content => epp('cgit/lower.epp'), + target => $::cgit::cgitrc, } + create_resources(git::filter, $filters) + file { "${root}/logo": ensure => directory, } @@ -71,30 +86,7 @@ class cgit ( } } - file { dirname($filterpath): - ensure => directory, - } - file { $filterpath: - ensure => directory, - } - - [$about_filter, $source_filter].each |$f| { - file { "${filterpath}/${f}": - ensure => file, - source => "puppet:///modules/cgit/filters/${f}", - mode => stdlib::extname($f) ? { - '.lua' => '0444', - default => '0555', - }, - } - } - - file { "${filterpath}/${auth_filter}": - ensure => file, - content => epp("cgit/${auth_filter}.epp"), - mode => '0444', - } if $manage_server { if $server_name == undef { |