(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)
| 771 | } |
| 772 | |
| 773 | async 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 | |
| 798 | async function readUserEnvFromCache(userEnvProbe: UserEnvProbe, params: { output: Log; containerSessionDataFolder?: string }, shellServer?: ShellServer) { |
| 799 | if (!shellServer || !params.containerSessionDataFolder) { |
no test coverage detected