Skip to content

Commit

Permalink
fix: differ remove ssl key field (api7#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
bzp2010 authored May 6, 2024
1 parent c9be4d4 commit 4bf0d5b
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions apps/cli/src/differ/differv3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,10 @@ export class DifferV3 {
stream_routes: (remoteItem as ADCSDK.Service).stream_routes,
}
: resourceType === ADCSDK.ResourceType.CONSUMER_GROUP
? {
consumers: (remoteItem as ADCSDK.ConsumerGroup).consumers,
}
: {},
? {
consumers: (remoteItem as ADCSDK.ConsumerGroup).consumers,
}
: {},
this.defaultValue,
).map(this.postprocessSubEvent(remoteName, remoteId)),
});
Expand All @@ -328,6 +328,8 @@ export class DifferV3 {
// to identify locally added resources.
checkedRemoteId.push(remoteId);

const originalLocalItem = cloneDeep(localItem);

// For special handling of SSL resources, since neither APISIX nor
// API7 outputs certificate private keys in plaintext, the local
// and remote key fields should be removed, and the check item should
Expand Down Expand Up @@ -374,20 +376,20 @@ export class DifferV3 {
stream_routes: (localItem as ADCSDK.Service).stream_routes,
}
: resourceType === ADCSDK.ResourceType.CONSUMER_GROUP
? {
consumers: (localItem as ADCSDK.ConsumerGroup).consumers,
}
: {},
? {
consumers: (localItem as ADCSDK.ConsumerGroup).consumers,
}
: {},
resourceType === ADCSDK.ResourceType.SERVICE
? {
routes: (remoteItem as ADCSDK.Service).routes,
stream_routes: (remoteItem as ADCSDK.Service).stream_routes,
}
: resourceType === ADCSDK.ResourceType.CONSUMER_GROUP
? {
consumers: (remoteItem as ADCSDK.ConsumerGroup).consumers,
}
: {},
? {
consumers: (remoteItem as ADCSDK.ConsumerGroup).consumers,
}
: {},
this.defaultValue,
).map(this.postprocessSubEvent(remoteName, remoteId)),
);
Expand All @@ -409,7 +411,7 @@ export class DifferV3 {
});
}

let outputLocalItem: ADCSDK.Resource = cloneDeep(mergedLocalItem);
let outputLocalItem: ADCSDK.Resource = cloneDeep(originalLocalItem);
let outputRemoteItem: ADCSDK.Resource = cloneDeep(remoteItem);

// If the resource may contain plugin configurations, perform a
Expand Down Expand Up @@ -461,6 +463,7 @@ export class DifferV3 {
remote: outputRemoteItem,
realRemote: remoteItem,
realLocal: mergedLocalItem,
originalLocal: localItem,
transactionId: this.transactionId,
});

Expand Down Expand Up @@ -519,10 +522,10 @@ export class DifferV3 {
stream_routes: (localItem as ADCSDK.Service).stream_routes,
}
: resourceType === ADCSDK.ResourceType.CONSUMER_GROUP
? {
consumers: (localItem as ADCSDK.ConsumerGroup).consumers,
}
: {},
? {
consumers: (localItem as ADCSDK.ConsumerGroup).consumers,
}
: {},
{},
this.defaultValue,
).map(this.postprocessSubEvent(localName, localId)),
Expand Down

0 comments on commit 4bf0d5b

Please sign in to comment.