Skip to content

Commit

Permalink
fix: fix mapping of validation action for synchronized bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
f1ames committed Jan 4, 2024
1 parent 541babd commit ea3c92e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion admission-controller/synchronizer/src/utils/policy-updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export class PolicyUpdater {

return {
policyName: binding.policy.id,
validationActions: ['Warn'],
validationActions: [this.mapValidationAction(binding.action)],
matchResources: {
namespaceSelector: {
matchExpressions: [{
Expand All @@ -239,4 +239,18 @@ export class PolicyUpdater {

return _.isEqual(binding1Copy, binding2Copy);
}

protected mapValidationAction(action: string) {
const actionNormalized = action.toLowerCase().trim();

switch (actionNormalized) {
case 'warn':
return 'Warn';
case 'deny':
return 'Deny';
default:
this._logger.error({ msg: 'Unknown validation action', action });
return 'Warn';
}
}
}
2 changes: 2 additions & 0 deletions admission-controller/synchronizer/src/utils/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type ClusterQueryResponseBindingPolicy = {
export type ClusterQueryResponseBinding = {
id: string
mode: 'ALLOW_LIST' | 'BLOCK_LIST'
action: 'warn' | 'deny'
namespaces: string[]
policy: ClusterQueryResponseBindingPolicy
};
Expand Down Expand Up @@ -53,6 +54,7 @@ export const getClusterQuery = `
bindings {
id
mode
action
namespaces
policy {
id
Expand Down

0 comments on commit ea3c92e

Please sign in to comment.