Skip to content

Commit 8a0184b

Browse files
committed
fix(scf): auto release
1 parent 4c2df40 commit 8a0184b

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

__tests__/cdn.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { CdnDeployInputs } from './../src/modules/cdn/interface';
22
import { Cdn } from '../src';
3-
import { getCdnByDomain } from '../src/modules/cdn/utils';
3+
import { getCdnByDomain, openCdnService } from '../src/modules/cdn/utils';
44
import { sleep } from '@ygkit/request';
55

66
describe('Cdn', () => {
@@ -42,6 +42,12 @@ describe('Cdn', () => {
4242
};
4343
const cdn = new Cdn(credentials);
4444

45+
test('openCdnService', async () => {
46+
await openCdnService(cdn.capi);
47+
48+
expect(true).toEqual(true);
49+
});
50+
4551
test('should deploy CDN success with originType = cos', async () => {
4652
await sleep(5000);
4753
const res = await cdn.deploy(inputs);

src/modules/apigw/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default class Apigw {
8686
environment = 'release' as const,
8787
oldState = {},
8888
isInputServiceId = false,
89-
isAutoRelease = false,
89+
isAutoRelease = true,
9090
} = inputs;
9191
if (isInputServiceId) {
9292
return this.deployWIthInputServiceId(inputs as ApigwDeployWithServiceIdInputs);
@@ -112,7 +112,7 @@ export default class Apigw {
112112
environment,
113113
});
114114

115-
if (!isAutoRelease) {
115+
if (isAutoRelease) {
116116
await this.service.release({ serviceId, environment });
117117
}
118118

@@ -246,7 +246,7 @@ export default class Apigw {
246246
environment,
247247
});
248248

249-
if (!isAutoRelease) {
249+
if (isAutoRelease) {
250250
await this.service.release({ serviceId, environment });
251251
}
252252

src/modules/cdn/utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,14 @@ export async function openCdnService(capi: Capi) {
123123
PayTypeMainland: 'flux',
124124
PayTypeOverseas: 'flux',
125125
});
126+
return true;
126127
} catch (e) {
127-
if (e.code !== 'ResourceInUse.CdnUserExists') {
128+
if (
129+
e.code !== 'ResourceInUse.CdnUserExists' &&
130+
e.code !== 'UnauthorizedOperation.OperationTooOften'
131+
) {
128132
throw e;
129133
}
134+
return false;
130135
}
131136
}

0 commit comments

Comments
 (0)