Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default values for AppProjects #152

Merged
merged 1 commit into from
Feb 29, 2024
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
4 changes: 3 additions & 1 deletion component/instances.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ local argocds = std.foldl(
// Gather AppProject instances
local projects = std.mapWithKey(function(k, v) std.get(v, 'projects', {}), instances);

local projectDefaults = std.mapWithKey(function(k, v) std.get(v, 'projectDefaults', {}), instances);

// Flatten AppProjects, generating a namespaced name as the key
local appprojects = {
[namespacedName(argocd).namespace + '/' + project]: projects[argocd][project]
[namespacedName(argocd).namespace + '/' + project]+: std.mergePatch(projectDefaults[argocd], projects[argocd][project])
for argocd in std.objectFields(projects)
for project in std.objectFields(projects[argocd])
// remove nulled objects
Expand Down
9 changes: 9 additions & 0 deletions docs/modules/ROOT/pages/references/parameters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,12 @@ Arbitrary `AppProject` instances to be deployed on the cluster.
The keys of this parameter are used as the generated resource's `metadata.name`, while the parent `ArgoCD`'s namespace will be inherited.

See https://argo-cd.readthedocs.io/en/stable/user-guide/projects/[the `AppProject` reference of Argo CD] for available fields.


=== `instances.<namespace>/<name>.projectDefaults`

[horizontal]
type:: dictionary
default:: `{}`

Default values that will be applied for all `AppProjects` created for this instance.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ metadata:
spec:
clusterResourceWhitelist: []
destinations:
- namespace: cust-*
- namespace: other-*
server: https://kubernetes.default.svc
sourceNamespaces:
- two
---
apiVersion: argoproj.io/v1alpha1
kind: AppProject
Expand All @@ -25,3 +27,5 @@ spec:
destinations:
- namespace: corp-*
server: https://kubernetes.default.svc
sourceNamespaces:
- one
19 changes: 13 additions & 6 deletions tests/params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,24 @@ parameters:
tls:
termination: reencrypt
version: v2.10.1

projectDefaults:
spec:
clusterResourceWhitelist: []
destinations:
- namespace: corp-*
server: https://kubernetes.default.svc

projects:
nulled-project: null
some-project:
spec:
clusterResourceWhitelist: []
destinations:
- namespace: corp-*
server: https://kubernetes.default.svc
sourceNamespaces:
- one
other-project:
spec:
clusterResourceWhitelist: []
sourceNamespaces:
- two
destinations:
- namespace: cust-*
- namespace: other-*
server: https://kubernetes.default.svc
Loading