Skip to content

Commit

Permalink
fix: reload issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Arun-KumarH committed Jul 4, 2024
1 parent bc94bf7 commit 7033d46
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
10 changes: 10 additions & 0 deletions src/resourceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ export class RuleService extends ServiceBase<RuleListResponse, RuleList> impleme
return { operation_status: acsResponse.operation_status };
}
const result = await super.update(request, ctx);
_accessController.policySets = await policySetService.load() || new Map();
this.logger.info('Reloaded Rules after update operation');
return result;
}

Expand Down Expand Up @@ -286,6 +288,8 @@ export class RuleService extends ServiceBase<RuleListResponse, RuleList> impleme
return { operation_status: acsResponse.operation_status };
}
const result = await super.upsert(request, ctx);
_accessController.policySets = await policySetService.load() || new Map();
this.logger.info('Reloaded Rules after upsert operation');
return result;
}

Expand Down Expand Up @@ -541,6 +545,8 @@ export class PolicyService extends ServiceBase<PolicyListResponse, PolicyList> i
return { operation_status: acsResponse.operation_status };
}
const result = await super.update(request, ctx);
_accessController.policySets = await policySetService.load() || new Map();
this.logger.info('Reloaded Policies after update operation');
return result;
}

Expand Down Expand Up @@ -570,6 +576,8 @@ export class PolicyService extends ServiceBase<PolicyListResponse, PolicyList> i
return { operation_status: acsResponse.operation_status };
}
const result = await super.upsert(request, ctx);
_accessController.policySets = await policySetService.load() || new Map();
this.logger.info('Reloaded Policies after upsert operation');
return result;
}

Expand Down Expand Up @@ -986,6 +994,8 @@ export class PolicySetService extends ServiceBase<PolicySetListResponse, PolicyS
return { operation_status: acsResponse.operation_status };
}
const result = await super.upsert(request, ctx);
_accessController.policySets = await policySetService.load() || new Map();
this.logger.info('Reloaded PolicySet after upsert operation');
return result;
}
}
Expand Down
15 changes: 1 addition & 14 deletions src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,6 @@ export class Worker {
_.assign({}, kafkaConfig, policySetConfig, policyConfig, ruleConfig));

kafkaConfig = this.cfg.get('events:kafka');
const acsEvents = [
'policy_setCreated',
'policy_setModified',
'policy_setDeleted',
'policyCreated',
'policyModified',
'policyDeleted',
'ruleCreated',
'ruleModified',
'ruleDeleted',
];
const hierarchicalScopesResponse = 'hierarchicalScopesResponse';
const events = new Events(kafkaConfig, this.logger); // Kafka
await events.start();
Expand Down Expand Up @@ -241,9 +230,7 @@ export class Worker {
const commandTopic = await events.topic(this.cfg.get('events:kafka:topics:command:topic'));
const eventListener = async (msg: any,
context: any, config: any, eventName: string): Promise<any> => {
if (acsEvents.indexOf(eventName) > -1) {
await accessControlService.loadPolicies();
} else if (eventName === hierarchicalScopesResponse) {
if (eventName === hierarchicalScopesResponse) {
// Add subject_id to waiting list
const hierarchical_scopes = msg?.hierarchical_scopes ? msg.hierarchical_scopes : [];
const tokenDate = msg?.token;
Expand Down

0 comments on commit 7033d46

Please sign in to comment.