Skip to content

Commit 7a2c54d

Browse files
authored
Merge pull request #58 from devsapp/fix-listTriggers
fix: listTriggers headers
2 parents bef307b + 2c37934 commit 7a2c54d

4 files changed

Lines changed: 53 additions & 6 deletions

File tree

src/commands-help/provision.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ Examples with CLI:
7474
'--ac, --always-allocate-cpu',
7575
'[Optional] Specify if always allocate CPU resources to the provisioned instances',
7676
],
77+
[
78+
'--ag, --always-allocate-gpu',
79+
'[Optional] Specify if always allocate GPU resources to the provisioned instances',
80+
],
7781
[
7882
'--scheduled-actions <json>',
7983
'[Optional] Set the configuration details of scheduled auto scaling.',

src/resources/fc/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,21 +617,30 @@ export default class FC extends FC_Client {
617617
}
618618
}
619619

620-
async listTriggers(functionName: string) {
620+
async listTriggers(
621+
functionName: string,
622+
disable_list_remote_eb_triggers: string,
623+
disable_list_remote_alb_triggers: string,
624+
) {
621625
let nextToken: string;
622626
const limit = 10;
623627
const triggers: any[] = [];
624628

625629
while (true) {
626630
const request = new ListTriggersRequest({ limit, nextToken });
627631
const runtime = new RuntimeOptions({});
628-
const headers = {};
632+
const headers = {
633+
'x-fc-disable-list-remote-eb-triggers': disable_list_remote_eb_triggers || 'false',
634+
'x-fc-disable-list-remote-alb-triggers': disable_list_remote_alb_triggers || 'false',
635+
};
636+
logger.info(`listTriggers headers: ${JSON.stringify(headers, null, 2)}`);
629637
const result = await this.fc20230330Client.listTriggersWithOptions(
630638
functionName,
631639
request,
632640
headers,
633641
runtime,
634642
);
643+
logger.info(`listTriggers result: ${JSON.stringify(result, null, 2)}`);
635644
const { body } = result.toMap();
636645
triggers.push(...body.triggers);
637646
if (!body.nextToken) {

src/subCommands/remove/index.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export default class Remove {
1717
private yes = false;
1818
private async_invoke_config: boolean;
1919
private resources: Record<string, any> = {};
20+
private disable_list_remote_eb_triggers: string;
21+
private disable_list_remote_alb_triggers: string;
2022

2123
private fcSdk: FC;
2224

@@ -26,7 +28,12 @@ export default class Remove {
2628
'assume-yes': 'y',
2729
},
2830
boolean: ['function', 'async_invoke_config'],
29-
string: ['function-name', 'region'],
31+
string: [
32+
'function-name',
33+
'region',
34+
'disable-list-remote-eb-triggers',
35+
'disable-list-remote-alb-triggers',
36+
],
3037
});
3138
logger.debug(`parse argv: ${JSON.stringify(opts)}`);
3239

@@ -37,10 +44,14 @@ export default class Remove {
3744
'assume-yes': yes,
3845
'function-name': functionName,
3946
'async-invoke-config': async_invoke_config,
47+
'disable-list-remote-eb-triggers': disable_list_remote_eb_triggers,
48+
'disable-list-remote-alb-triggers': disable_list_remote_alb_triggers,
4049
} = opts;
4150

4251
const removeAll = !needRemoveFunction && !trigger && !async_invoke_config;
4352
this.async_invoke_config = async_invoke_config;
53+
this.disable_list_remote_eb_triggers = disable_list_remote_eb_triggers;
54+
this.disable_list_remote_alb_triggers = disable_list_remote_alb_triggers;
4455

4556
this.region = region || _.get(inputs, 'props.region');
4657
logger.debug(`region: ${this.region}`);
@@ -261,7 +272,11 @@ export default class Remove {
261272
private async getTriggerResource() {
262273
let triggers = [];
263274
try {
264-
triggers = await this.fcSdk.listTriggers(this.functionName);
275+
triggers = await this.fcSdk.listTriggers(
276+
this.functionName,
277+
this.disable_list_remote_eb_triggers,
278+
this.disable_list_remote_alb_triggers,
279+
);
265280
} catch (ex) {
266281
logger.debug(
267282
`List function ${this.region}/${this.functionName} triggers error: ${ex.message}`,

src/subCommands/sync/index.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,26 @@ export default class Sync {
1616
private fcSdk: FC;
1717
private target: string;
1818
private qualifier: string;
19+
private disable_list_remote_eb_triggers: string;
20+
private disable_list_remote_alb_triggers: string;
1921

2022
constructor(private inputs: IInputs) {
2123
const {
2224
'target-dir': target,
2325
'function-name': functionName,
2426
qualifier,
2527
region,
28+
'disable-list-remote-eb-triggers': disable_list_remote_eb_triggers,
29+
'disable-list-remote-alb-triggers': disable_list_remote_alb_triggers,
2630
} = parseArgv(inputs.args, {
27-
string: ['target-dir', 'function-name', 'qualifier', 'region'],
31+
string: [
32+
'target-dir',
33+
'function-name',
34+
'qualifier',
35+
'region',
36+
'disable-list-remote-eb-triggers',
37+
'disable-list-remote-alb-triggers',
38+
],
2839
alias: { 'assume-yes': 'y' },
2940
});
3041

@@ -41,6 +52,10 @@ export default class Sync {
4152
checkRegion(this.region);
4253
this.functionName = functionName || _.get(inputs, 'props.functionName');
4354
logger.debug(`function name: ${this.functionName}`);
55+
this.disable_list_remote_eb_triggers = disable_list_remote_eb_triggers;
56+
logger.debug(`disable_list_remote_eb_triggers: ${disable_list_remote_eb_triggers}`);
57+
this.disable_list_remote_alb_triggers = disable_list_remote_alb_triggers;
58+
logger.debug(`disable_list_remote_alb_triggers: ${disable_list_remote_alb_triggers}`);
4459
if (!this.functionName) {
4560
throw new Error('Function name not specified, please specify --function-name');
4661
}
@@ -55,7 +70,11 @@ export default class Sync {
5570

5671
async getTriggers(): Promise<any[]> {
5772
const result: any[] = [];
58-
const triggers = await this.fcSdk.listTriggers(this.functionName);
73+
const triggers = await this.fcSdk.listTriggers(
74+
this.functionName,
75+
this.disable_list_remote_eb_triggers,
76+
this.disable_list_remote_alb_triggers,
77+
);
5978
logger.debug(triggers);
6079
for (const t of triggers) {
6180
const { triggerName, triggerType, description, qualifier, invocationRole, sourceArn } = t;

0 commit comments

Comments
 (0)