Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit 4a620ba

Browse files
authored
feat: support debug on Podman (#685)
* feat: support debug on Podman Signed-off-by: Stephane Bouchet <[email protected]> * feat: support debug on Podman fix after review Signed-off-by: Stephane Bouchet <[email protected]> --------- Signed-off-by: Stephane Bouchet <[email protected]>
1 parent f59f0b7 commit 4a620ba

32 files changed

+619
-231
lines changed

build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ tasks.register('integrationTest', Test) {
106106
testClassesDirs = sourceSets.integrationTest.output.classesDirs
107107
classpath = sourceSets.integrationTest.runtimeClasspath
108108
outputs.upToDateWhen { false }
109-
jvmArgs "-Djava.awt.headless=true"
110109
testlogger {
111110
showStandardStreams true
112111
showPassedStandardStreams false

src/it/projects/springboot-rest/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ tmp
1313

1414
.odo/
1515
devfile.yaml
16+
17+
.odo

src/main/java/org/jboss/tools/intellij/openshift/actions/NodeUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public static <T> T getElement(Object selected) {
9393
selected = ((DefaultMutableTreeNode)selected).getUserObject();
9494
}
9595
if (selected instanceof NodeDescriptor) {
96-
selected = ((NodeDescriptor)selected).getElement();
96+
selected = ((NodeDescriptor<?>) selected).getElement();
9797
}
9898
return (T) selected;
9999
}

src/main/java/org/jboss/tools/intellij/openshift/actions/component/DeployComponentAction.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@
1010
******************************************************************************/
1111
package org.jboss.tools.intellij.openshift.actions.component;
1212

13+
import org.jboss.tools.intellij.openshift.utils.odo.Component;
1314
import org.jboss.tools.intellij.openshift.utils.odo.ComponentFeature;
1415

1516
public class DeployComponentAction extends FeatureComponentAction {
1617
public DeployComponentAction() {
1718
super(ComponentFeature.DEPLOY);
1819
}
20+
21+
@Override
22+
protected String getCustomizedPresentation(Component component) {
23+
return "";
24+
}
25+
1926
}

src/main/java/org/jboss/tools/intellij/openshift/actions/component/DevComponentAction.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,25 @@
1010
******************************************************************************/
1111
package org.jboss.tools.intellij.openshift.actions.component;
1212

13+
import org.jboss.tools.intellij.openshift.utils.odo.Component;
1314
import org.jboss.tools.intellij.openshift.utils.odo.ComponentFeature;
1415

1516
public class DevComponentAction extends FeatureComponentAction {
1617
public DevComponentAction() {
1718
super(ComponentFeature.DEV);
1819
}
20+
21+
@Override
22+
protected boolean needCustomizedPresentation() {
23+
return true;
24+
}
25+
26+
@Override
27+
protected String getCustomizedPresentation(Component component) {
28+
if (component.getLiveFeatures().is(ComponentFeature.DEV)) {
29+
return "Stop " + getActionName();
30+
} else {
31+
return "Start " + getActionName();
32+
}
33+
}
1934
}

src/main/java/org/jboss/tools/intellij/openshift/actions/component/DevOnPodmanComponentAction.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ public DevOnPodmanComponentAction() {
2020
}
2121

2222
@Override
23-
protected String getActionName() {
24-
return ComponentFeature.DEV_ON_PODMAN.getLabel();
23+
protected boolean needCustomizedPresentation() {
24+
return true;
2525
}
2626

2727
@Override
28-
public String getTelemetryActionName() {
29-
return ComponentFeature.DEV_ON_PODMAN.getLabel() + " component";
28+
protected String getCustomizedPresentation(Component component) {
29+
if (component.getLiveFeatures().is(ComponentFeature.DEV_ON_PODMAN)) {
30+
return "Stop " + getActionName();
31+
} else {
32+
return "Start " + getActionName();
33+
}
3034
}
3135

32-
@Override
33-
protected ComponentFeature getComponentFeature(Component component) {
34-
return ComponentFeature.DEV_ON_PODMAN;
35-
}
3636
}

src/main/java/org/jboss/tools/intellij/openshift/actions/component/FeatureComponentAction.java

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
import com.intellij.openapi.progress.ProgressIndicator;
1515
import com.intellij.openapi.ui.Messages;
1616
import com.redhat.devtools.intellij.common.utils.UIHelper;
17-
import org.jboss.tools.intellij.openshift.actions.NodeUtils;
17+
import org.jboss.tools.intellij.openshift.actions.ActionUtils;
1818
import org.jboss.tools.intellij.openshift.tree.application.ComponentNode;
1919
import org.jboss.tools.intellij.openshift.tree.application.NamespaceNode;
2020
import org.jboss.tools.intellij.openshift.utils.odo.Component;
2121
import org.jboss.tools.intellij.openshift.utils.odo.ComponentFeature;
22+
import org.jboss.tools.intellij.openshift.utils.odo.DebugComponentFeature;
2223
import org.jboss.tools.intellij.openshift.utils.odo.Odo;
2324
import org.jetbrains.annotations.NotNull;
2425
import org.slf4j.Logger;
@@ -36,7 +37,9 @@ public abstract class FeatureComponentAction extends ContextAwareComponentAction
3637

3738
protected final ComponentFeature feature;
3839

39-
public FeatureComponentAction(ComponentFeature feature) {
40+
protected DebugComponentFeature debugFeature;
41+
42+
protected FeatureComponentAction(ComponentFeature feature) {
4043
this.feature = feature;
4144
}
4245

@@ -45,38 +48,39 @@ public boolean isVisible(Object selected) {
4548
boolean visible = super.isVisible(selected);
4649
if (visible && selected instanceof ComponentNode) {
4750
Component component = ((ComponentNode) selected).getComponent();
48-
visible = component.getInfo().getFeatures().is(feature);
51+
visible = component.getInfo().getSupportedFeatures().contains(feature.getMode());
4952
}
5053
return visible;
5154
}
5255

5356
@Override
5457
public void update(AnActionEvent e) {
5558
super.update(e);
56-
if (e.getPresentation().isVisible()) {
59+
if (e.getPresentation().isVisible() && needCustomizedPresentation()) {
5760
Object node = adjust(getSelected(getTree(e)));
5861
if (!(node instanceof ComponentNode)) {
5962
return;
6063
}
61-
ComponentNode componentNode = ((ComponentNode) adjust(getSelected(getTree(e))));
64+
ComponentNode componentNode = (ComponentNode) node;
6265
Component component = componentNode.getComponent();
63-
ComponentFeature feat = getComponentFeature(component);
6466
try {
6567
Odo odo = componentNode.getRoot().getOdo().getNow(null);
6668
if (odo == null) {
6769
return;
6870
}
69-
if (odo.isStarted(componentNode.getNamespace(), component.getPath(), component.getName(), feat)) {
70-
e.getPresentation().setText("Stop " + getActionName());
71-
} else {
72-
e.getPresentation().setText("Start " + getActionName());
73-
}
71+
e.getPresentation().setText(getCustomizedPresentation(component));
7472
} catch (Exception ex) {
7573
LOGGER.warn("Could not update {}", componentNode.getName(), e);
7674
}
7775
}
7876
}
7977

78+
protected abstract String getCustomizedPresentation(Component component);
79+
80+
protected boolean needCustomizedPresentation() {
81+
return false;
82+
}
83+
8084
protected String getActionName() {
8185
return feature.getLabel();
8286
}
@@ -91,23 +95,27 @@ public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object
9195
ComponentNode componentNode = (ComponentNode) selected;
9296
Component component = componentNode.getComponent();
9397
NamespaceNode namespaceNode = componentNode.getParent();
94-
runWithProgress((ProgressIndicator progress) -> {
98+
runWithProgress(
99+
(ProgressIndicator progress) -> {
95100
try {
96-
ComponentFeature feat = getComponentFeature(component);
101+
ComponentFeature feat = getComponentFeature();
97102
process(odo,
98103
namespaceNode.getName(),
99104
component,
100105
feat,
101106
b1 -> {
102-
if (component.getLiveFeatures().is(feat)) {
103-
component.getLiveFeatures().removeFeature(feat);
104-
} else {
105-
component.getLiveFeatures().addFeature(feat);
107+
component.getLiveFeatures().addFeature(feature);
108+
if (feat.getMode().equals(ComponentFeature.Mode.DEBUG_MODE)) {
109+
component.getLiveFeatures().addFeature(debugFeature);
110+
}
111+
ActionUtils.getApplicationTreeStructure(anActionEvent).fireModified(componentNode);
112+
}, b2 -> {
113+
component.getLiveFeatures().removeFeature(feature);
114+
if (feat.getMode().equals(ComponentFeature.Mode.DEBUG_MODE)) {
115+
component.getLiveFeatures().removeFeature(debugFeature);
106116
}
107-
NodeUtils.fireModified(componentNode);
108-
},
109-
b2 -> NodeUtils.fireModified(componentNode)
110-
);
117+
ActionUtils.getApplicationTreeStructure(anActionEvent).fireModified(componentNode);
118+
});
111119
sendTelemetryResults(TelemetryResult.SUCCESS);
112120
} catch (IOException e) {
113121
sendTelemetryError(e);
@@ -118,9 +126,11 @@ public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object
118126
getEventProject(anActionEvent));
119127
}
120128

121-
protected ComponentFeature getComponentFeature(Component component) {
122-
return ((feature.getPeer() != null) && component.getInfo().getFeatures().is(feature.getPeer())) ?
123-
feature.getPeer() : feature;
129+
private ComponentFeature getComponentFeature() {
130+
// for now, always start dev in debug mode. see #571 for use of a preference
131+
if (debugFeature == null)
132+
debugFeature = new DebugComponentFeature(feature);
133+
return debugFeature;
124134
}
125135

126136
protected void process(Odo odo, String project, Component component,

src/main/java/org/jboss/tools/intellij/openshift/actions/project/ChangeActiveProjectAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public String getTelemetryActionName() {
132132
@Override
133133
public boolean isVisible(Object selected) {
134134
return (selected instanceof NamespaceNode)
135-
|| ((selected instanceof ApplicationsRootNode && ((ApplicationsRootNode) selected).isLogged()));
135+
|| (selected instanceof ApplicationsRootNode && ((ApplicationsRootNode) selected).isLogged());
136136
}
137137

138138
private static final class ClusterProjects {

src/main/java/org/jboss/tools/intellij/openshift/tree/application/ApplicationRootNodeOdo.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
package org.jboss.tools.intellij.openshift.tree.application;
1212

1313
import com.fasterxml.jackson.databind.node.ObjectNode;
14+
import com.intellij.execution.process.ProcessHandler;
1415
import com.intellij.openapi.util.io.FileUtil;
1516
import com.intellij.openapi.util.text.StringUtil;
1617
import com.intellij.openapi.vfs.VfsUtil;
@@ -336,8 +337,13 @@ public void migrateComponent(String context, String name){
336337
}
337338

338339
@Override
339-
public void release() {
340-
delegate.release();
340+
public Map<String, Map<ComponentFeature, ProcessHandler>> getComponentFeatureProcesses() {
341+
return delegate.getComponentFeatureProcesses();
342+
}
343+
344+
@Override
345+
public void setComponentFeatureProcesses(Map<String, Map<ComponentFeature, ProcessHandler>> processes) {
346+
delegate.setComponentFeatureProcesses(processes);
341347
}
342348

343349
/** for testing purposes **/

0 commit comments

Comments
 (0)