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

Function readDevContainerConfigFile

src/spec-node/configContainer.ts:82–117  ·  view source on GitHub ↗
(cliHost: CLIHost, workspace: Workspace | undefined, configFile: URI, mountWorkspaceGitRoot: boolean, mountGitWorktreeCommonDir: boolean, output: Log, consistency?: BindMountConsistency, overrideConfigFile?: URI)

Source from the content-addressed store, hash-verified

80}
81
82export async function readDevContainerConfigFile(cliHost: CLIHost, workspace: Workspace | undefined, configFile: URI, mountWorkspaceGitRoot: boolean, mountGitWorktreeCommonDir: boolean, output: Log, consistency?: BindMountConsistency, overrideConfigFile?: URI) {
83 const documents = createDocuments(cliHost);
84 const content = await documents.readDocument(overrideConfigFile ?? configFile);
85 if (!content) {
86 return undefined;
87 }
88 const raw = jsonc.parse(content) as DevContainerConfig | undefined;
89 const updated = raw && updateFromOldProperties(raw);
90 if (!updated || typeof updated !== 'object' || Array.isArray(updated)) {
91 throw new ContainerError({ description: `Dev container config (${uriToFsPath(configFile, cliHost.platform)}) must contain a JSON object literal.` });
92 }
93 const workspaceConfig = await getWorkspaceConfiguration(cliHost, workspace, updated, mountWorkspaceGitRoot, mountGitWorktreeCommonDir, output, consistency);
94 const substitute0: SubstituteConfig = value => substitute({
95 platform: cliHost.platform,
96 localWorkspaceFolder: workspace?.rootFolderPath,
97 containerWorkspaceFolder: workspaceConfig.workspaceFolder,
98 configFile,
99 env: cliHost.env,
100 }, value);
101 const config: DevContainerConfig = substitute0(updated);
102 if (typeof config.workspaceFolder === 'string') {
103 workspaceConfig.workspaceFolder = config.workspaceFolder;
104 }
105 if ('workspaceMount' in config) {
106 workspaceConfig.workspaceMount = config.workspaceMount;
107 }
108 config.configFilePath = configFile;
109 return {
110 config: {
111 config,
112 raw: updated,
113 substitute: substitute0,
114 },
115 workspaceConfig,
116 };
117}

Callers 9

getConfigFunction · 0.90
doSetUpFunction · 0.90
doBuildFunction · 0.90
doRunUserCommandsFunction · 0.90
readConfigurationFunction · 0.90
outdatedFunction · 0.90
doExecFunction · 0.90
resolveWithLocalFolderFunction · 0.85

Calls 6

createDocumentsFunction · 0.90
updateFromOldPropertiesFunction · 0.90
uriToFsPathFunction · 0.85
substitute0Function · 0.70
readDocumentMethod · 0.65

Tested by

no test coverage detected