Skip to content

Commit

Permalink
fix(costcenter): transfer error (#4010)
Browse files Browse the repository at this point in the history
  • Loading branch information
xudaotutou authored Sep 27, 2023
1 parent cb91077 commit cd43d4b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default async function handler(req: NextApiRequest, resp: NextApiResponse
if (kube_user === null) {
return jsonRes(resp, { code: 404, message: 'user not found' });
}
const kube_namespace = kc.getContexts()[0].namespace;
// get payment crd
type paymentStatus = {
tradeNo: string;
Expand All @@ -31,7 +30,7 @@ export default async function handler(req: NextApiRequest, resp: NextApiResponse

const paymentM = {
...paymentMeta,
namespace: kube_namespace || GetUserDefaultNameSpace(kube_user.name)
namespace: GetUserDefaultNameSpace(kube_user.name)
};
const paymentDesc = await GetCRD(kc, paymentM, id);
//@ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default async function handler(req: NextApiRequest, resp: NextApiResponse
return jsonRes(resp, { code: 401, message: 'user not found' });
}

const namespace = kc.getContexts()[0].namespace || GetUserDefaultNameSpace(kubeUser.name);
const namespace = GetUserDefaultNameSpace(kubeUser.name);
const name = to + '-' + getTime(new Date());
const transferCRD = generateTransferCrd({
to,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default async function handler(req: NextApiRequest, resp: NextApiResponse
if (user === null) {
return jsonRes(resp, { code: 403, message: 'user null' });
}
const namespace = GetUserDefaultNameSpace(user.name);
const namespace = kc.getContexts()[0].namespace || GetUserDefaultNameSpace(user.name);
const name = new Date().getTime() + 'appquery';
const crdSchema = {
apiVersion: `account.sealos.io/v1`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { authSession } from '@/service/backend/auth';
import { CRDMeta, GetCRD } from '@/service/backend/kubernetes';
import { CRDMeta, GetCRD, GetUserDefaultNameSpace } from '@/service/backend/kubernetes';
import { jsonRes } from '@/service/backend/response';
import type { NextApiRequest, NextApiResponse } from 'next';
import { ApplyYaml } from '@/service/backend/kubernetes';
Expand Down Expand Up @@ -44,7 +44,8 @@ export default async function handler(req: NextApiRequest, resp: NextApiResponse
if (user === null) {
return jsonRes(resp, { code: 403, message: 'user null' });
}
const namespace = kc.getContexts()[0].namespace || 'ns-' + user.name;
// 要和kc保持一致
const namespace = kc.getContexts()[0].namespace || GetUserDefaultNameSpace(user.name);
const name = new Date().getTime() + 'namespacequery';
const crdSchema = {
apiVersion: `account.sealos.io/v1`,
Expand Down
4 changes: 2 additions & 2 deletions frontend/providers/costcenter/src/pages/api/billing/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { authSession } from '@/service/backend/auth';
import { CRDMeta, GetCRD } from '@/service/backend/kubernetes';
import { CRDMeta, GetCRD, GetUserDefaultNameSpace } from '@/service/backend/kubernetes';
import { jsonRes } from '@/service/backend/response';
import type { NextApiRequest, NextApiResponse } from 'next';
import { ApplyYaml } from '@/service/backend/kubernetes';
Expand Down Expand Up @@ -42,7 +42,7 @@ export default async function handler(req: NextApiRequest, resp: NextApiResponse
if (user === null) {
return jsonRes(resp, { code: 403, message: 'user null' });
}
const namespace = 'ns-' + user.name;
const namespace = GetUserDefaultNameSpace(user.name);
const body = req.body;
let spec: BillingSpec = body.spec;
if (!spec) {
Expand Down

0 comments on commit cd43d4b

Please sign in to comment.