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

* 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>
pull/6862/head
itsconquest 2022-04-29 09:44:34 +12:00 committed by GitHub
parent 8a6024ce9b
commit b1b0a76465
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 14 deletions

View File

@ -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}

View File

@ -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(

View File

@ -21,13 +21,12 @@ export function useCopy(copyText: string, fadeDelay = 1000) {
navigator.clipboard.writeText(copyText);
} else {
// https://stackoverflow.com/a/57192718
const inputEl = document.createElement('input');
const inputEl = document.createElement('textarea');
inputEl.value = copyText;
inputEl.type = 'text';
document.body.appendChild(inputEl);
inputEl.select();
document.execCommand('copy');
inputEl.type = 'hidden';
inputEl.hidden = true;
document.body.removeChild(inputEl);
}
setCopiedSuccessfully(true);

View File

@ -1,7 +1,8 @@
.code {
display: block;
white-space: pre-wrap;
padding: 16px 90px;
word-break: break-word;
padding: 20px;
}
.root {