Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a6b4229
feat: add env and stage addon
leonsteinhaeuser Mar 10, 2025
1996ae4
fix: property value validation
leonsteinhaeuser Mar 10, 2025
dd5e5fa
chore: improve type comparision and parsing
leonsteinhaeuser Mar 16, 2025
3ba00e8
feat: add AddonHandler interface
leonsteinhaeuser Mar 16, 2025
9c4774a
feat: implement AddonHandler for project.Cluster
leonsteinhaeuser Mar 16, 2025
973723a
feat: implement AddonHandler for project.Environment
leonsteinhaeuser Mar 16, 2025
94e96f1
feat: implement AddonHandler for project.Stage
leonsteinhaeuser Mar 16, 2025
a871f8e
feat: implement text color wraping
leonsteinhaeuser Mar 16, 2025
db3f616
chore: improve addon menu
leonsteinhaeuser Mar 16, 2025
e41d58b
feat: implement environment based addon menu
leonsteinhaeuser Mar 16, 2025
276cef8
fix: check type unit tests
leonsteinhaeuser Mar 16, 2025
5c18b65
chore: remove debug output
leonsteinhaeuser Mar 16, 2025
d869e35
feat: manage addons on stage level
leonsteinhaeuser Mar 16, 2025
8efdb9b
chore: sanitize go dependencies
leonsteinhaeuser Mar 16, 2025
e862614
chore: improve env, stage and cluster gathering
leonsteinhaeuser Mar 16, 2025
17bdd5d
feat: add cluster properties to addon rendering
leonsteinhaeuser Mar 16, 2025
5928fc4
feat: add cluster properties to addon config
leonsteinhaeuser Mar 16, 2025
d30ba87
chore: remove overlays folder from .gitignore
leonsteinhaeuser Mar 16, 2025
e44cab1
feat: add example PROJECT.yaml, templates and addons
leonsteinhaeuser Mar 16, 2025
e4a6c9b
fix: check type for string
leonsteinhaeuser Mar 18, 2025
cd17aa9
chore: add further tests for cluster
leonsteinhaeuser Mar 18, 2025
cfaab7c
chore: add unit tests for environment
leonsteinhaeuser Mar 18, 2025
86515af
chore: add unit tests for stage
leonsteinhaeuser Mar 18, 2025
b2bed9c
chore: add tests for addon handling
leonsteinhaeuser Mar 18, 2025
36a90fb
fix: nil pointer when one of the addons is not defined on the stage o…
leonsteinhaeuser Mar 18, 2025
3b0c756
chore: update example
leonsteinhaeuser Mar 18, 2025
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
overlays/
dist/

PROJECT.yaml
76 changes: 76 additions & 0 deletions PROJECT.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
addons:
cluster-policies:
defaultEnabled: true
group: cluster-configs/policies
path: _example/source/addons/cluster-policies
disco-operator:
defaultEnabled: true
group: cluster-configs/policies
path: _example/source/addons/disco-operator
kyverno:
defaultEnabled: true
group: cluster-configs
path: _example/source/addons/kyverno
monitoring:
defaultEnabled: false
group: cluster-configs
path: _example/source/addons/monitoring
basePath: _example/overlays
environments:
dev:
actions:
postCreateHooks: null
postUpdateHooks: null
preCreateHooks: null
preUpdateHooks: null
addons:
cluster-policies:
enabled: true
properties:
enableNetworkPolicies: true
disco-operator:
enabled: true
properties:
isSuperCool: true
requiredDefaultNotSet: 10
second: Hello World
properties:
gitBranch: develop
gitURL: https://github.com/leonsteinhaeuser/openshift-gitops-cli.git
stages:
dev:
actions:
postCreateHooks: null
postUpdateHooks: null
preCreateHooks: null
preUpdateHooks: null
addons:
cluster-policies:
enabled: true
properties:
enableNetworkPolicies: false
clusters:
hugi:
addons:
cluster-policies:
enabled: true
properties:
enableNetworkPolicies: true
disco-operator:
enabled: true
properties:
isSuperCool: false
requiredDefaultNotSet: null
second: Hello World
kyverno:
enabled: true
properties: {}
monitoring:
enabled: true
properties:
ingress_host: https://monitoring.2.external.url
properties:
destinationNamespace: openshift-gitops
properties:
destinationServer: https://kubernetes.default.svc
templateBasePath: _example/source/templates
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,4 @@ No matter if you define an addon or a template, you always have access to the fo
| `{{ .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. |
| `{{ .ClusterProperties.<key> }}` | addon | The cluster properties is a map that contains all properties that are defined for the cluster. |
3 changes: 3 additions & 0 deletions _example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Example

This folder contains an example for the openshift-gitops-cli. The `PROJECT.example.yaml` file contains the configuration for the example project. The `PROJECT.example.yaml` file is an example project config referencing the templates and addons in the `_example/source` folder. The `_example/overlys` folder contains the rendered configuration defined by the cluster defined in the PROJECT.example.yaml file.
11 changes: 11 additions & 0 deletions _example/overlays/dev/dev/hugi/app-of-apps/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
helmGlobals:
chartHome: ../../../../../../charts/
helmCharts:
- name: argocd-app-of-app
version: 0.4.0
valuesFile: values.yaml
namespace: openshift-gitops
releaseName: argocd-app-of-app-0.4.0
68 changes: 68 additions & 0 deletions _example/overlays/dev/dev/hugi/app-of-apps/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
appSuffix: "hugi-dev"
appSourceBasePath: overlays/dev/dev/hugi/cluster-configs

default:
app:
annotations:
argocd.argoproj.io/compare-options: IgnoreExtraneous
enabled: true
enableAutoSync: true
autoSyncPrune: true
project: hub
destination:
namespace: openshift-gitops
server: https://kubernetes.default.svc
source:
repoURL: https://github.com/leonsteinhaeuser/openshift-gitops-cli.git
targetRevision: <no value>

projects:
hub:
annotations:
argocd.argoproj.io/sync-wave: "-2"
description: Project for cluster hub
namespace: openshift-gitops
sourceRepos:
- https://github.com/leonsteinhaeuser/openshift-gitops-cli.git
destinations: |
- namespace: '*'
server: https://kubernetes.default.svc
extraFields: |
clusterResourceWhitelist:
- group: '*'
kind: '*'

applications:
cluster-policies:
enabled: true
annotations:
argocd.argoproj.io/sync-wave: "0"
source:
path: cluster-policies
labels:
app.kubernetes.io/managed-by: argocd
disco-operator:
enabled: true
annotations:
argocd.argoproj.io/sync-wave: "0"
source:
path: disco-operator
labels:
app.kubernetes.io/managed-by: argocd
kyverno:
enabled: true
annotations:
argocd.argoproj.io/sync-wave: "0"
source:
path: kyverno
labels:
app.kubernetes.io/managed-by: argocd
monitoring:
enabled: true
annotations:
argocd.argoproj.io/sync-wave: "0"
source:
path: monitoring
labels:
app.kubernetes.io/managed-by: argocd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- "../../../../../../base/kyverno/"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value: pair
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- "../../../../../../base/monitoring"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
hello: world
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
hello: world
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
hello: world
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
hello: world
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- config/abc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- config/abc.yaml
- "../../../../../../base/base-config/cluster-policies/"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- "../../../../../../base/disco-operator/"
patches:
- name: Hello World
file: patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
some: yaml
key: false
2 changes: 2 additions & 0 deletions _example/source/addons/cluster-policies/config/abc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
hello: world
2 changes: 2 additions & 0 deletions _example/source/addons/cluster-policies/config/sub/abc2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
hello: world
8 changes: 8 additions & 0 deletions _example/source/addons/cluster-policies/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- config/abc.yaml
{{- if .Properties.enableNetworkPolicies}}
- "../../../../../../base/base-config/cluster-policies/"
{{- end}}
12 changes: 12 additions & 0 deletions _example/source/addons/cluster-policies/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: cluster-policies
group: cluster-policies
annotations:
argocd.argoproj.io/sync-wave: "0"
properties:
enableNetworkPolicies:
required: false
default: false
type: bool
description: "Whether to enable the cluster wide network policies"
files:
- ./
8 changes: 8 additions & 0 deletions _example/source/addons/disco-operator/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- "../../../../../../base/disco-operator/"
patches:
- name: {{ .Properties.second }}
file: patch.yaml
23 changes: 23 additions & 0 deletions _example/source/addons/disco-operator/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: disco-operator
group: cluster-policies
annotations:
argocd.argoproj.io/sync-wave: "0"
properties:
isSuperCool:
required: false
default: false
type: bool
description: "Is this app super cool?"
second:
required: true
default: "Hello World"
type: string
description: "Second?"
requiredDefaultNotSet:
required: true
default: null
type: int
description: "An empty property that is required"
files:
- kustomization.yaml
- patch.yaml
3 changes: 3 additions & 0 deletions _example/source/addons/disco-operator/patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
some: yaml
key: {{ .Properties.isSuperCool }}
5 changes: 5 additions & 0 deletions _example/source/addons/kyverno/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- "../../../../../../base/kyverno/"
7 changes: 7 additions & 0 deletions _example/source/addons/kyverno/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: kyverno
group: cluster-policies
annotations:
argocd.argoproj.io/sync-wave: "0"
properties: {}
files:
- ./
1 change: 1 addition & 0 deletions _example/source/addons/kyverno/something.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value: pair
5 changes: 5 additions & 0 deletions _example/source/addons/monitoring/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- "../../../../../../base/monitoring"
12 changes: 12 additions & 0 deletions _example/source/addons/monitoring/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: cluster-policies
group: cluster-policies
annotations:
argocd.argoproj.io/sync-wave: "0"
properties:
ingress_host:
required: false
default: false
type: string
description: "The host to expose grafana on"
files:
- ./
11 changes: 11 additions & 0 deletions _example/source/templates/appofapps/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
helmGlobals:
chartHome: ../../../../../../charts/
helmCharts:
- name: argocd-app-of-app
version: 0.4.0
valuesFile: values.yaml
namespace: openshift-gitops
releaseName: argocd-app-of-app-0.4.0
13 changes: 13 additions & 0 deletions _example/source/templates/appofapps/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: app-of-apps
properties:
gitURL:
required: true
default: ""
descriptionL: "Please define the git URL ArgoCD should reference"
targetRevision:
required: false
default: "develop"
description: "Please define the git target revision ArgoCD should reference"
files:
- values.yaml
- kustomization.yaml
46 changes: 46 additions & 0 deletions _example/source/templates/appofapps/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
appSuffix: "{{ .ClusterName }}-{{ .Stage }}"
appSourceBasePath: overlays/{{ .Environment }}/{{ .Stage }}/{{ .ClusterName }}/cluster-configs

default:
app:
annotations:
argocd.argoproj.io/compare-options: IgnoreExtraneous
enabled: true
enableAutoSync: true
autoSyncPrune: true
project: hub
destination:
namespace: {{ .Properties.destinationNamespace }}
server: {{ .Properties.destinationServer }}
source:
repoURL: {{ .Properties.gitURL }}
targetRevision: {{ .Properties.gitTargetRevision }}

projects:
hub:
annotations:
argocd.argoproj.io/sync-wave: "-2"
description: Project for cluster hub
namespace: openshift-gitops
sourceRepos:
- {{ .Properties.gitURL }}
destinations: |
- namespace: '*'
server: {{ .Properties.destinationServer }}
extraFields: |
clusterResourceWhitelist:
- group: '*'
kind: '*'

applications:
{{- range $key, $value := .Addons }}
{{ $key }}:
enabled: {{ $value.Enabled }}
annotations:
{{- $value.Annotations | toYaml | nindent 6 }}
source:
path: {{ $key }}
labels:
app.kubernetes.io/managed-by: argocd
{{- end }}
Loading
Loading