Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ spec:
value: /helm/cache
- name: ENV_DESTINATIONS
value: | {{- .Values.environmentDestinations | toJson | nindent 16 }}
- name: ENV_SOURCE_PATTERN
value: {{ .Values.environmentSourcePattern | quote }}
{{- if .Values.helm.registry }}
- name: HELM_REGISTRY
value: {{ .Values.helm.registry | quote }}
Expand Down
13 changes: 9 additions & 4 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ image: oci://ghcr.io/joy-operator
version: latest

helm:
registry: ''
registry: ""
credentials:
secret: ''
key: ''
mountPath: ''
secret: ""
key: ""
mountPath: ""

commonLabels: {}

Expand Down Expand Up @@ -39,3 +39,8 @@ controller: {}
# defaultCatalog: catalog

environmentDestinations: {}

# Glob pattern to match source environment files
# Uses glob syntax from https://github.com/gobwas/glob
# To specify multiple specific environments, use something like `environments/{dev,demo}/env.yaml`
environmentSourcePattern: "environments/*/env.yaml"
Comment thread
davidmdm marked this conversation as resolved.
14 changes: 8 additions & 6 deletions cmd/operator/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import (
)

type Config struct {
CatalogName string
ChartCacheDir string
EnvDestinations map[string]argocd.ApplicationDestination
HelmLogin HelmLogin
Concurrency int
Pull bool
CatalogName string
ChartCacheDir string
EnvDestinations map[string]argocd.ApplicationDestination
EnvSourcePattern string
HelmLogin HelmLogin
Concurrency int
Pull bool
}

type HelmLogin struct {
Expand All @@ -31,6 +32,7 @@ func GetConfig() (Config, error) {
var cfg Config

conf.Var(conf.Environ, &cfg.EnvDestinations, "ENV_DESTINATIONS", conf.JSON[map[string]argocd.ApplicationDestination])
conf.Var(conf.Environ, &cfg.EnvSourcePattern, "ENV_SOURCE_PATTERN", conf.Default("environments/*/env.yaml"))
conf.Var(conf.Environ, &cfg.HelmLogin.Registry, "HELM_REGISTRY")
conf.Var(conf.Environ, &cfg.HelmLogin.CredentialsPath, "HELM_REGISTRY_CREDENTIALS_PATH")
conf.Var(conf.Environ, &cfg.ChartCacheDir, "CHART_CACHE_DIR", conf.RequiredNonEmpty[string]())
Expand Down
5 changes: 3 additions & 2 deletions cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ func run() (err error) {
ctrl.Entry{
GroupKind: v1alpha1.CatalogGK,
Funcs: CatalogReconciler(CatalogReconcilerParams{
CatalogName: cfg.CatalogName,
Pull: cfg.Pull,
CatalogName: cfg.CatalogName,
EnvSourcePattern: cfg.EnvSourcePattern,
Pull: cfg.Pull,
}),
},
); err != nil {
Expand Down
7 changes: 4 additions & 3 deletions cmd/operator/reconciler_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import (
)

type CatalogReconcilerParams struct {
CatalogName string
Pull bool
CatalogName string
Pull bool
EnvSourcePattern string
}

func CatalogReconciler(params CatalogReconcilerParams) ctrl.Funcs {
Expand Down Expand Up @@ -53,7 +54,7 @@ func CatalogReconciler(params CatalogReconcilerParams) ctrl.Funcs {
Source: argocd.ApplicationSource{
RepoURL: catalog.Spec.RepoURL,
TargetRevision: catalog.Spec.Revision,
Directory: argocd.SourceDirectory{Include: "environments/*/env.yaml"},
Directory: argocd.SourceDirectory{Include: params.EnvSourcePattern},
},
Destination: argocd.ApplicationDestination{
Server: "http://kubernetes.svc.local",
Expand Down