Skip to content

Commit f192591

Browse files
Library 2.2.1 & Helmize 0.1.0-rc.1 (#31)
Library 2.2.1 & Helmize 0.1.0-rc.1
1 parent 7594d5e commit f192591

File tree

18 files changed

+118
-62
lines changed

18 files changed

+118
-62
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ credentials.yml
4242
# Nodejs
4343
node_modules/
4444
package-lock.json
45+
46+
# Charts
47+
*.tgz
48+
Chart.lock

charts/helmize/Chart.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ apiVersion: v2
22
name: helmize
33
description: Go Sprig based deployment engine deployed via Helm
44
type: library
5-
version: "0.1.0-rc.0"
5+
version: "0.1.0-rc.1"
66
appVersion: "0.1.0"
77
home: https://buttahtoast.github.io/helmize/
88
icon: https://raw.githubusercontent.com/buttahtoast/helmize/main/icon.jpg
99
dependencies:
1010
- name: library
1111
version: "2.2.0"
12-
repository: https://buttahtoast.github.io/helm-charts/
12+
repository: "file://../library"
13+
#repository: https://buttahtoast.github.io/helm-charts/
1314
keywords:
1415
- library
1516
- sprig

charts/helmize/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Helmize
22

3-
![Version: 0.1.0-rc.0](https://img.shields.io/badge/Version-0.1.0--rc.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)
3+
![Version: 0.1.0-rc.1](https://img.shields.io/badge/Version-0.1.0--rc.1-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)
44

55
Helmize is a simple deployment library wrapped in a library helm chart. It's purpose is to simplify complex infrastructure deployments where you change deployed manifests based on given conditions. This project is thought for people that bootstrap complex infrastructure setup on kubernetes and want to simplify their file structure.
66

charts/helmize/templates/conditions/_defaults.tpl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ conditions
1515
*/}}
1616
{{- define "inventory.conditions.defaults.inv_dir" -}}
1717
inventory_directory
18-
{{- end }}
19-
18+
{{- end }}

charts/helmize/templates/conditions/_types.tpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ name:
99
required: true
1010
key:
1111
types: [ "string" ]
12+
key_types:
13+
types: [ "slice" ]
14+
default: [ "string", "slice" ]
1215
required:
1316
types: [ "int", "bool" ]
1417
default:
@@ -17,7 +20,7 @@ path:
1720
types: [ "string" ]
1821
filter:
1922
types: [ "string", "slice" ]
20-
reverseFilter:
23+
reverse_filter:
2124
types: [ "int", "bool" ]
2225
allow_root:
2326
types: [ "int", "bool" ]

charts/helmize/templates/conditions/func/_path.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/}}
1313
{{- define "inventory.conditions.func.path" -}}
1414
{{- if and $.cond $.path $.ctx -}}
15-
{{- $base_directory := (fromYaml (include "inventory.config.func.resolve" (dict "path" (include "inventory.conditions.defaults.inv_dir" $.ctx) "req" true "ctx" $.ctx))).res -}}
15+
{{- $base_directory := (fromYaml (include "inventory.config.func.resolve" (dict "path" (include "inventory.conditions.defaults.inv_dir" $.ctx) "ctx" $.ctx))).res -}}
1616
{{- $base_path := (include "inventory.helpers.trailingPath" $.path) -}}
1717
{{- if $base_directory -}}
1818
{{- $base_path = (printf "%s/%s" (include "inventory.helpers.trailingPath" $base_directory | trimSuffix "/") $base_path) -}}

charts/helmize/templates/conditions/func/_resolve.tpl

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@
3434
{{- $condition_struct := dict "name" $condition.name "root_path" $condition_path "paths" list "keys" list "config" $condition -}}
3535

3636
{{/* Add Condition Keys */}}
37-
{{- $key := (fromYaml (include "lib.utils.dicts.lookup" (dict "data" $.ctx "path" (default "" $condition.key) "required" false))).res }}
37+
{{- $key := "" -}}
38+
{{- if $condition.key -}}
39+
{{- $key = (fromYaml (include "lib.utils.dicts.lookup" (dict "data" $.ctx "path" $condition.key "required" false))).res -}}
40+
{{- end -}}
3841
{{- if and $condition.key (and (not $key) ($condition.required)) -}}
3942
{{- include "inventory.helpers.fail" (printf "A Value for %s is required but not set" $condition.key) -}}
4043
{{- else if not $key -}}
@@ -48,18 +51,28 @@
4851
{{- $condition_keys = append $condition_keys $key -}}
4952
{{- end -}}
5053
{{- end -}}
51-
52-
{{/* Add groups as possible keys */}}
53-
{{- if not $condition.groups_disabled -}}
54-
{{- if $.roles -}}
55-
{{- $condition_keys = concat $.roles $condition_keys -}}
54+
55+
{{/* Validate Type */}}
56+
{{- if $key -}}
57+
{{- $type_error := 1 -}}
58+
{{- if $condition.key_types -}}
59+
{{- range $condition.key_types -}}
60+
{{- if (kindIs . $key) -}}
61+
{{- $type_error = 0 -}}
62+
{{- end -}}
63+
{{- end -}}
64+
{{- else -}}
65+
{{- $type_error = 0 -}}
5666
{{- end -}}
57-
{{- end -}}
67+
{{- if $type_error -}}
68+
{{- $_ := set $return "errors" (concat $return.errors (list (dict "condition" $condition.name "error" (printf "Value for condition must be %s but is %s" ($condition.key_types| join ", ") (kindOf $key))))) -}}
69+
{{- end -}}
70+
{{- end -}}
5871

5972
{{/* Apply a filter to all results */}}
6073
{{- if $condition.filter -}}
6174
{{- $filtered_list := $condition_keys -}}
62-
{{- if $condition.reverseFilter -}}
75+
{{- if $condition.reverse_filter -}}
6376
{{- $filtered_list = list -}}
6477
{{- end -}}
6578
{{- if (kindIs "string" $condition.filter) -}}
@@ -69,7 +82,7 @@
6982
{{- $con := . -}}
7083
{{- range $condition.filter -}}
7184
{{- if (regexMatch . $con) -}}
72-
{{- if $condition.reverseFilter -}}
85+
{{- if $condition.reverse_filter -}}
7386
{{- $filtered_list = append $filtered_list $con -}}
7487
{{- else -}}
7588
{{- $filtered_list = without $filtered_list $con -}}
@@ -79,6 +92,12 @@
7992
{{- end -}}
8093
{{- $condition_keys = $filtered_list -}}
8194
{{- end -}}
95+
96+
{{/* Add Base */}}
97+
{{- if $condition.allow_root -}}
98+
{{- $condition_keys = prepend $condition_keys "/" -}}
99+
{{- end -}}
100+
82101

83102
{{/* Create Path for each Condition Key */}}
84103
{{- $condition_keys = $condition_keys | uniq -}}

charts/helmize/templates/config/_defaults.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
55
*/}}
66
{{- define "inventory.config.defaults.location" -}}
7-
{{- default "_config.yaml" $.Values.config_file -}}
7+
{{- default "helmize.yaml" $.Values.config_file -}}
88
{{- end }}

charts/helmize/templates/config/func/_get.tpl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,22 @@
1010
{{- $cfg_loc := (include "inventory.config.defaults.location" $) -}}
1111

1212
{{/* Validate based on type how config is set */}}
13-
{{- $cfg := fromYaml (.Files.Get $cfg_loc) -}}
13+
{{- $cfg := .Files.Get $cfg_loc -}}
1414

15-
{{/* When config has values */}}
15+
{{/* When config has content */}}
1616
{{- if $cfg -}}
1717

18+
{{/* Template Content */}}
19+
{{- $template_config_raw := tpl $cfg $ -}}
20+
{{- $template_config := fromYaml ($template_config_raw) -}}
21+
22+
{{/* Validate if conversation was successful, otherwise return with error */}}
23+
{{- if not (include "lib.utils.errors.unmarshalingError" $template_config) -}}
24+
{{- $cfg = $template_config -}}
25+
{{- else -}}
26+
{{- include "lib.utils.errors.fail" (printf "Templating of %s did not return valid YAML:\n%s" $cfg_loc ($template_config_raw | nindent 2)) -}}
27+
{{- end -}}
28+
1829
{{/* Validate Configuration */}}
1930
{{- $cfg_validate := fromYaml (include "lib.utils.types.validate" (dict "type" "inventory.config.types.config" "data" $cfg "ctx" $)) -}}
2031
{{- if $cfg_validate.isType -}}

charts/helmize/templates/entrypoint/_defaults.tpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,13 @@
55
*/}}
66
{{- define "inventory.entrypoint.defaults.force" -}}
77
force
8+
{{- end -}}
9+
10+
{{/* Summary <Template>
11+
12+
Default Summary Values Key
13+
14+
*/}}
15+
{{- define "inventory.entrypoint.defaults.summary_value" -}}
16+
summary
817
{{- end -}}

0 commit comments

Comments
 (0)