Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/commands-help/provision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ Examples with CLI:
'--ac, --always-allocate-cpu',
'[Optional] Specify if always allocate CPU resources to the provisioned instances',
],
[
'--ag, --always-allocate-gpu',
'[Optional] Specify if always allocate GPU resources to the provisioned instances',
],
[
'--scheduled-actions <json>',
'[Optional] Set the configuration details of scheduled auto scaling.',
Expand Down
13 changes: 11 additions & 2 deletions src/resources/fc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,21 +617,30 @@ export default class FC extends FC_Client {
}
}

async listTriggers(functionName: string) {
async listTriggers(
functionName: string,
disable_list_remote_eb_triggers: string,
disable_list_remote_alb_triggers: string,
) {
let nextToken: string;
const limit = 10;
const triggers: any[] = [];

while (true) {
const request = new ListTriggersRequest({ limit, nextToken });
const runtime = new RuntimeOptions({});
const headers = {};
const headers = {
'x-fc-disable-list-remote-eb-triggers': disable_list_remote_eb_triggers || 'false',
'x-fc-disable-list-remote-alb-triggers': disable_list_remote_alb_triggers || 'false',
};
logger.info(`listTriggers headers: ${JSON.stringify(headers, null, 2)}`);
const result = await this.fc20230330Client.listTriggersWithOptions(
functionName,
request,
headers,
runtime,
);
logger.info(`listTriggers result: ${JSON.stringify(result, null, 2)}`);
const { body } = result.toMap();
triggers.push(...body.triggers);
if (!body.nextToken) {
Expand Down
19 changes: 17 additions & 2 deletions src/subCommands/remove/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export default class Remove {
private yes = false;
private async_invoke_config: boolean;
private resources: Record<string, any> = {};
private disable_list_remote_eb_triggers: string;
private disable_list_remote_alb_triggers: string;

private fcSdk: FC;

Expand All @@ -26,7 +28,12 @@ export default class Remove {
'assume-yes': 'y',
},
boolean: ['function', 'async_invoke_config'],
string: ['function-name', 'region'],
string: [
'function-name',
'region',
'disable-list-remote-eb-triggers',
'disable-list-remote-alb-triggers',
],
});
logger.debug(`parse argv: ${JSON.stringify(opts)}`);

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

const removeAll = !needRemoveFunction && !trigger && !async_invoke_config;
this.async_invoke_config = async_invoke_config;
this.disable_list_remote_eb_triggers = disable_list_remote_eb_triggers;
this.disable_list_remote_alb_triggers = disable_list_remote_alb_triggers;

this.region = region || _.get(inputs, 'props.region');
logger.debug(`region: ${this.region}`);
Expand Down Expand Up @@ -261,7 +272,11 @@ export default class Remove {
private async getTriggerResource() {
let triggers = [];
try {
triggers = await this.fcSdk.listTriggers(this.functionName);
triggers = await this.fcSdk.listTriggers(
this.functionName,
this.disable_list_remote_eb_triggers,
this.disable_list_remote_alb_triggers,
);
} catch (ex) {
logger.debug(
`List function ${this.region}/${this.functionName} triggers error: ${ex.message}`,
Expand Down
23 changes: 21 additions & 2 deletions src/subCommands/sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,26 @@ export default class Sync {
private fcSdk: FC;
private target: string;
private qualifier: string;
private disable_list_remote_eb_triggers: string;
private disable_list_remote_alb_triggers: string;

constructor(private inputs: IInputs) {
const {
'target-dir': target,
'function-name': functionName,
qualifier,
region,
'disable-list-remote-eb-triggers': disable_list_remote_eb_triggers,
'disable-list-remote-alb-triggers': disable_list_remote_alb_triggers,
} = parseArgv(inputs.args, {
string: ['target-dir', 'function-name', 'qualifier', 'region'],
string: [
'target-dir',
'function-name',
'qualifier',
'region',
'disable-list-remote-eb-triggers',
'disable-list-remote-alb-triggers',
],
alias: { 'assume-yes': 'y' },
});

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

async getTriggers(): Promise<any[]> {
const result: any[] = [];
const triggers = await this.fcSdk.listTriggers(this.functionName);
const triggers = await this.fcSdk.listTriggers(
this.functionName,
this.disable_list_remote_eb_triggers,
this.disable_list_remote_alb_triggers,
);
logger.debug(triggers);
for (const t of triggers) {
const { triggerName, triggerType, description, qualifier, invocationRole, sourceArn } = t;
Expand Down