mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 00:14:34 +00:00
Config: newline-join sandbox setupCommand arrays (#31953)
This commit is contained in:
@@ -7,6 +7,26 @@ import {
|
||||
import { validateConfigObject } from "./config.js";
|
||||
|
||||
describe("sandbox docker config", () => {
|
||||
it("joins setupCommand arrays with newlines", () => {
|
||||
const res = validateConfigObject({
|
||||
agents: {
|
||||
defaults: {
|
||||
sandbox: {
|
||||
docker: {
|
||||
setupCommand: ["apt-get update", "apt-get install -y curl"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(res.ok).toBe(true);
|
||||
if (res.ok) {
|
||||
expect(res.config.agents?.defaults?.sandbox?.docker?.setupCommand).toBe(
|
||||
"apt-get update\napt-get install -y curl",
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it("accepts safe binds array in sandbox.docker config", () => {
|
||||
const res = validateConfigObject({
|
||||
agents: {
|
||||
|
||||
@@ -17,7 +17,7 @@ export type SandboxDockerSettings = {
|
||||
capDrop?: string[];
|
||||
/** Extra environment variables for sandbox exec. */
|
||||
env?: Record<string, string>;
|
||||
/** Optional setup command run once after container creation. */
|
||||
/** Optional setup command run once after container creation (array entries are joined by newline). */
|
||||
setupCommand?: string;
|
||||
/** Limit container PIDs (0 = Docker default). */
|
||||
pidsLimit?: number;
|
||||
|
||||
@@ -102,7 +102,10 @@ export const SandboxDockerSchema = z
|
||||
user: z.string().optional(),
|
||||
capDrop: z.array(z.string()).optional(),
|
||||
env: z.record(z.string(), z.string()).optional(),
|
||||
setupCommand: z.string().optional(),
|
||||
setupCommand: z
|
||||
.union([z.string(), z.array(z.string())])
|
||||
.transform((value) => (Array.isArray(value) ? value.join("\n") : value))
|
||||
.optional(),
|
||||
pidsLimit: z.number().int().positive().optional(),
|
||||
memory: z.union([z.string(), z.number()]).optional(),
|
||||
memorySwap: z.union([z.string(), z.number()]).optional(),
|
||||
|
||||
Reference in New Issue
Block a user