File tree Expand file tree Collapse file tree 2 files changed +37
-3
lines changed
com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal
com.ibm.microclimate.ui/src/com/ibm/microclimate/ui/internal/actions Expand file tree Collapse file tree 2 files changed +37
-3
lines changed Original file line number Diff line number Diff line change 2727 * General utils that don't belong anywhere else
2828 */
2929public class MCUtil {
30+
31+ // Provide a way for users to override the path used for running commands
32+ private static final String ENV_PATH_PROPERTY = "com.ibm.microclimate.envPath" ;
3033
3134 /**
3235 * Open a dialog on top of the current active window. Can be called off the UI thread.
@@ -161,5 +164,33 @@ public static void updateApplication(MicroclimateApplication app) {
161164 }
162165 }
163166
164-
167+ public static String getOSName () {
168+ return (String )System .getProperty ("os.name" );
169+ }
170+
171+ public static boolean isMACOS () {
172+ String osName = getOSName ();
173+ if (osName != null && osName .toLowerCase ().contains ("mac" )) {
174+ return true ;
175+ }
176+ return false ;
177+ }
178+
179+ public static String getEnvPath () {
180+ String path = (String )System .getProperty (ENV_PATH_PROPERTY );
181+ if (path == null || path .trim ().isEmpty ()) {
182+ if (isMACOS ()) {
183+ // On MAC a full path is required for running commands
184+ return "/usr/local/bin/" ;
185+ }
186+ return null ;
187+ }
188+ path = path .trim ();
189+ path = path .replaceAll ("\\ " , "/" );
190+ if (!path .endsWith ("/" )) {
191+ path = path + "/" ;
192+ }
193+ return path ;
194+ }
195+
165196}
Original file line number Diff line number Diff line change 2222import org .eclipse .ui .IWorkbenchPart ;
2323
2424import com .ibm .microclimate .core .internal .MCLogger ;
25+ import com .ibm .microclimate .core .internal .MCUtil ;
2526import com .ibm .microclimate .core .internal .MicroclimateApplication ;
2627import com .ibm .microclimate .core .internal .constants .ProjectType ;
2728
3132public class ContainerShellAction implements IObjectActionDelegate {
3233
3334 private static final String LAUNCHER_DELEGATE_ID = "org.eclipse.tm.terminal.connector.local.launcher.local" ; //$NON-NLS-1$
34-
35+
3536 protected MicroclimateApplication app ;
3637 protected ILauncherDelegate delegate ;
3738
@@ -87,10 +88,12 @@ public void run(IAction action) {
8788 }
8889
8990 // Open a shell in the application container
91+ String envPath = MCUtil .getEnvPath ();
92+ String dockerPath = envPath != null ? envPath + "docker" : "docker" ;
9093 Map <String , Object > properties = new HashMap <>();
9194 properties .put (ITerminalsConnectorConstants .PROP_DELEGATE_ID , delegate .getId ());
9295 properties .put (ITerminalsConnectorConstants .PROP_TITLE , app .name );
93- properties .put (ITerminalsConnectorConstants .PROP_PROCESS_PATH , "docker" );
96+ properties .put (ITerminalsConnectorConstants .PROP_PROCESS_PATH , dockerPath );
9497 properties .put (ITerminalsConnectorConstants .PROP_PROCESS_ARGS , "exec -it " + app .getContainerId () + " " + command );
9598 delegate .execute (properties , null );
9699 }
You can’t perform that action at this time.
0 commit comments