Skip to content

Commit

Permalink
feat: field level version filter
Browse files Browse the repository at this point in the history
  • Loading branch information
bzp2010 committed Dec 27, 2024
1 parent 1926f10 commit cd86776
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
6 changes: 5 additions & 1 deletion libs/backend-api7/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ export class BackendAPI7 implements ADCSDK.Backend {
}

public async sync(): Promise<Listr> {
const operator = new Operator(this.client, this.gatewayGroup);
const operator = new Operator({
client: this.client,
gatewayGroupName: this.gatewayGroup,
version: this.version,
});
return new Listr<OperateContext>(
[
this.getAPI7VersionTask(),
Expand Down
24 changes: 18 additions & 6 deletions libs/backend-api7/src/operator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@ export interface OperateContext {
type OperateTask = ListrTask<OperateContext>;

export class Operator {
constructor(
private readonly client: Axios,
private readonly gatewayGroupName: string,
) {}
private readonly client: Axios;
private readonly gatewayGroupName: string;
private readonly version: SemVer;

constructor(opts: {
client: Axios;
gatewayGroupName: string;
version: SemVer;
}) {
this.client = opts.client;
this.gatewayGroupName = opts.gatewayGroupName;
this.version = opts.version;
}

public updateResource(event: ADCSDK.Event): OperateTask {
return {
Expand Down Expand Up @@ -279,12 +288,15 @@ export class Operator {
case ADCSDK.ResourceType.SERVICE:
(event.newValue as ADCSDK.Service).id = event.resourceId;
return fromADC.transformService(event.newValue as ADCSDK.Service);
case ADCSDK.ResourceType.ROUTE:
case ADCSDK.ResourceType.ROUTE: {
(event.newValue as ADCSDK.Route).id = event.resourceId;
return fromADC.transformRoute(
const route = fromADC.transformRoute(
event.newValue as ADCSDK.Route,
event.parentId,
);
if (!semVerGTE(this.version, '3.2.16')) delete route.vars;
return route;
}
case ADCSDK.ResourceType.STREAM_ROUTE:
(event.newValue as ADCSDK.StreamRoute).id = event.resourceId;
return fromADC.transformStreamRoute(
Expand Down

0 comments on commit cd86776

Please sign in to comment.