(params: DockerCLIParameters, config: DevContainerConfig, additionalFeatures: Record<string, string | boolean | Record<string, string | boolean>>, idLabels: string[] | undefined)
| 11 | |
| 12 | |
| 13 | export 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 | |
| 51 | export function findDisallowedFeatureEntry(controlManifest: DevContainerControlManifest, featureId: string): DisallowedFeature | undefined { |
| 52 | return controlManifest.disallowedFeatures.find( |
no test coverage detected