Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:implement license id scheme (#4413)
* feat:implement license id scheme Signed-off-by: jingyang <3161362058@qq.com> * add nocluster active Signed-off-by: jingyang <3161362058@qq.com> * fix active cluster Signed-off-by: jingyang <3161362058@qq.com> --------- Signed-off-by: jingyang <3161362058@qq.com>
- Loading branch information
Showing
59 changed files
with
2,294 additions
and
1,005 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
frontend/providers/license/src/pages/api/platform/getClusterId.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { authSession } from '@/services/backend/auth'; | ||
import { K8sApiDefault, getK8s } from '@/services/backend/kubernetes'; | ||
import { jsonRes } from '@/services/backend/response'; | ||
import { ApiResp } from '@/services/kubernet'; | ||
import * as k8s from '@kubernetes/client-node'; | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResp>) { | ||
try { | ||
const { namespace } = await getK8s({ | ||
kubeconfig: await authSession(req) | ||
}); | ||
|
||
const defaultKc = K8sApiDefault(); | ||
|
||
const result = await defaultKc.makeApiClient(k8s.CoreV1Api).readNamespace('kube-system'); | ||
|
||
const systemId = result?.body?.metadata?.uid?.substring(0, 8); | ||
|
||
jsonRes(res, { | ||
data: { | ||
systemId: systemId | ||
} | ||
}); | ||
} catch (err: any) { | ||
jsonRes(res, { | ||
code: 500, | ||
error: err | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
frontend/providers/license/src/services/backend/kubernetes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,29 @@ | ||
import { GET, POST } from '@/services/request'; | ||
import { CreateClusterParams, ClusterDB, ClusterType, ClusterResult } from '@/types'; | ||
import { ActiveClusterParams } from '@/pages/api/cluster/activeCluster'; | ||
import { DELETE, GET, POST } from '@/services/request'; | ||
import { ClusterResult, CreateClusterParams } from '@/types'; | ||
|
||
export const createCluster = (payload: { type: ClusterType }) => | ||
POST('/api/cluster/create', payload); | ||
export const createCluster = (payload: CreateClusterParams) => POST('/api/cluster/create', payload); | ||
|
||
export const createClusterAndLicense = (payload: CreateClusterParams) => | ||
POST('/api/cluster/clusterAndLicense', payload); | ||
|
||
export const getClusterRecord = ({ page, pageSize }: { page: number; pageSize: number }) => | ||
POST<{ total: number; records: ClusterDB[] }>('/api/cluster/getRecord', { | ||
export const getClusterList = ({ page, pageSize }: { page: number; pageSize: number }) => | ||
POST<{ total: number; records: ClusterResult[] }>('/api/cluster/getClusterList', { | ||
page, | ||
pageSize | ||
}); | ||
|
||
export const findClusterById = (payload: { clusterId: string }) => | ||
GET<ClusterResult>('/api/cluster/findById', payload); | ||
|
||
export const updateClusterName = (payload: { clusterId: string; displayName: string }) => | ||
POST<ClusterResult>('/api/cluster/updateName', payload); | ||
|
||
export const deleteClusterById = (payload: { clusterId: string }) => | ||
DELETE<ClusterResult>('/api/cluster/delete', payload); | ||
|
||
export const isKubeSystemIDBound = (id: string) => | ||
GET<{ isBound: boolean }>('/api/cluster/isBound', { kubeSystemID: id }); | ||
|
||
export const activeClusterBySystemId = (payload: ActiveClusterParams) => | ||
POST<ClusterResult>('/api/cluster/activeCluster', payload); | ||
|
||
export const findClusterBySystemId = (payload: { systemId: string }) => | ||
GET<ClusterResult>('/api/cluster/findBySystemId', payload); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Icon, IconProps } from '@chakra-ui/react'; | ||
export const LeftIcon = (props: IconProps) => { | ||
return ( | ||
<Icon | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="20px" | ||
height="20px" | ||
viewBox="0 0 20 20" | ||
fill="#24282C" | ||
{...props} | ||
> | ||
<path d="M12.25 17.5832L5.22917 10.5832C5.14583 10.4998 5.08694 10.4096 5.0525 10.3123C5.0175 10.2151 5 10.1109 5 9.99984C5 9.88873 5.0175 9.78456 5.0525 9.68734C5.08694 9.59012 5.14583 9.49984 5.22917 9.4165L12.25 2.39567C12.4444 2.20123 12.6875 2.104 12.9792 2.104C13.2708 2.104 13.5208 2.20817 13.7292 2.4165C13.9375 2.62484 14.0417 2.86789 14.0417 3.14567C14.0417 3.42345 13.9375 3.6665 13.7292 3.87484L7.60417 9.99984L13.7292 16.1248C13.9236 16.3193 14.0208 16.5587 14.0208 16.8432C14.0208 17.1282 13.9167 17.3748 13.7083 17.5832C13.5 17.7915 13.2569 17.8957 12.9792 17.8957C12.7014 17.8957 12.4583 17.7915 12.25 17.5832Z" /> | ||
</Icon> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Icon, IconProps } from '@chakra-ui/react'; | ||
export const TimeIcon = (props: IconProps) => { | ||
return ( | ||
<Icon | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="16px" | ||
height="17px" | ||
viewBox="0 0 16 17" | ||
{...props} | ||
> | ||
<g clipPath="url(#clip0_877_36741)"> | ||
<path | ||
d="M7.99992 1.8335C11.6819 1.8335 14.6666 4.81816 14.6666 8.50016C14.6666 12.1822 11.6819 15.1668 7.99992 15.1668C4.31792 15.1668 1.33325 12.1822 1.33325 8.50016C1.33325 4.81816 4.31792 1.8335 7.99992 1.8335ZM7.99992 3.16683C6.58543 3.16683 5.22888 3.72873 4.22868 4.72893C3.22849 5.72912 2.66659 7.08567 2.66659 8.50016C2.66659 9.91465 3.22849 11.2712 4.22868 12.2714C5.22888 13.2716 6.58543 13.8335 7.99992 13.8335C9.41441 13.8335 10.771 13.2716 11.7712 12.2714C12.7713 11.2712 13.3333 9.91465 13.3333 8.50016C13.3333 7.08567 12.7713 5.72912 11.7712 4.72893C10.771 3.72873 9.41441 3.16683 7.99992 3.16683ZM7.99992 4.50016C8.16321 4.50018 8.32081 4.56013 8.44283 4.66864C8.56486 4.77715 8.64281 4.92666 8.66192 5.08883L8.66658 5.16683V8.22416L10.4713 10.0288C10.5908 10.1488 10.6602 10.3098 10.6654 10.4791C10.6706 10.6484 10.6111 10.8133 10.4991 10.9403C10.3871 11.0674 10.2309 11.147 10.0623 11.1631C9.89365 11.1792 9.72525 11.1304 9.59125 11.0268L9.52858 10.9715L7.52858 8.9715C7.42497 8.86779 7.35843 8.73283 7.33925 8.5875L7.33325 8.50016V5.16683C7.33325 4.99002 7.40349 4.82045 7.52851 4.69542C7.65354 4.5704 7.82311 4.50016 7.99992 4.50016Z" | ||
fill="#8172D8" | ||
/> | ||
</g> | ||
<defs> | ||
<clipPath id="clip0_877_36741"> | ||
<rect width="16" height="16" fill="white" transform="translate(0 0.5)" /> | ||
</clipPath> | ||
</defs> | ||
</Icon> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.