forked from farhoodlabs/paperclip
fix(plugin): address kubernetes greptile follow-up
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -12,6 +12,10 @@ describe("manifest", () => {
|
||||
|
||||
it("keeps namespace inputs within the Kubernetes DNS label length limit", () => {
|
||||
expect(configSchema.properties.namespacePrefix.maxLength).toBe(20);
|
||||
expect(configSchema.properties.paperclipServerNamespace.maxLength).toBe(63);
|
||||
expect(configSchema.properties.paperclipServerNamespace.pattern).toBe(
|
||||
"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$",
|
||||
);
|
||||
expect(configSchema.properties.companySlug.maxLength).toBe(43);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import plugin, { extractAdapterEnvFromProcess } from "../../src/plugin.js";
|
||||
import plugin, {
|
||||
buildSandboxExecShellCommand,
|
||||
extractAdapterEnvFromProcess,
|
||||
} from "../../src/plugin.js";
|
||||
|
||||
describe("plugin", () => {
|
||||
it("exports the kubernetes driver", () => {
|
||||
@@ -34,6 +37,7 @@ describe("plugin", () => {
|
||||
expect.objectContaining({
|
||||
namespacePrefix: "paperclip-",
|
||||
egressMode: "standard",
|
||||
paperclipServerNamespace: "paperclip",
|
||||
jobTtlSecondsAfterFinished: 900,
|
||||
podActivityDeadlineSec: 3600,
|
||||
adapterType: "claude_local",
|
||||
@@ -120,4 +124,41 @@ describe("plugin", () => {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("preserves intentionally empty adapter env values", () => {
|
||||
const warnMessages: string[] = [];
|
||||
const originalValue = process.env.PAPERCLIP_TEST_EMPTY_KEY;
|
||||
process.env.PAPERCLIP_TEST_EMPTY_KEY = "";
|
||||
try {
|
||||
const result = extractAdapterEnvFromProcess(
|
||||
["PAPERCLIP_TEST_EMPTY_KEY"],
|
||||
(message) => warnMessages.push(message),
|
||||
);
|
||||
expect(result).toEqual({ PAPERCLIP_TEST_EMPTY_KEY: "" });
|
||||
expect(warnMessages).toHaveLength(0);
|
||||
} finally {
|
||||
if (originalValue === undefined) {
|
||||
delete process.env.PAPERCLIP_TEST_EMPTY_KEY;
|
||||
} else {
|
||||
process.env.PAPERCLIP_TEST_EMPTY_KEY = originalValue;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("quotes args before passing them to /bin/sh -lc", () => {
|
||||
expect(
|
||||
buildSandboxExecShellCommand({
|
||||
args: ["git", "commit", "-m", "feat: add feature", "it's ready"],
|
||||
}),
|
||||
).toBe("'git' 'commit' '-m' 'feat: add feature' 'it'\\''s ready'");
|
||||
});
|
||||
|
||||
it("uses command verbatim when command is provided", () => {
|
||||
expect(
|
||||
buildSandboxExecShellCommand({
|
||||
command: "pnpm test -- --runInBand",
|
||||
args: ["ignored"],
|
||||
}),
|
||||
).toBe("pnpm test -- --runInBand");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ describe("kubernetesProviderConfigSchema", () => {
|
||||
const parsed = parseKubernetesProviderConfig({ inCluster: true });
|
||||
expect(parsed.inCluster).toBe(true);
|
||||
expect(parsed.namespacePrefix).toBe("paperclip-");
|
||||
expect(parsed.paperclipServerNamespace).toBe("paperclip");
|
||||
expect(parsed.imageAllowList).toEqual([]);
|
||||
expect(parsed.egressMode).toBe("standard");
|
||||
expect(parsed.jobTtlSecondsAfterFinished).toBe(900);
|
||||
@@ -40,6 +41,25 @@ describe("kubernetesProviderConfigSchema", () => {
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("accepts a custom paperclip-server namespace", () => {
|
||||
const parsed = parseKubernetesProviderConfig({
|
||||
inCluster: true,
|
||||
paperclipServerNamespace: "paperclip-prod",
|
||||
});
|
||||
expect(parsed.paperclipServerNamespace).toBe("paperclip-prod");
|
||||
});
|
||||
|
||||
it("rejects invalid paperclip-server namespace values", () => {
|
||||
for (const namespace of ["Paperclip", "paperclip_", "-paperclip", "paperclip-"]) {
|
||||
expect(() =>
|
||||
parseKubernetesProviderConfig({
|
||||
inCluster: true,
|
||||
paperclipServerNamespace: namespace,
|
||||
}),
|
||||
).toThrow();
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects whitespace-only kubeconfig", () => {
|
||||
expect(() =>
|
||||
parseKubernetesProviderConfig({ inCluster: false, kubeconfig: " " }),
|
||||
|
||||
Reference in New Issue
Block a user