Skip to content

Commit d306277

Browse files
committed
support use custom temp upload oss endpoint
1 parent 3340466 commit d306277

3 files changed

Lines changed: 22 additions & 6 deletions

File tree

src/base.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import FC from './resources/fc';
1616
import { ICredentials } from '@serverless-devs/component-interface';
1717
import Role, { RamClient } from './resources/ram';
1818
import { TriggerType } from './interface/base';
19-
import { isAuto } from './utils';
19+
import { isAuto, isAppCenter } from './utils';
2020

2121
export default class Base {
2222
commands: any;
@@ -28,7 +28,12 @@ export default class Base {
2828

2929
// 在运行方法之前运行
3030
async handlePreRun(inputs: IInputs, needCredential: boolean) {
31-
log.debug(`input: ${JSON.stringify(inputs)}`);
31+
log.info(`userAgent: ${inputs.userAgent}`);
32+
if (isAppCenter()) {
33+
log.info(`input: ${JSON.stringify(inputs)}`);
34+
} else {
35+
log.debug(`input: ${JSON.stringify(inputs)}`);
36+
}
3237
// fc组件镜像 trim 左右空格
3338
const image = _.get(inputs, 'props.customContainerConfig.image');
3439
if (!_.isEmpty(image)) {

src/resources/fc/impl/replace-function-config.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ export default function (_local: any, _remote: any) {
9292
// 适配钩子函数配置
9393
if (!(_.isEmpty(local?.instanceLifecycleConfig) && _.isEmpty(remote?.instanceLifecycleConfig))) {
9494
const { initializer, preStop } = local.instanceLifecycleConfig || {};
95-
if (initializer?.handler && initializer?.command && !_.isEmpty(initializer?.command)) {
95+
if (initializer?.handler && initializer?.command && !_.isEmpty(initializer?.command)) {
9696
throw new Error(
9797
'fc3 pre check: command and handler can not be set at the same time in lifecycle Lifecycle.Initializer',
9898
);
9999
}
100-
if (preStop?.handler && preStop?.command && !_.isEmpty(preStop?.command)) {
100+
if (preStop?.handler && preStop?.command && !_.isEmpty(preStop?.command)) {
101101
throw new Error(
102102
'fc3 pre check: command and handler can not be set at the same time in lifecycle Lifecycle.PreStop',
103103
);
@@ -109,7 +109,11 @@ export default function (_local: any, _remote: any) {
109109
remote?.instanceLifecycleConfig?.initializer?.timeout
110110
) {
111111
if (initializer?.handler || (initializer?.command && !_.isEmpty(initializer.command))) {
112-
if (remote?.instanceLifecycleConfig?.initializer?.handler && (initializer?.command && !_.isEmpty(initializer.command))) {
112+
if (
113+
remote?.instanceLifecycleConfig?.initializer?.handler &&
114+
initializer?.command &&
115+
!_.isEmpty(initializer.command)
116+
) {
113117
_.set(local, 'instanceLifecycleConfig.initializer.handler', '');
114118
}
115119
if (remote?.instanceLifecycleConfig?.initializer?.command && initializer?.handler) {
@@ -134,7 +138,11 @@ export default function (_local: any, _remote: any) {
134138
remote?.instanceLifecycleConfig?.preStop?.timeout
135139
) {
136140
if (preStop?.handler || (preStop?.command && !_.isEmpty(preStop.command))) {
137-
if (remote?.instanceLifecycleConfig?.preStop?.handler && (preStop?.command && !_.isEmpty(preStop.command))) {
141+
if (
142+
remote?.instanceLifecycleConfig?.preStop?.handler &&
143+
preStop?.command &&
144+
!_.isEmpty(preStop.command)
145+
) {
138146
_.set(local, 'instanceLifecycleConfig.preStop.handler', '');
139147
}
140148
if (remote?.instanceLifecycleConfig?.preStop?.command && preStop?.handler) {

src/resources/fc/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,9 @@ export default class FC extends FC_Client {
377377
if (this.region === 'cn-heyuan-acdr-1') {
378378
ossEndpoint = `oss-${this.region}-internal.aliyuncs.com`;
379379
}
380+
if (process.env.FC_CODE_TEMP_OSS_ENDPOINT) {
381+
ossEndpoint = process.env.FC_CODE_TEMP_OSS_ENDPOINT;
382+
}
380383
logger.debug(`Uploading code to ${ossEndpoint}`);
381384

382385
const ossClient = new OSS({

0 commit comments

Comments
 (0)