Skip to content

Commit

Permalink
fix: log event
Browse files Browse the repository at this point in the history
  • Loading branch information
ElderMatt committed Jun 21, 2024
1 parent 2650ba0 commit 6647982
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/operator/keycloak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,19 +280,22 @@ export default class MyOperator extends Operator {
// Watch team namespaces to see if teams get added or removed
try {
await this.watchResource('', 'v1', 'namespaces', async (e) => {
const { object }: { object: k8s.V1Namespace } = e
const { object } = e
const { metadata, type } = object as CustomKubernetesObject
// Check if namespace starts with prefix 'team-'
if (metadata && !metadata.name?.startsWith('team-')) return
if (metadata && metadata.name === 'team-admin') return
console.log('namespace object: ', object)
console.log('namespace metadata: ', object.metadata)
console.log('Type namespace: ', type)
console.log('event: ', e)
switch (e.type) {
case ResourceEventType.Deleted:
console.log('EVENT DELETED NAMESPACE')
await runKeycloakUpdater('removeTeam')
break
case ResourceEventType.Added:
console.log('EVENT ADDED NAMESPACE')
await runKeycloakUpdater('addTeam')
break
default:
Expand Down

0 comments on commit 6647982

Please sign in to comment.