Skip to content

Commit

Permalink
feat(base-cluster/flux): add option to add a path inside the kustomiz… (
Browse files Browse the repository at this point in the history
  • Loading branch information
cwrau authored Apr 18, 2024
1 parent fe9037b commit 358b9e2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
14 changes: 8 additions & 6 deletions charts/base-cluster/ci/flux-gitrepositories-gen-values.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ set -o pipefail

i=0
for url in 'url="https://github.com"' 'url="ssh://[email protected]/group/name.git"'; do
for extra in 'branch="main"' 'commit="549aee1"' 'semver="1.0.0"' 'tag="2.0.1"' ''; do
for decr in 'decryption={provider:"sops"}' ''; do
for auth in 'username="user" | .password="pass"' ''; do
for git in 'gitInterval="5m"' ''; do
[[ $url = *ssh* ]] && [[ -n "$auth" ]] && continue
yq -y -n "{main$((i++)): ({} | .$url | .$extra | .$decr | .$auth | .$git)}"
for path in 'path="prod"' ''; do
for extra in 'branch="main"' 'commit="549aee1"' 'semver="1.0.0"' 'tag="2.0.1"' ''; do
for decr in 'decryption={provider:"sops"}' ''; do
for auth in 'username="user" | .password="pass"' ''; do
for git in 'gitInterval="5m"' ''; do
[[ $url = *ssh* ]] && [[ -n "$auth" ]] && continue
yq -y -n "{main$((i++)): ({} | .$url | .$path | .$extra | .$decr | .$auth | .$git)}"
done
done
done
done
Expand Down
5 changes: 4 additions & 1 deletion charts/base-cluster/templates/flux/flux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{- $authenticationMethod := (list nil) | first -}}
{{- if and $instance.username $instance.password -}}
{{- $authenticationMethod = "password" -}}
{{- else if regexMatch "^ssh://" $instance.url -}}
{{- else if hasPrefix "ssh://" $instance.url -}}
{{- $authenticationMethod = "ssh" -}}
{{- end -}}
{{- $authenticationSecretName := printf "%s-flux-%s" (include "common.names.fullname" $) $name -}}
Expand Down Expand Up @@ -81,6 +81,9 @@ spec:
kind: GitRepository
name: {{ printf "%s-flux-%s" (include "common.names.fullname" $) $name }}
namespace: {{ $.Release.Namespace }}
{{- if $instance.path }}
path: {{ include "common.tplvalues.render" (dict "value" $instance.path "context" $) | quote }}
{{- end }}
{{- if $instance.decryption }}
decryption:
provider: {{ $instance.decryption.provider | quote }}
Expand Down
3 changes: 3 additions & 0 deletions charts/base-cluster/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,9 @@
"tag": {
"type": "string"
},
"path": {
"type": "string"
},
"gitInterval": {
"type": "string",
"description": "The interval in which to sync the repository",
Expand Down

0 comments on commit 358b9e2

Please sign in to comment.