fix(endpoints): Change syntax for multi-line commands in Windows (#1355)

Co-authored-by: Shawn <host@shawnsg.dev>
This commit is contained in:
Chaim Lev-Ari
2025-11-18 08:48:32 +02:00
committed by GitHub
parent e59d4dea77
commit e73d07281c
4 changed files with 1160 additions and 108 deletions
@@ -1,22 +1,119 @@
import { buildLinuxPodmanCommand } from './scripts';
import {
buildLinuxPodmanCommand,
buildLinuxStandaloneCommand,
buildLinuxSwarmCommand,
buildLinuxKubernetesCommand,
buildWindowsStandaloneCommand,
buildWindowsSwarmCommand,
} from './scripts';
import { ScriptFormValues } from './types';
describe('buildLinuxPodmanCommand', () => {
const defaultProperties: ScriptFormValues = {
allowSelfSignedCertificates: false,
authEnabled: false,
edgeGroupsIds: [],
edgeIdGenerator: '',
envVars: '',
group: 0,
os: 'linux',
platform: 'podman',
tagsIds: [],
tlsEnabled: false,
};
describe.each([
{
name: 'buildLinuxStandaloneCommand',
builder: buildLinuxStandaloneCommand,
defaultProperties: {
allowSelfSignedCertificates: false,
authEnabled: false,
edgeGroupsIds: [],
edgeIdGenerator: '',
envVars: '',
group: 0,
os: 'linux' as const,
platform: 'standalone' as const,
tagsIds: [],
tlsEnabled: false,
},
edgeIdGeneratorValue: 'uuidgen',
},
{
name: 'buildLinuxPodmanCommand',
builder: buildLinuxPodmanCommand,
defaultProperties: {
allowSelfSignedCertificates: false,
authEnabled: false,
edgeGroupsIds: [],
edgeIdGenerator: '',
envVars: '',
group: 0,
os: 'linux' as const,
platform: 'podman' as const,
tagsIds: [],
tlsEnabled: false,
},
edgeIdGeneratorValue: 'uuidgen',
},
{
name: 'buildLinuxSwarmCommand',
builder: buildLinuxSwarmCommand,
defaultProperties: {
allowSelfSignedCertificates: false,
authEnabled: false,
edgeGroupsIds: [],
edgeIdGenerator: '',
envVars: '',
group: 0,
os: 'linux' as const,
platform: 'swarm' as const,
tagsIds: [],
tlsEnabled: false,
},
edgeIdGeneratorValue: 'uuidgen',
},
{
name: 'buildLinuxKubernetesCommand',
builder: buildLinuxKubernetesCommand,
defaultProperties: {
allowSelfSignedCertificates: false,
authEnabled: false,
edgeGroupsIds: [],
edgeIdGenerator: '',
envVars: '',
group: 0,
os: 'linux' as const,
platform: 'k8s' as const,
tagsIds: [],
tlsEnabled: false,
},
edgeIdGeneratorValue: 'uuidgen',
},
{
name: 'buildWindowsStandaloneCommand',
builder: buildWindowsStandaloneCommand,
defaultProperties: {
allowSelfSignedCertificates: false,
authEnabled: false,
edgeGroupsIds: [],
edgeIdGenerator: '',
envVars: '',
group: 0,
os: 'win' as const,
platform: 'standalone' as const,
tagsIds: [],
tlsEnabled: false,
},
edgeIdGeneratorValue: 'Get-MachineGUID',
},
{
name: 'buildWindowsSwarmCommand',
builder: buildWindowsSwarmCommand,
defaultProperties: {
allowSelfSignedCertificates: false,
authEnabled: false,
edgeGroupsIds: [],
edgeIdGenerator: '',
envVars: '',
group: 0,
os: 'win' as const,
platform: 'swarm' as const,
tagsIds: [],
tlsEnabled: false,
},
edgeIdGeneratorValue: 'Get-MachineGUID',
},
])('$name', ({ builder, defaultProperties, edgeIdGeneratorValue }) => {
it('should generate basic command with minimal configuration', () => {
const command = buildLinuxPodmanCommand(
const command = builder(
'2.19.0',
'test-edge-key',
defaultProperties,
@@ -29,11 +126,11 @@ describe('buildLinuxPodmanCommand', () => {
});
it('should generate command with async mode enabled', () => {
const command = buildLinuxPodmanCommand(
const command = builder(
'2.19.0',
'test-edge-key',
defaultProperties,
true, // async mode
true,
'test-edge-id',
'test-secret'
);
@@ -42,12 +139,12 @@ describe('buildLinuxPodmanCommand', () => {
});
it('should generate command with self-signed certificates allowed', () => {
const properties = {
const properties: ScriptFormValues = {
...defaultProperties,
allowSelfSignedCertificates: true,
};
const command = buildLinuxPodmanCommand(
const command = builder(
'2.19.0',
'test-edge-key',
properties,
@@ -60,17 +157,17 @@ describe('buildLinuxPodmanCommand', () => {
});
it('should generate command with edge ID generator', () => {
const properties = {
const properties: ScriptFormValues = {
...defaultProperties,
edgeIdGenerator: 'uuidgen',
edgeIdGenerator: edgeIdGeneratorValue,
};
const command = buildLinuxPodmanCommand(
const command = builder(
'2.19.0',
'test-edge-key',
properties,
false,
undefined, // no edgeId when using generator
undefined,
'test-secret'
);
@@ -78,12 +175,12 @@ describe('buildLinuxPodmanCommand', () => {
});
it('should generate command with custom environment variables', () => {
const properties = {
const properties: ScriptFormValues = {
...defaultProperties,
envVars: 'MY_VAR=value1,ANOTHER_VAR=value2',
};
const command = buildLinuxPodmanCommand(
const command = builder(
'2.19.0',
'test-edge-key',
properties,
@@ -96,12 +193,12 @@ describe('buildLinuxPodmanCommand', () => {
});
it('should generate command with edge groups', () => {
const properties = {
const properties: ScriptFormValues = {
...defaultProperties,
edgeGroupsIds: [1, 2, 3],
};
const command = buildLinuxPodmanCommand(
const command = builder(
'2.19.0',
'test-edge-key',
properties,
@@ -114,12 +211,12 @@ describe('buildLinuxPodmanCommand', () => {
});
it('should generate command with portainer group', () => {
const properties = {
const properties: ScriptFormValues = {
...defaultProperties,
group: 5,
};
const command = buildLinuxPodmanCommand(
const command = builder(
'2.19.0',
'test-edge-key',
properties,
@@ -132,12 +229,12 @@ describe('buildLinuxPodmanCommand', () => {
});
it('should generate command with tags', () => {
const properties = {
const properties: ScriptFormValues = {
...defaultProperties,
tagsIds: [10, 20, 30],
};
const command = buildLinuxPodmanCommand(
const command = builder(
'2.19.0',
'test-edge-key',
properties,
@@ -150,14 +247,14 @@ describe('buildLinuxPodmanCommand', () => {
});
it('should generate command with all meta variables', () => {
const properties = {
const properties: ScriptFormValues = {
...defaultProperties,
edgeGroupsIds: [1, 2],
group: 5,
tagsIds: [10, 20],
};
const command = buildLinuxPodmanCommand(
const command = builder(
'2.19.0',
'test-edge-key',
properties,
@@ -170,7 +267,7 @@ describe('buildLinuxPodmanCommand', () => {
});
it('should generate command without agent secret', () => {
const command = buildLinuxPodmanCommand(
const command = builder(
'2.19.0',
'test-edge-key',
defaultProperties,
@@ -183,7 +280,7 @@ describe('buildLinuxPodmanCommand', () => {
});
it('should generate command with empty agent secret', () => {
const command = buildLinuxPodmanCommand(
const command = builder(
'2.19.0',
'test-edge-key',
defaultProperties,