mirror of
https://github.com/coder/registry.git
synced 2026-06-02 20:48:14 +00:00
chore: sync newest module updates to registry (#84)
## Changes made - Copied over all changes to existing modules, making sure to preserve all relative path updates made specifically for the Registry repo - Copied over all modules that were created since the last sync (Windsurf, Devcontainers-CLI) - Copied over changes from the `test.ts` file ## Notes - This PR does not cover https://github.com/coder/modules/pull/426, which contains a few changes around updating the Bash scripts and the contributing README file. @f0ssel tagging you so that you're aware, but I'll be taking care of the `CONTRIBUTING.md` file --------- Co-authored-by: M Atif Ali <me@matifali.dev>
This commit is contained in:
+15
-6
@@ -30,6 +30,12 @@ export const runContainer = async (
|
||||
return containerID.trim();
|
||||
};
|
||||
|
||||
export interface scriptOutput {
|
||||
exitCode: number;
|
||||
stdout: string[];
|
||||
stderr: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the only "coder_script" resource in the given state and runs it in a
|
||||
* container.
|
||||
@@ -38,13 +44,15 @@ export const executeScriptInContainer = async (
|
||||
state: TerraformState,
|
||||
image: string,
|
||||
shell = "sh",
|
||||
): Promise<{
|
||||
exitCode: number;
|
||||
stdout: string[];
|
||||
stderr: string[];
|
||||
}> => {
|
||||
before?: string,
|
||||
): Promise<scriptOutput> => {
|
||||
const instance = findResourceInstance(state, "coder_script");
|
||||
const id = await runContainer(image);
|
||||
|
||||
if (before) {
|
||||
await execContainer(id, [shell, "-c", before]);
|
||||
}
|
||||
|
||||
const resp = await execContainer(id, [shell, "-c", instance.script]);
|
||||
const stdout = resp.stdout.trim().split("\n");
|
||||
const stderr = resp.stderr.trim().split("\n");
|
||||
@@ -58,12 +66,13 @@ export const executeScriptInContainer = async (
|
||||
export const execContainer = async (
|
||||
id: string,
|
||||
cmd: string[],
|
||||
args?: string[],
|
||||
): Promise<{
|
||||
exitCode: number;
|
||||
stderr: string;
|
||||
stdout: string;
|
||||
}> => {
|
||||
const proc = spawn(["docker", "exec", id, ...cmd], {
|
||||
const proc = spawn(["docker", "exec", ...(args ?? []), id, ...cmd], {
|
||||
stderr: "pipe",
|
||||
stdout: "pipe",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user