Skip to content

Commit 33cfe80

Browse files
committed
add groups
1 parent 5a92006 commit 33cfe80

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

groups.tf

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
locals {
2+
groups_html_template_file_basename = "groups.html.tftpl"
3+
input_groups_html_template_file = "${var.template_files_path}/${local.groups_html_template_file_basename}"
4+
default_groups_html_template_file = "${path.module}/templates/${var.template_type}/${local.groups_html_template_file_basename}"
5+
groups_html_template_file = fileexists(local.input_groups_html_template_file) ? local.input_groups_html_template_file : local.default_groups_html_template_file
6+
}
7+
8+
locals {
9+
branch_protection_text = tomap({
10+
0 = "no protection"
11+
1 = "partial protection"
12+
2 = "full protection"
13+
3 = "protect against pushes"
14+
})
15+
}
16+
17+
data "gitlab_groups" "groups" {
18+
}

outputs_groups.tf

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
locals {
2+
groups_template_vars = merge(
3+
tomap({
4+
groups = data.gitlab_groups.groups.groups
5+
}),
6+
tomap({
7+
groups_sort = var.groups_sort
8+
tabulator_theme = var.tabulator_theme,
9+
html_font_family = var.html_font_family
10+
}),
11+
tomap({
12+
branch_protection_text = local.branch_protection_text
13+
}))
14+
}
15+
16+
output "groups_html" {
17+
value = templatefile(local.groups_html_template_file, local.groups_template_vars)
18+
}

templates/tabulator/groups.html.tftpl

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8">
4+
<link href="https://unpkg.com/tabulator-tables/dist/css/tabulator.min.css" rel="stylesheet">
5+
<script type="text/javascript" src="https://unpkg.com/tabulator-tables/dist/js/tabulator.min.js"></script>
6+
<link href="https://unpkg.com/tabulator-tables/dist/css/tabulator_${tabulator_theme}.min.css" rel="stylesheet">
7+
<style>
8+
.tabulator, h1 {
9+
font-family: ${html_font_family};
10+
}
11+
</style>
12+
</head>
13+
<div id="gitlab-groups"></div>
14+
<script>
15+
var tabledata = [
16+
%{ for group in groups ~}
17+
{
18+
full_path: "${group.full_path}",
19+
description: "${group.description}",
20+
visibility_level: "${group.visibility_level}",
21+
request_access_enabled: "${group.request_access_enabled}",
22+
branch_protection_text: "${branch_protection_text[group.default_branch_protection]}",
23+
prevent_forking_outside_group: "${group.prevent_forking_outside_group}",
24+
},
25+
%{ endfor ~}
26+
];
27+
var table = new Tabulator("#gitlab-groups", {
28+
data: tabledata,
29+
columns: [
30+
{ title:"Full path", field:"full_path" },
31+
{ title:"Description", field:"description" },
32+
{ title:"Visibility", field:"visibility_level", headerVertical:"true" },
33+
{ title:"Request access enabled", field:"request_access_enabled", headerVertical:"true"},
34+
{ title:"Default branch protection", field:"branch_protection_text", headerVertical:"true" },
35+
{ title:"Prevent forking outside group", field:"prevent_forking_outside_group", headerVertical:"true" },
36+
],
37+
initialSort: [
38+
{ column: "full_path", dir: "${groups_sort}" },
39+
]
40+
});
41+
</script>
42+
</body>
43+
</html>

variables_groups.tf

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
variable "groups_sort" {
2+
description = "the value for sort for full_path"
3+
type = string
4+
default = "asc"
5+
}

0 commit comments

Comments
 (0)