Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions src/core/dev/container.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ describe("ContainerDevRunner", () => {
AWS_REGION: "us-east-1",
AWS_CONFIG_FILE: "/aws-config/config",
AWS_SHARED_CREDENTIALS_FILE: "/aws-config/credentials",
AWS_LOGIN_CACHE_DIRECTORY: "/aws-config/login/cache",
});
expect(run.command.join(" ")).not.toContain("sandbox");

Expand All @@ -268,6 +269,55 @@ describe("ContainerDevRunner", () => {
expect(missing.calls).toHaveLength(0);
});

test.each(["docker", "podman", "finch"])(
"uses the mounted aws login cache with %s",
async (tool) => {
const projectRuntime = runtime();
const root = await projectRoot(projectRuntime);
const awsDirectory = join(root, ".aws");
await mkdir(join(awsDirectory, "login", "cache"), { recursive: true });
await writeFile(
join(awsDirectory, "config"),
"[profile sandbox]\nlogin_session=sample-user\nregion=us-east-1\n",
);
const { calls, runner } = harness({
awsDirectory,
processEnv: { AWS_PROFILE: "sandbox" },
available: async (candidate) => candidate === tool,
});

await collect(runner.run(input(root, projectRuntime)));

const run = commandCall(calls, "run");
expect(run.command[0]).toBe(tool);
expect(run.command).toContain(`${awsDirectory}:/aws-config:ro`);
expect(parseEnv(run.envFile!.contents)).toMatchObject({
AWS_PROFILE: "sandbox",
AWS_CONFIG_FILE: "/aws-config/config",
AWS_SHARED_CREDENTIALS_FILE: "/aws-config/credentials",
AWS_LOGIN_CACHE_DIRECTORY: "/aws-config/login/cache",
});
expect(run.command.join(" ")).not.toContain("AWS_LOGIN_CACHE_DIRECTORY");
await expect(readFile(run.envFile!.path, "utf8")).rejects.toThrow();
},
);

test("preserves an explicit container login cache directory", async () => {
const projectRuntime = runtime();
const root = await projectRoot(projectRuntime);
const awsDirectory = join(root, ".aws");
await mkdir(awsDirectory);
const { calls, runner } = harness({ awsDirectory, processEnv: { AWS_PROFILE: "sandbox" } });
const runInput = input(root, projectRuntime);
runInput.env = { ...runInput.env, AWS_LOGIN_CACHE_DIRECTORY: "/container/cache" };

await collect(runner.run(runInput));

const run = commandCall(calls, "run");
expect(parseEnv(run.envFile!.contents).AWS_LOGIN_CACHE_DIRECTORY).toBe("/container/cache");
expect(run.command).toContain(`${awsDirectory}:/aws-config:ro`);
});

test("preserves an existing build context .dockerignore", async () => {
const projectRuntime = runtime({ buildContextPath: "." });
const root = await projectRoot(projectRuntime);
Expand Down
1 change: 1 addition & 0 deletions src/core/dev/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export class ContainerDevRunner implements DevRunner {
if (awsMount.length) {
forwardedEnv.AWS_CONFIG_FILE = "/aws-config/config";
forwardedEnv.AWS_SHARED_CREDENTIALS_FILE = "/aws-config/credentials";
forwardedEnv.AWS_LOGIN_CACHE_DIRECTORY ??= "/aws-config/login/cache";
}
const envFile = join(tmpdir(), `agentcore-dev-${randomUUID()}.env`);
try {
Expand Down