1
- {{ $data := "" }} {{ $p := "static/data/csv/keys.csv" }} {{ $excludedColumns :=
2
- slice 0 10 11 12 13 14 15 16 17 18 }} {{ if os.FileExists $p }} {{ $opts := dict
3
- "delimiter" "," }} {{ $data = (os.ReadFile $p | transform.Unmarshal $opts) }} {{
4
- else }} {{ errorf "Unable to get resource %q" $p }} {{ end }} {{ if $data }} {{
5
- $uniqueCategories := slice }} {{ $stopAddingCategories := false }} {{ range $i,
6
- $header := index $data 1 }} {{ if gt $i 3 }} {{if eq $header "Keychain ID"}} {{
7
- $stopAddingCategories = true }} {{end}} {{ if not $stopAddingCategories }} {{ if
8
- and (ne (trim $header "") "") (not (in $uniqueCategories $header)) }} {{
9
- $uniqueCategories = $uniqueCategories | append $header }} {{ end }} {{ end }} {{
10
- end }} {{end}} {{ range $index, $category := $uniqueCategories }}
11
- < div class ="csvtable-div ">
12
- < h2 id ="{{ $category | urlquery }} "> {{ $category }} Role </ h2 >
13
- < table class ="csvtable td-initial ">
14
- < thead >
15
- < tr >
16
- {{ range $i, $col := index $data 1 }} {{ if and (not (in
17
- $excludedColumns $i)) (or (eq $i 0) (ne $i 1) (ne $i 2)) }} {{ if and
18
- (eq $i 1) }}
19
- < th > Permission</ th >
20
- {{ else }} {{ if and (eq $i 2) }}
21
- < th > Description</ th >
22
- {{ end }}{{ end }} {{ end }} {{ end }}
23
- </ tr >
24
- </ thead >
25
- < tbody >
26
- {{ range $i, $row := $data }} {{ if gt $i 0 }} {{/* Skip the header row */}}
27
- {{ $hasAccess := false }} {{/* Flag to track if the row has access for the category */}}
28
- {{ $functionValue := "" }} {{/* Variable to hold the Function value */}}
29
- {{ $featureValue := "" }} {{/* Variable to hold the Feature value */}}
30
-
31
- {{/* Find the column indices for Category, Function, and Feature */}}
32
- {{ $categoryIndex := -1 }}
33
- {{ $functionIndex := -1 }}
34
- {{ $featureIndex := -1 }}
35
- {{ range $j, $header := index $data 1 }} {{/* Assuming the first row contains headers */}}
36
- {{ if eq $header $category }} {{/* Check if the header matches the current category */}}
37
- {{ $categoryIndex = $j }}
38
- {{ end }}
39
- {{ if eq $header "Function" }}
40
- {{ $functionIndex = $j }}
41
- {{ end }}
42
- {{ if eq $header "Feature" }}
43
- {{ $featureIndex = $j }}
44
- {{ end }}
45
- {{ end }}
46
- {{/* Check if the row has access for the category */}}
47
- {{ if and (ge $categoryIndex 0) (or (eq (index $row $categoryIndex) "X") (eq (index $row $categoryIndex) "X*")) }}
48
- {{ $hasAccess = true }}
49
- {{ end }}
50
- {{/* Get the Function and Feature values if the row has access */}}
51
- {{ if $hasAccess }}
52
- {{ $functionValue = index $row $functionIndex }}
53
- {{ $featureValue = index $row $featureIndex }}
54
- {{ end }}
55
- {{/* Print the row if it has access */}}
56
- {{ if $hasAccess }}
1
+ {{ $data := "" }}
2
+ {{ $p := "static/data/csv/keys.csv" }}
3
+ {{ $excludedColumns := slice 0 10 11 12 13 14 15 16 17 18 }}
4
+
5
+ {{ if os.FileExists $p }}
6
+ {{ $opts := dict "delimiter" "," }}
7
+ {{ $data = (os.ReadFile $p | transform.Unmarshal $opts) }}
8
+ {{ else }}
9
+ {{ errorf "Unable to get resource %q" $p }}
10
+ {{ end }}
11
+
12
+ {{ if $data }}
13
+ {{ $uniqueCategories := slice }}
14
+ {{ $stopAddingCategories := false }}
15
+
16
+ {{ range $i, $header := index $data 1 }}
17
+ {{ if gt $i 3 }}
18
+ {{ if eq $header "Keychain ID" }}
19
+ {{ $stopAddingCategories = true }}
20
+ {{ end }}
21
+
22
+ {{ if not $stopAddingCategories }}
23
+ {{ if and (ne (trim $header "") "") (not (in $uniqueCategories $header)) }}
24
+ {{ $uniqueCategories = $uniqueCategories | append $header }}
25
+ {{ end }}
26
+ {{ end }}
27
+ {{ end }}
28
+ {{ end }}
29
+
30
+ {{ range $index, $category := $uniqueCategories }}
31
+ < div class ="csvtable-div ">
32
+ {{ $sectionName := $category | lower }}
33
+ {{ $urlPath := "roles" }}
34
+ {{ if hasPrefix $sectionName "workspace" }}
35
+ {{ $urlPath = "roles/workspace-roles" }}
36
+ {{ else if hasPrefix $sectionName "team" }}
37
+ {{ $urlPath = "roles/team-roles" }}
38
+ {{ else if hasPrefix $sectionName "org" }}
39
+ {{ $urlPath = "roles/organization-roles" }}
40
+ {{ else if hasPrefix $sectionName "provider" }}
41
+ {{ $urlPath = "roles/#provider-admin-role" }}
42
+ {{ else }}
43
+ {{ $urlPath = print "roles/" $sectionName | urlize }}
44
+ {{ end }}
45
+ < h2 > < a href ="/cloud/security/{{ $urlPath }} "> {{ $category }} Role</ a > </ h2 >
46
+ < table class ="csvtable td-initial ">
47
+ < thead >
57
48
< tr >
58
- < td > {{ $functionValue }} </ td >
59
- < td > {{ $featureValue }}</ td >
49
+ {{ range $i, $col := index $data 1 }}
50
+ {{ if and (not (in $excludedColumns $i)) (or (eq $i 0) (ne $i 1) (ne $i 2)) }}
51
+ {{ if and (eq $i 1) }}
52
+ < th > Permission</ th >
53
+ {{ else }}
54
+ {{ if and (eq $i 2) }}
55
+ < th > Description</ th >
56
+ {{ end }}
57
+ {{ end }}
58
+ {{ end }}
59
+ {{ end }}
60
60
</ tr >
61
- {{end}}
62
- {{ end }} {{ end }}
63
- </ tbody >
64
- </ table >
65
- </ div >
66
- {{ end }} {{ else }}
61
+ </ thead >
62
+ < tbody >
63
+ {{ range $i, $row := $data }}
64
+ {{ if gt $i 0 }}
65
+ {{/* Skip the header row */}}
66
+ {{ $hasAccess := false }}
67
+ {{/* Flag to track if the row has access for the category */}}
68
+ {{ $functionValue := "" }}
69
+ {{/* Variable to hold the Function value */}}
70
+ {{ $featureValue := "" }}
71
+ {{/* Variable to hold the Feature value */}}
72
+
73
+ {{/* Find the column indices for Category, Function, and Feature */}}
74
+ {{ $categoryIndex := -1 }}
75
+ {{ $functionIndex := -1 }}
76
+ {{ $featureIndex := -1 }}
77
+ {{ range $j, $header := index $data 1 }}
78
+ {{/* Assuming the first row contains headers */}}
79
+ {{ if eq $header $category }}
80
+ {{/* Check if the header matches the current category */}}
81
+ {{ $categoryIndex = $j }}
82
+ {{ end }}
83
+ {{ if eq $header "Function" }}
84
+ {{ $functionIndex = $j }}
85
+ {{ end }}
86
+ {{ if eq $header "Feature" }}
87
+ {{ $featureIndex = $j }}
88
+ {{ end }}
89
+ {{ end }}
90
+
91
+ {{/* Check if the row has access for the category */}}
92
+ {{ if and (ge $categoryIndex 0) (or (eq (index $row $categoryIndex) "X") (eq (index $row $categoryIndex) "X*")) }}
93
+ {{ $hasAccess = true }}
94
+ {{ end }}
95
+ {{/* Get the Function and Feature values if the row has access */}}
96
+ {{ if $hasAccess }}
97
+ {{ $functionValue = index $row $functionIndex }}
98
+ {{ $featureValue = index $row $featureIndex }}
99
+ {{ end }}
100
+
101
+ {{/* Print the row if it has access */}}
102
+ {{ if $hasAccess }}
103
+ < tr >
104
+ < td > {{ $functionValue }} </ td >
105
+ < td > {{ $featureValue }}</ td >
106
+ </ tr >
107
+ {{ end }}
108
+ {{ end }}
109
+ {{ end }}
110
+ </ tbody >
111
+ </ table >
112
+ </ div >
113
+ {{ end }}
114
+ {{ else }}
67
115
< p > No data available.</ p >
68
- {{ end }}
69
-
70
-
116
+ {{ end }}
0 commit comments