Skip to content

Commit

Permalink
perf: form args
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu committed Aug 18, 2023
1 parent 46a5640 commit 112a5cd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 1 addition & 2 deletions frontend/providers/applaunchpad/src/pages/app/edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ const EditApp = ({ appName, tabType }: { appName?: string; tabType: string }) =>
crYamlList: crOldYamls.current,
newYamlList: yamls
});
// console.log(patch, '-=-=-');
// return setIsLoading(false);

await putApp({
patch,
appName,
Expand Down
5 changes: 4 additions & 1 deletion frontend/providers/applaunchpad/src/utils/adapt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ export const adaptAppDetail = (configs: DeployKindsType[]): AppDetailType => {
appDeploy.spec?.template?.spec?.containers?.[0]?.image ||
'',
runCMD: appDeploy.spec?.template?.spec?.containers?.[0]?.command?.join(' ') || '',
cmdParam: appDeploy.spec?.template?.spec?.containers?.[0]?.args?.join(' ') || '',
cmdParam:
(appDeploy.spec?.template?.spec?.containers?.[0]?.args?.length === 1
? appDeploy.spec?.template?.spec?.containers?.[0]?.args.join(' ')
: JSON.stringify(appDeploy.spec?.template?.spec?.containers?.[0]?.args)) || '',
replicas: appDeploy.spec?.replicas || 0,
cpu: cpuFormatToM(
appDeploy.spec?.template?.spec?.containers?.[0]?.resources?.limits?.cpu || '0'
Expand Down
11 changes: 9 additions & 2 deletions frontend/providers/applaunchpad/src/utils/deployYaml2Json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,19 @@ export const json2DeployCr = (data: AppEditType, type: 'deployment' | 'statefuls
command: (() => {
if (!data.runCMD) return undefined;
try {
return JSON.stringify(JSON.parse(data.runCMD));
return JSON.parse(data.runCMD);
} catch (error) {
return data.runCMD.split(' ').filter((item) => item);
}
})(),
args: data.cmdParam ? [data.cmdParam] : undefined,
args: (() => {
if (!data.cmdParam) return undefined;
try {
return JSON.parse(data.cmdParam) as string[];
} catch (error) {
return [data.cmdParam];
}
})(),
ports: [
{
containerPort: str2Num(data.containerOutPort)
Expand Down

0 comments on commit 112a5cd

Please sign in to comment.