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

Allow hierarchical token store configuration #3

Merged
merged 1 commit into from
Jan 23, 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
19 changes: 16 additions & 3 deletions component/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,31 @@ local alerts = function(name, groupName, alerts)

local emergencyAccounts =
std.map(
function(ea) ea { _create_binding:: super._create_binding },
function(ea) ea {
// Commodores makeMergeable unhides fields so we hide them after processing
_create_binding:: super._create_binding,
spec+: {
_tokenStores+:: {},
},
},
com.generateResources(
params.emergency_accounts,
function(name) kube._Object('cluster.appuio.io/v1beta1', 'EmergencyAccount', name) {
function(name) kube._Object('cluster.appuio.io/v1beta1', 'EmergencyAccount', name) + {
spec+: {
tokenStores+: [],
_tokenStores+: {},
},
} + {
metadata+: {
namespace: params.namespace,
},
spec+: {
tokenStores+: std.map(function(k) self._tokenStores[k] { name: k }, std.objectFields(self._tokenStores)),
},
},
)
);


local emergencyAccountBindings = std.filterMap(
function(name) std.get(params.emergency_accounts[name], '_create_binding', true),
function(name) kube.ClusterRoleBinding(name) {
Expand Down
19 changes: 19 additions & 0 deletions docs/modules/ROOT/pages/references/parameters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ emergency_accounts:
tokenStores:
- name: secret
type: secret
_tokenStores:
ext-s3:
type: s3
s3Store:
encryption:
encrypt: true
pgpKeys: [omitted]
s3:
endpoint: zrh.example.io
bucket: emergency-credentials
accessKeyId: nJxvJLuryTpxBVt16La4xEM5ZfAB5fIVPGEPdDrR
secretAccessKey: Z9rQrB2QHLEcmCVBqGi8EnKlKUfUcQ6PrfXnjenH
objectNameTemplate: "em-{{ .Context.ClusterId | sha256sum }}"
objectNameTemplateContext:
ClusterId: ${cluster:name}
no-binding:
_create_binding: false
spec:
Expand All @@ -76,6 +91,10 @@ The value is the configuration of the `EmergencyAccount` object.
The value has an additional key `_create_binding` which is used to control whether a `ClusterRoleBinding` to the ClusterRole defined in `cluster_admin_role` should be created.
The default is `true`.

The `_tokenStores` keys is a helper to hierarchically configure the `tokenStores` key.
It's a dictionary where the key is the name of the `tokenStore` and the value is the configuration of the `tokenStore`.
The resulting configurations are appended to the `tokenStores` key.

See https://github.com/appuio/emergency-credentials-controller for the manifest definition.


Expand Down
6 changes: 6 additions & 0 deletions tests/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ parameters:
_create_binding: false
spec:
validityDuration: 720h
tokenStores:
- name: secret
type: secret
_tokenStores:
ext-s3:
type: s3
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ metadata:
name: no-binding
namespace: appuio-emergency-credentials-controller
spec:
tokenStores:
- name: ext-s3
type: s3
- name: secret
type: secret
validityDuration: 720h
Loading