Skip to content

Commit

Permalink
fix(deploy): IMPORTANT!fix deploy apply bugs(missing appid);
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Sep 10, 2021
1 parent 9a90a6b commit 41ddbfb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions packages/system-server/src/api/function.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Author: Maslow<wangfugen@126.com>
* @Date: 2021-07-30 10:30:29
* @LastEditTime: 2021-09-09 17:59:42
* @LastEditTime: 2021-09-10 11:43:37
* @Description:
*/

Expand Down Expand Up @@ -100,7 +100,7 @@ function compileFunction(func: any) {
/**
* Deploy functions which pushed from remote environment
*/
export async function deployFunctions(functions: FunctionStruct[]) {
export async function deployFunctions(appid: string, functions: FunctionStruct[]) {
assert.ok(functions)
assert.ok(functions instanceof Array)

Expand All @@ -112,6 +112,7 @@ export async function deployFunctions(functions: FunctionStruct[]) {
try {
await session.withTransaction(async () => {
for (const func of data) {
func['appid'] = appid
await _deployOneFunction(func, session)
}
})
Expand Down
5 changes: 3 additions & 2 deletions packages/system-server/src/api/policy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Author: Maslow<wangfugen@126.com>
* @Date: 2021-07-30 10:30:29
* @LastEditTime: 2021-09-10 00:42:48
* @LastEditTime: 2021-09-10 11:44:11
* @Description:
*/

Expand Down Expand Up @@ -75,7 +75,7 @@ export async function publishAccessPolicies(app: ApplicationStruct) {
/**
* Deploy policies which pushed from remote environment
*/
export async function deployPolicies(policies: PolicyStruct[]) {
export async function deployPolicies(appid: string, policies: PolicyStruct[]) {
assert.ok(policies)
assert.ok(policies instanceof Array)

Expand All @@ -87,6 +87,7 @@ export async function deployPolicies(policies: PolicyStruct[]) {
try {
await session.withTransaction(async () => {
for (const item of data) {
item['appid'] = appid
await _deployOnePolicy(item, session)
}
})
Expand Down
7 changes: 3 additions & 4 deletions packages/system-server/src/router/deploy/request.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Author: Maslow<wangfugen@126.com>
* @Date: 2021-09-06 15:47:57
* @LastEditTime: 2021-09-10 00:42:56
* @LastEditTime: 2021-09-10 11:49:07
* @Description:
*/

Expand Down Expand Up @@ -109,7 +109,6 @@ export async function handleApplyDeployRequest(req: Request, res: Response) {
return res.status(code).send()
}


const db = DatabaseAgent.sys_db
const { data: deploy_request } = await db.collection(Constants.cn.deploy_requests)
.where({ _id: req_id, appid: app.appid })
Expand All @@ -127,13 +126,13 @@ export async function handleApplyDeployRequest(req: Request, res: Response) {

// deploy functions
if (type === 'function') {
await deployFunctions(deploy_request.data)
await deployFunctions(app.appid, deploy_request.data)
await publishFunctions(app)
}

// deploy policies
if (type === 'policy') {
await deployPolicies(deploy_request.data)
await deployPolicies(app.appid, deploy_request.data)
await publishAccessPolicies(app)
}

Expand Down

0 comments on commit 41ddbfb

Please sign in to comment.