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

Function probeUserEnv

src/spec-common/injectHeadless.ts:773–796  ·  view source on GitHub ↗
(params: { defaultUserEnvProbe: UserEnvProbe; allowSystemConfigChange: boolean; output: Log; containerSessionDataFolder?: string }, containerProperties: { shell: string; remoteExec: ExecFunction; installFolder?: string; env?: NodeJS.ProcessEnv; shellServer?: ShellServer; launchRootShellServer?: (() => Promise<ShellServer>); user?: string }, config?: CommonMergedDevContainerConfig)

Source from the content-addressed store, hash-verified

771}
772
773async function probeUserEnv(params: { defaultUserEnvProbe: UserEnvProbe; allowSystemConfigChange: boolean; output: Log; containerSessionDataFolder?: string }, containerProperties: { shell: string; remoteExec: ExecFunction; installFolder?: string; env?: NodeJS.ProcessEnv; shellServer?: ShellServer; launchRootShellServer?: (() => Promise<ShellServer>); user?: string }, config?: CommonMergedDevContainerConfig) {
774 let userEnvProbe = getUserEnvProb(config, params);
775 if (!userEnvProbe || userEnvProbe === 'none') {
776 return {};
777 }
778
779 let env = await readUserEnvFromCache(userEnvProbe, params, containerProperties.shellServer);
780 if (env) {
781 return env;
782 }
783
784 params.output.write('userEnvProbe: not found in cache');
785 env = await runUserEnvProbe(userEnvProbe, params, containerProperties, 'cat /proc/self/environ', '\0');
786 if (!env) {
787 params.output.write('userEnvProbe: falling back to printenv');
788 env = await runUserEnvProbe(userEnvProbe, params, containerProperties, 'printenv', '\n');
789 }
790
791 if (env) {
792 await updateUserEnvCache(env, userEnvProbe, params, containerProperties.shellServer);
793 }
794
795 return env || {};
796}
797
798async function readUserEnvFromCache(userEnvProbe: UserEnvProbe, params: { output: Log; containerSessionDataFolder?: string }, shellServer?: ShellServer) {
799 if (!shellServer || !params.containerSessionDataFolder) {

Callers 1

probeRemoteEnvFunction · 0.85

Calls 5

getUserEnvProbFunction · 0.85
readUserEnvFromCacheFunction · 0.85
runUserEnvProbeFunction · 0.85
updateUserEnvCacheFunction · 0.85
writeMethod · 0.65

Tested by

no test coverage detected