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
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,10 @@ No matter if you define an addon or a template, you always have access to the fo

| Variable | Scope | Description |
| --- | --- | --- |
| `{{ .Environment }}` | addon, tempate | The environment variable returns the name of the environment we are currenlty in |
| `{{ .Stage }}` | addon, tempate | The stage variable returns the name of the stage we are currently in |
| `{{ .Cluster }}` | addon, tempate | The cluster variable returns the name of the cluster we are currently in |
| `{{ .Properties.<key> }}` | addon, tempate | The properties variable returns the value of the property with the key `<key>`. The property keys in addons differ from the property keys in the template, as the addon does not currently have access to the environment, stage or cluster properties. In order for the addon to have properties available, you must define a property key in the `manifest.yaml` file. All properties defined there are then available for your addon template files. |
| `{{ .BasePath }}` | template | The configured base path to the `environment` folder |
| `{{ .ClusterPath }}` | template | The complete path to the cluster |
| `{{ .Environment }}` | addon, template | The environment variable returns the name of the environment we are currenlty in |
| `{{ .Stage }}` | addon, template | The stage variable returns the name of the stage we are currently in |
| `{{ .Cluster }}` | addon, template | The cluster variable returns the name of the cluster we are currently in |
| `{{ .Properties.<key> }}` | addon, template | The properties variable returns the value of the property with the key `<key>`. The property keys in addons differ from the property keys in the template, as the addon does not currently have access to the environment, stage or cluster properties. In order for the addon to have properties available, you must define a property key in the `manifest.yaml` file. All properties defined there are then available for your addon template files. |
| `{{ .ClusterProperties.<key> }}` | addon | The cluster properties is a map that contains all properties that are defined for the cluster. |
10 changes: 5 additions & 5 deletions _example/overlays/dev/dev/hugi/app-of-apps/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
appSuffix: "hugi-dev"
appSourceBasePath: overlays/dev/dev/hugi/cluster-configs
appSourceBasePath: _example/overlays/dev/dev/hugi

default:
app:
Expand Down Expand Up @@ -39,30 +39,30 @@ applications:
annotations:
argocd.argoproj.io/sync-wave: "0"
source:
path: cluster-policies
path: cluster-configs/policies/cluster-policies
labels:
app.kubernetes.io/managed-by: argocd
disco-operator:
enabled: true
annotations:
argocd.argoproj.io/sync-wave: "0"
source:
path: disco-operator
path: cluster-configs/policies/disco-operator
labels:
app.kubernetes.io/managed-by: argocd
kyverno:
enabled: true
annotations:
argocd.argoproj.io/sync-wave: "0"
source:
path: kyverno
path: cluster-configs/kyverno
labels:
app.kubernetes.io/managed-by: argocd
monitoring:
enabled: true
annotations:
argocd.argoproj.io/sync-wave: "0"
source:
path: monitoring
path: cluster-configs/monitoring
labels:
app.kubernetes.io/managed-by: argocd

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions _example/source/templates/appofapps/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
appSuffix: "{{ .ClusterName }}-{{ .Stage }}"
appSourceBasePath: overlays/{{ .Environment }}/{{ .Stage }}/{{ .ClusterName }}/cluster-configs
appSourceBasePath: {{ .ClusterPath }}

default:
app:
Expand Down Expand Up @@ -40,7 +40,7 @@ applications:
annotations:
{{- $value.Annotations | toYaml | nindent 6 }}
source:
path: {{ $key }}
path: {{ joinPath $value.Group $key }}
labels:
app.kubernetes.io/managed-by: argocd
{{- end }}
4 changes: 4 additions & 0 deletions internal/project/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package project

import (
"fmt"
"path"

"github.com/leonsteinhaeuser/openshift-gitops-cli/internal/template"
"github.com/leonsteinhaeuser/openshift-gitops-cli/internal/utils"
Expand Down Expand Up @@ -70,6 +71,7 @@ func (c *Cluster) Render(config *ProjectConfig, env, stage string) error {
for k, v := range addonProperties {
addons[k] = template.AddonData{
Enabled: v.Enabled,
Group: config.ParsedAddons[k].Group,
Annotations: config.ParsedAddons[k].Annotations,
Properties: v.Properties,
}
Expand All @@ -78,6 +80,8 @@ func (c *Cluster) Render(config *ProjectConfig, env, stage string) error {
// render templates
for _, t := range templates {
err = t.Render(config.BasePath, template.TemplateData{
BasePath: config.BasePath,
ClusterPath: path.Join(config.BasePath, env, stage, c.Name),
Environment: env,
Stage: stage,
ClusterName: c.Name,
Expand Down
3 changes: 3 additions & 0 deletions internal/template/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type TemplateCarrier struct {
}

type TemplateData struct {
BasePath string
ClusterPath string
Environment string
Stage string
ClusterName string
Expand All @@ -31,6 +33,7 @@ type TemplateData struct {

type AddonData struct {
Enabled bool
Group string
Annotations map[string]string
Properties map[string]any
}
Expand Down
2 changes: 2 additions & 0 deletions internal/template/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"compress/gzip"
"fmt"
"io"
"path"
"strings"
"text/template"

Expand All @@ -18,6 +19,7 @@ func funcMap(tmpl *template.Template) template.FuncMap {
templateFuncMap["gzip"] = gzipCompress
templateFuncMap["gunzip"] = gzipDecompress
templateFuncMap["include"] = includeFun(tmpl, map[string]int{})
templateFuncMap["joinPath"] = path.Join
return templateFuncMap
}

Expand Down
Loading