fix(edge): fix formatting of scripts for release [EE-2987] (#6785)

* fix(edge) fix formatting for release [EE-2987]

* fix(edge) EE-2987 fix edge agent command formatting

Co-authored-by: Simon Meng <simon.meng@portainer.io>
This commit is contained in:
itsconquest
2022-04-29 09:44:30 +12:00
committed by GitHub
parent 8471d2ae26
commit 5e25f8fe7d
4 changed files with 12 additions and 14 deletions
@@ -5,7 +5,7 @@ import { r2a } from '@/react-tools/react2angular';
import { useSettings } from '@/portainer/settings/settings.service';
import { EdgePropertiesForm } from './EdgePropertiesForm';
import { Scripts } from './Scripts';
import { ScriptTabs } from './ScriptTabs';
import { EdgeProperties } from './types';
interface Props {
@@ -43,7 +43,7 @@ export function EdgeScriptForm({ edgeKey, edgeId }: Props) {
hideIdGetter={edgeId !== undefined}
/>
<Scripts
<ScriptTabs
values={edgeProperties}
agentVersion={agentVersion}
edgeKey={edgeKey}
@@ -49,7 +49,7 @@ interface Props {
onPlatformChange(platform: Platform): void;
}
export function Scripts({
export function ScriptTabs({
agentVersion,
values,
edgeKey,
@@ -134,7 +134,7 @@ function buildLinuxStandaloneCommand(
)
);
return `${edgeIdScript ? `PORTAINER_EDGE_ID=$(${edgeIdScript}) \n\n` : ''}
return `${edgeIdScript ? `PORTAINER_EDGE_ID=$(${edgeIdScript}) \n\n` : ''}\
docker run -d \\
-v /var/run/docker.sock:/var/run/docker.sock \\
-v /var/lib/docker/volumes:/var/lib/docker/volumes \\
@@ -168,7 +168,7 @@ function buildWindowsStandaloneCommand(
return `${
edgeIdScript ? `$Env:PORTAINER_EDGE_ID = "@(${edgeIdScript})" \n\n` : ''
}
}\
docker run -d \\
--mount type=npipe,src=\\\\.\\pipe\\docker_engine,dst=\\\\.\\pipe\\docker_engine \\
--mount type=bind,src=C:\\ProgramData\\docker\\volumes,dst=C:\\ProgramData\\docker\\volumes \\
@@ -199,7 +199,7 @@ function buildLinuxSwarmCommand(
'AGENT_CLUSTER_ADDR=tasks.portainer_edge_agent',
]);
return `${edgeIdScript ? `PORTAINER_EDGE_ID=$(${edgeIdScript}) \n\n` : ''}
return `${edgeIdScript ? `PORTAINER_EDGE_ID=$(${edgeIdScript}) \n\n` : ''}\
docker network create \\
--driver overlay \\
portainer_agent_network;
@@ -270,13 +270,11 @@ function buildKubernetesCommand(
const idEnvVar = edgeIdScript
? `PORTAINER_EDGE_ID=$(${edgeIdScript}) \n\n`
: '';
const envVarsTrimmed = envVars.trim();
const edgeIdVar = !edgeIdScript && edgeId ? edgeId : '$PORTAINER_EDGE_ID';
const selfSigned = allowSelfSignedCerts ? '1' : '0';
return `${idEnvVar}curl https://downloads.portainer.io/ce${agentShortVersion}/portainer-edge-agent-setup.sh |
bash -s -- "${edgeIdVar}" \\
"${edgeKey}" \\
"${selfSigned}" "${agentSecret}" "${envVars}"`;
return `${idEnvVar}curl https://downloads.portainer.io/ce${agentShortVersion}/portainer-edge-agent-setup.sh | bash -s -- "${edgeIdVar}" "${edgeKey}" "${selfSigned}" "${agentSecret}" "${envVarsTrimmed}"`;
}
function buildDefaultEnvVars(