-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JBIDE-24184] get debug port and devmode switch from image
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
- Loading branch information
Showing
81 changed files
with
4,148 additions
and
2,376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,5 +60,5 @@ public static <T> T getFirstElement(Collection<T> collection) { | |
} | ||
|
||
return collection.iterator().next(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...rg/jboss/tools/openshift/internal/common/ui/databinding/RequiredStringMultiValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2015-2017 Red Hat, Inc. | ||
* Distributed under license by Red Hat, Inc. All rights reserved. | ||
* This program is made available under the terms of the | ||
* Eclipse Public License v1.0 which accompanies this distribution, | ||
* and is available at http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
******************************************************************************/ | ||
package org.jboss.tools.openshift.internal.common.ui.databinding; | ||
|
||
import org.eclipse.core.databinding.observable.value.IObservableValue; | ||
import org.eclipse.core.databinding.validation.MultiValidator; | ||
import org.eclipse.core.databinding.validation.ValidationStatus; | ||
import org.eclipse.core.runtime.IStatus; | ||
import org.jboss.tools.openshift.common.core.utils.StringUtils; | ||
|
||
/** | ||
* A validator whose state may be observed. | ||
* | ||
* @author Andre Dietisheim | ||
*/ | ||
public class RequiredStringMultiValidator extends MultiValidator { | ||
|
||
private IObservableValue<String> observableValue; | ||
private String name; | ||
private String errorMessage; | ||
|
||
public RequiredStringMultiValidator(IObservableValue<String> value, String name) { | ||
this(value, name, null); | ||
} | ||
|
||
public RequiredStringMultiValidator(String errorMessage, IObservableValue<String> value) { | ||
this(value, null, errorMessage); | ||
} | ||
|
||
protected RequiredStringMultiValidator(IObservableValue<String> value, String name, String errorMessage) { | ||
this.observableValue = value; | ||
this.name = name; | ||
this.errorMessage = errorMessage; | ||
} | ||
|
||
@Override | ||
protected IStatus validate() { | ||
String value = observableValue.getValue(); | ||
if (!isValueProvided(value)) { | ||
return ValidationStatus.cancel(getErrorMessage()); | ||
} | ||
return validateValue(value); | ||
} | ||
|
||
protected boolean isValueProvided(String value) { | ||
return !StringUtils.isEmpty(value); | ||
} | ||
|
||
protected IStatus validateValue(String value) { | ||
return ValidationStatus.ok(); | ||
} | ||
|
||
protected String getErrorMessage() { | ||
if (errorMessage != null) { | ||
return errorMessage; | ||
} else { | ||
return "Please provide a value for " + name; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...s.tools.openshift.core/src/org/jboss/tools/openshift/core/OpenShiftResourceSelectors.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2017 Red Hat, Inc. | ||
* Distributed under license by Red Hat, Inc. All rights reserved. | ||
* This program is made available under the terms of the | ||
* Eclipse Public License v1.0 which accompanies this distribution, | ||
* and is available at http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
******************************************************************************/ | ||
package org.jboss.tools.openshift.core; | ||
|
||
/** | ||
* The list of well known selectors that can be consumed by the tooling | ||
* | ||
* @author Andre Dietisheim | ||
*/ | ||
public interface OpenShiftResourceSelectors { | ||
/** as in eap templates **/ | ||
static final String DEPLOYMENT_CONFIG = "deploymentconfig"; | ||
} |
89 changes: 89 additions & 0 deletions
89
...jboss.tools.openshift.core/src/org/jboss/tools/openshift/core/server/DevmodeMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2016-2017 Red Hat Inc.. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat Incorporated - initial API and implementation | ||
*******************************************************************************/ | ||
package org.jboss.tools.openshift.core.server; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import org.jboss.tools.openshift.common.core.utils.StringUtils; | ||
|
||
/** | ||
* @author Andre Dietisheim | ||
*/ | ||
public class DevmodeMetadata { | ||
|
||
// default fallback | ||
private static final String DEFAULT_ENABLEMENT_KEY = "DEBUG"; | ||
private static final String DEFAULT_ENABLEMENT_VALUE = "true"; | ||
private static final String DEFAULT_PORT_KEY = "DEBUG_PORT"; | ||
private static final String DEFAULT_PORT_VALUE = "8787"; | ||
|
||
// "image->"dockerImageMetadata"->"Config"->"Labels"-> | ||
private static final Pattern REGEX_LABEL_DEVMODE = Pattern | ||
.compile("\\\"com\\.redhat\\.dev-mode\\\" ?\\: ?\\\"([^(:|\\\")]+)(:|\\\")([^\\\"]*)"); | ||
private static final Pattern REGEX_LABEL_DEVMODE_PORT = Pattern | ||
.compile("\\\"com\\.redhat\\.dev-mode\\.port\\\" ?\\: ?\\\"([^(:|\\\")]+)(:|\\\")([^\\\"]*)"); | ||
|
||
private String enablementKey; | ||
private String enablementValue; | ||
private String portKey; | ||
private String portValue; | ||
|
||
public DevmodeMetadata(String metadata) { | ||
parse(metadata); | ||
} | ||
|
||
public String getEnablementKey() { | ||
return enablementKey; | ||
} | ||
|
||
public String getEnablementValue() { | ||
return enablementValue; | ||
} | ||
|
||
public String getPortKey() { | ||
return portKey; | ||
} | ||
|
||
public String getPortValue() { | ||
return portValue; | ||
} | ||
|
||
private void parse(String metadata) { | ||
if (!StringUtils.isEmpty(metadata)) { | ||
parseEnablement(metadata); | ||
parsePort(metadata); | ||
} | ||
} | ||
|
||
private void parseEnablement(String metadata) { | ||
Matcher matcher = REGEX_LABEL_DEVMODE.matcher(metadata); | ||
if (matcher.find()) { | ||
this.enablementKey = matcher.group(1); | ||
this.enablementValue = matcher.group(3); | ||
} else { | ||
this.enablementKey = DEFAULT_ENABLEMENT_KEY; | ||
this.enablementValue = DEFAULT_ENABLEMENT_VALUE; | ||
} | ||
} | ||
|
||
private void parsePort(String metadata) { | ||
Matcher matcher = REGEX_LABEL_DEVMODE_PORT.matcher(metadata); | ||
if (matcher.find()) { | ||
this.portKey = matcher.group(1); | ||
this.portValue = matcher.group(3); | ||
} else { | ||
this.portKey = DEFAULT_PORT_KEY; | ||
this.portValue = DEFAULT_PORT_VALUE; | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.