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

Function findDevContainerByNormalizedLabels

src/spec-node/utils.ts:667–693  ·  view source on GitHub ↗
(params: DockerResolverParameters | DockerCLIParameters, normalizedWorkspaceFolder: string, normalizedConfigFile: string)

Source from the content-addressed store, hash-verified

665}
666
667async function findDevContainerByNormalizedLabels(params: DockerResolverParameters | DockerCLIParameters, normalizedWorkspaceFolder: string, normalizedConfigFile: string) {
668 if (process.platform !== 'win32') {
669 return undefined;
670 }
671
672 const ids = await listContainers(params, true, [hostFolderLabel]);
673 if (!ids.length) {
674 return undefined;
675 }
676
677 const details = await inspectContainers(params, ids);
678 return details
679 .filter(container => container.State.Status !== 'removing')
680 .find(container => {
681 const labels = container.Config.Labels || {};
682 const containerWorkspaceFolder = labels[hostFolderLabel];
683 const normalizedContainerWorkspaceFolder = containerWorkspaceFolder && normalizeDevContainerLabelPath('win32', containerWorkspaceFolder);
684 if (!normalizedContainerWorkspaceFolder || normalizedContainerWorkspaceFolder !== normalizedWorkspaceFolder) {
685 return false;
686 }
687
688 const containerConfigFile = labels[configFileLabel];
689 const normalizedContainerConfigFile = containerConfigFile && normalizeDevContainerLabelPath('win32', containerConfigFile);
690 return !!normalizedContainerConfigFile
691 && normalizedContainerConfigFile === normalizedConfigFile;
692 });
693}
694
695async function findLegacyDevContainerByNormalizedWorkspaceFolder(params: DockerResolverParameters | DockerCLIParameters, normalizedWorkspaceFolder: string) {
696 if (process.platform !== 'win32') {

Callers 1

findContainerAndIdLabelsFunction · 0.85

Calls 3

listContainersFunction · 0.90
inspectContainersFunction · 0.90

Tested by

no test coverage detected