Skip to content

Commit

Permalink
Merge pull request #4 from appuio/disabled
Browse files Browse the repository at this point in the history
Allow to disable configuration in hierarchy
  • Loading branch information
ccremer authored Oct 8, 2021
2 parents 87832b8 + 406f29e commit 4de2754
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 31 deletions.
73 changes: 42 additions & 31 deletions component/config.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,49 @@ local addCredentialNamespace(config, provider) =

local patchProvider(p) = std.foldl(addCredentialNamespace, std.objectFields(p), com.makeMergeable(p));

local groupSyncs = [
if !std.objectHas(params.sync[k], 'providers') then
error 'GroupSync needs to have at least one provider'
else
{
apiVersion: 'redhatcop.redhat.io/v1alpha1',
kind: 'GroupSync',
metadata: {
name: k,
namespace: params.namespace,
labels+: labels,
},
spec: {
providers: [
{ name: p } + patchProvider(params.sync[k].providers[p])
for p in std.objectFields(params.sync[k].providers)
],
},
}
for k in std.objectFields(params.sync)
];
local groupSyncs = std.filter(
// Ignore nullified objects
function(it) it != null,
[
if params.sync[k] != null then (
if !std.objectHas(params.sync[k], 'providers') then
error 'GroupSync needs to have at least one provider'
else
{
apiVersion: 'redhatcop.redhat.io/v1alpha1',
kind: 'GroupSync',
metadata: {
name: k,
namespace: params.namespace,
labels+: labels,
},
spec: {
providers: [
{ name: p } + patchProvider(params.sync[k].providers[p])
for p in std.objectFields(params.sync[k].providers)
],
},
}
)
for k in std.objectFields(params.sync)
]
);

local credentials = [
kube.Secret(s) {
type: 'Opaque',
metadata+: {
namespace: params.namespace,
labels+: labels,
},
} + com.makeMergeable(params.secrets[s])
for s in std.objectFields(params.secrets)
];
local credentials = std.filter(
// Ignore nullified objects
function(it) it != null,
[
if params.secrets[s] != null then
kube.Secret(s) {
type: 'Opaque',
metadata+: {
namespace: params.namespace,
labels+: labels,
},
} + com.makeMergeable(params.secrets[s])
for s in std.objectFields(params.secrets)
]
);

{
[if std.length(groupSyncs) > 0 then '02_groupsync']: groupSyncs,
Expand Down
3 changes: 3 additions & 0 deletions tests/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ parameters:
credentialsSecret:
name: other-foo

disabled: null

secrets:
disabled: null
foo-keycloak:
stingData:
username: foo
Expand Down

0 comments on commit 4de2754

Please sign in to comment.