Bug 497779 - Add labels to applications run as Docker containers
- add CDTLaunch label (no value) and CDTProject label (with project)
for containers created by the CDT Run in Container launch
Change-Id: Ic9a1ccb3c998083eccb6b16098c4a443c7d040bc
diff --git a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerLaunchConfigurationDelegate.java b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerLaunchConfigurationDelegate.java
index 24e6339..8967a68 100644
--- a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerLaunchConfigurationDelegate.java
+++ b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerLaunchConfigurationDelegate.java
@@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.docker.launcher;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -118,6 +119,13 @@
IPath commandPath = getCommandPath(configuration);
if (commandPath != null) {
+ // create some labels to allow user to filter out such Containers if
+ // kept
+ Map<String, String> labels = new HashMap<>();
+ labels.put("CDTLaunch", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ String projectName = configuration.getAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
+ labels.put("CDTProject", projectName); //$NON-NLS-1$
if (mode.equals(ILaunchManager.RUN_MODE)) {
String commandDir = commandPath.removeLastSegments(1)
.toString();
@@ -169,7 +177,7 @@
image, command,
commandDir, workingDir, additionalDirs, origEnv,
envMap, null, keepContainer, supportStdin,
- privilegedMode);
+ privilegedMode, labels);
} else if (mode.equals(ILaunchManager.DEBUG_MODE)) {
String gdbserverPortNumber = configuration.getAttribute(
ILaunchConstants.ATTR_GDBSERVER_PORT,
@@ -235,7 +243,7 @@
image, command,
commandDir, workingDir, additionalDirs, origEnv,
envMap, ports, keepContainer, supportStdin,
- privilegedMode);
+ privilegedMode, labels);
// wait until gdbserver is started successfully and we have its
// ip address or