Skip to content

Commit 4d12761

Browse files
feat: environment and stage addons (#13)
* feat: add env and stage addon * fix: property value validation * chore: improve type comparision and parsing * feat: add AddonHandler interface * feat: implement AddonHandler for project.Cluster * feat: implement AddonHandler for project.Environment * feat: implement AddonHandler for project.Stage * feat: implement text color wraping feat: implement text color wrapping * chore: improve addon menu * feat: implement environment based addon menu * fix: check type unit tests * chore: remove debug output * feat: manage addons on stage level * chore: sanitize go dependencies * chore: improve env, stage and cluster gathering * feat: add cluster properties to addon rendering * feat: add cluster properties to addon config * chore: remove overlays folder from .gitignore * feat: add example PROJECT.yaml, templates and addons * fix: check type for string * chore: add further tests for cluster * chore: add unit tests for environment * chore: add unit tests for stage * chore: add tests for addon handling * fix: nil pointer when one of the addons is not defined on the stage or env level * chore: update example
1 parent abc8270 commit 4d12761

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3537
-626
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
overlays/
21
dist/
32

43
PROJECT.yaml

PROJECT.example.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
addons:
2+
cluster-policies:
3+
defaultEnabled: true
4+
group: cluster-configs/policies
5+
path: _example/source/addons/cluster-policies
6+
disco-operator:
7+
defaultEnabled: true
8+
group: cluster-configs/policies
9+
path: _example/source/addons/disco-operator
10+
kyverno:
11+
defaultEnabled: true
12+
group: cluster-configs
13+
path: _example/source/addons/kyverno
14+
monitoring:
15+
defaultEnabled: false
16+
group: cluster-configs
17+
path: _example/source/addons/monitoring
18+
basePath: _example/overlays
19+
environments:
20+
dev:
21+
actions:
22+
postCreateHooks: null
23+
postUpdateHooks: null
24+
preCreateHooks: null
25+
preUpdateHooks: null
26+
addons:
27+
cluster-policies:
28+
enabled: true
29+
properties:
30+
enableNetworkPolicies: true
31+
disco-operator:
32+
enabled: true
33+
properties:
34+
isSuperCool: true
35+
requiredDefaultNotSet: 10
36+
second: Hello World
37+
properties:
38+
gitBranch: develop
39+
gitURL: https://github.com/leonsteinhaeuser/openshift-gitops-cli.git
40+
stages:
41+
dev:
42+
actions:
43+
postCreateHooks: null
44+
postUpdateHooks: null
45+
preCreateHooks: null
46+
preUpdateHooks: null
47+
addons:
48+
cluster-policies:
49+
enabled: true
50+
properties:
51+
enableNetworkPolicies: false
52+
clusters:
53+
hugi:
54+
addons:
55+
cluster-policies:
56+
enabled: true
57+
properties:
58+
enableNetworkPolicies: true
59+
disco-operator:
60+
enabled: true
61+
properties:
62+
isSuperCool: false
63+
requiredDefaultNotSet: null
64+
second: Hello World
65+
kyverno:
66+
enabled: true
67+
properties: {}
68+
monitoring:
69+
enabled: true
70+
properties:
71+
ingress_host: https://monitoring.2.external.url
72+
properties:
73+
destinationNamespace: openshift-gitops
74+
properties:
75+
destinationServer: https://kubernetes.default.svc
76+
templateBasePath: _example/source/templates

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,4 @@ No matter if you define an addon or a template, you always have access to the fo
246246
| `{{ .Stage }}` | addon, tempate | The stage variable returns the name of the stage we are currently in |
247247
| `{{ .Cluster }}` | addon, tempate | The cluster variable returns the name of the cluster we are currently in |
248248
| `{{ .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. |
249+
| `{{ .ClusterProperties.<key> }}` | addon | The cluster properties is a map that contains all properties that are defined for the cluster. |

_example/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Example
2+
3+
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.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
apiVersion: kustomize.config.k8s.io/v1beta1
3+
kind: Kustomization
4+
helmGlobals:
5+
chartHome: ../../../../../../charts/
6+
helmCharts:
7+
- name: argocd-app-of-app
8+
version: 0.4.0
9+
valuesFile: values.yaml
10+
namespace: openshift-gitops
11+
releaseName: argocd-app-of-app-0.4.0
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
appSuffix: "hugi-dev"
3+
appSourceBasePath: overlays/dev/dev/hugi/cluster-configs
4+
5+
default:
6+
app:
7+
annotations:
8+
argocd.argoproj.io/compare-options: IgnoreExtraneous
9+
enabled: true
10+
enableAutoSync: true
11+
autoSyncPrune: true
12+
project: hub
13+
destination:
14+
namespace: openshift-gitops
15+
server: https://kubernetes.default.svc
16+
source:
17+
repoURL: https://github.com/leonsteinhaeuser/openshift-gitops-cli.git
18+
targetRevision: <no value>
19+
20+
projects:
21+
hub:
22+
annotations:
23+
argocd.argoproj.io/sync-wave: "-2"
24+
description: Project for cluster hub
25+
namespace: openshift-gitops
26+
sourceRepos:
27+
- https://github.com/leonsteinhaeuser/openshift-gitops-cli.git
28+
destinations: |
29+
- namespace: '*'
30+
server: https://kubernetes.default.svc
31+
extraFields: |
32+
clusterResourceWhitelist:
33+
- group: '*'
34+
kind: '*'
35+
36+
applications:
37+
cluster-policies:
38+
enabled: true
39+
annotations:
40+
argocd.argoproj.io/sync-wave: "0"
41+
source:
42+
path: cluster-policies
43+
labels:
44+
app.kubernetes.io/managed-by: argocd
45+
disco-operator:
46+
enabled: true
47+
annotations:
48+
argocd.argoproj.io/sync-wave: "0"
49+
source:
50+
path: disco-operator
51+
labels:
52+
app.kubernetes.io/managed-by: argocd
53+
kyverno:
54+
enabled: true
55+
annotations:
56+
argocd.argoproj.io/sync-wave: "0"
57+
source:
58+
path: kyverno
59+
labels:
60+
app.kubernetes.io/managed-by: argocd
61+
monitoring:
62+
enabled: true
63+
annotations:
64+
argocd.argoproj.io/sync-wave: "0"
65+
source:
66+
path: monitoring
67+
labels:
68+
app.kubernetes.io/managed-by: argocd
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
apiVersion: kustomize.config.k8s.io/v1beta1
3+
kind: Kustomization
4+
resources:
5+
- "../../../../../../base/kyverno/"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
value: pair
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
apiVersion: kustomize.config.k8s.io/v1beta1
3+
kind: Kustomization
4+
resources:
5+
- "../../../../../../base/monitoring"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
test:
2+
hello: world

0 commit comments

Comments
 (0)