MCPcopy Index your code
hub / github.com/devcontainers/cli / createContainerProperties

Function createContainerProperties

src/spec-node/utils.ts:495–520  ·  view source on GitHub ↗
(params: DockerResolverParameters, containerId: string, remoteWorkspaceFolder: string | undefined, remoteUser: string | undefined, rootShellServer?: ShellServer)

Source from the content-addressed store, hash-verified

493}
494
495export async function createContainerProperties(params: DockerResolverParameters, containerId: string, remoteWorkspaceFolder: string | undefined, remoteUser: string | undefined, rootShellServer?: ShellServer) {
496 const { common } = params;
497 const inspecting = 'Inspecting container';
498 const start = common.output.start(inspecting);
499 const containerInfo = await inspectContainer(params, containerId);
500 common.output.stop(inspecting, start);
501 const containerUser = remoteUser || containerInfo.Config.User || 'root';
502 const [, user, , group] = /([^:]*)(:(.*))?/.exec(containerUser) as (string | undefined)[];
503 const containerEnv = envListToObj(containerInfo.Config.Env);
504 const remoteExec = dockerExecFunction(params, containerId, containerUser);
505 const remotePtyExec = await dockerPtyExecFunction(params, containerId, containerUser, common.loadNativeModule, common.allowInheritTTY);
506 const remoteExecAsRoot = dockerExecFunction(params, containerId, 'root');
507 return getContainerProperties({
508 params: common,
509 createdAt: containerInfo.Created,
510 startedAt: containerInfo.State.StartedAt,
511 remoteWorkspaceFolder,
512 containerUser: user === '0' ? 'root' : user,
513 containerGroup: group,
514 containerEnv,
515 remoteExec,
516 remotePtyExec,
517 remoteExecAsRoot,
518 rootShellServer,
519 });
520}
521
522export function envListToObj(list: string[] | null | undefined) {
523 // Handle Env is null (https://github.com/microsoft/vscode-remote-release/issues/2058).

Callers 5

doSetUpFunction · 0.90
doRunUserCommandsFunction · 0.90
doExecFunction · 0.90

Calls 8

inspectContainerFunction · 0.90
dockerExecFunctionFunction · 0.90
dockerPtyExecFunctionFunction · 0.90
getContainerPropertiesFunction · 0.90
envListToObjFunction · 0.85
startMethod · 0.80
stopMethod · 0.80
execMethod · 0.65

Tested by

no test coverage detected