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

Function ensureNoDisallowedFeatures

src/spec-node/disallowedFeatures.ts:13–49  ·  view source on GitHub ↗
(params: DockerCLIParameters, config: DevContainerConfig, additionalFeatures: Record<string, string | boolean | Record<string, string | boolean>>, idLabels: string[] | undefined)

Source from the content-addressed store, hash-verified

11
12
13export async function ensureNoDisallowedFeatures(params: DockerCLIParameters, config: DevContainerConfig, additionalFeatures: Record<string, string | boolean | Record<string, string | boolean>>, idLabels: string[] | undefined) {
14 const controlManifest = await getControlManifest(await getCacheFolder(params.cliHost), params.output);
15 const disallowed = Object.keys({
16 ...config.features,
17 ...additionalFeatures,
18 }).map(configFeatureId => {
19 const disallowedFeatureEntry = findDisallowedFeatureEntry(controlManifest, configFeatureId);
20 return disallowedFeatureEntry ? { configFeatureId, disallowedFeatureEntry } : undefined;
21 }).filter(Boolean) as {
22 configFeatureId: string;
23 disallowedFeatureEntry: DisallowedFeature;
24 }[];
25
26 if (!disallowed.length) {
27 return;
28 }
29
30 let stopped = false;
31 if (idLabels) {
32 const container = await findDevContainer(params, idLabels);
33 if (container?.State?.Status === 'running') {
34 await dockerCLI(params, 'stop', '-t', '0', container.Id);
35 stopped = true;
36 }
37 }
38
39 const d = disallowed[0]!;
40 const documentationURL = d.disallowedFeatureEntry.documentationURL;
41 throw new ContainerError({
42 description: `Cannot use the '${d.configFeatureId}' Feature since it was reported to be problematic. Please remove this Feature from your configuration and rebuild any dev container using it before continuing.${stopped ? ' The existing dev container was stopped.' : ''}${documentationURL ? ` See ${documentationURL} to learn more.` : ''}`,
43 data: {
44 disallowedFeatureId: d.configFeatureId,
45 didStopContainer: stopped,
46 learnMoreUrl: documentationURL,
47 },
48 });
49}
50
51export function findDisallowedFeatureEntry(controlManifest: DevContainerControlManifest, featureId: string): DisallowedFeature | undefined {
52 return controlManifest.disallowedFeatures.find(

Callers 3

doBuildFunction · 0.90
resolveWithLocalFolderFunction · 0.90

Calls 5

getControlManifestFunction · 0.90
getCacheFolderFunction · 0.90
findDevContainerFunction · 0.90
dockerCLIFunction · 0.90

Tested by

no test coverage detected