Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.44-1</version>
<version>0.1.51</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.8.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
57 changes: 57 additions & 0 deletions src/main/java/com/openshift/client/DeploymentTypes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*******************************************************************************
* Copyright (c) 2014 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 com.openshift.client;

import java.util.Arrays;
import java.util.List;

/**
* @author Andre Dietisheim
*/
public class DeploymentTypes {

private static final String GIT = "git";
private static final String BINARY = "binary";

private DeploymentTypes() {
}

public static String git() {
return GIT;
}

public static String binary() {
return BINARY;
}

public static boolean isBinary(String deploymentType) {
return BINARY.equals(deploymentType);
}

public static boolean isGit(String deploymentType) {
return GIT.equals(deploymentType);
}

public static List<String> getAll() {
return Arrays.asList(GIT, BINARY);
}

public static String switchType(String deploymentType) {
if (isBinary(deploymentType)) {
return GIT;
} else if (isGit(deploymentType)) {
return BINARY;
} else {
throw new OpenShiftException("Unknown deployment type {0}", deploymentType);
}
}

}
129 changes: 88 additions & 41 deletions src/main/java/com/openshift/client/IApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,18 @@ public interface IApplication extends IOpenShiftResource {
public String getSshUrl();

/**
* Returns the git url that the application will get its initial code and configuration from.
* Returns the git url that the application will get its initial code and
* configuration from.
*
* @return the initial git url
*/
public String getInitialGitUrl();

/**
* Returns the deployment type for this application. Either "binary" or "git" currently.
* @return "binary" or "git"
*/
public String getDeploymentType();

/**
* Returns the url at which this application may be reached at.
Expand Down Expand Up @@ -103,15 +110,17 @@ public interface IApplication extends IOpenShiftResource {
/**
* Adds the given embeddable cartridge to this application.
*
* @param cartridge the cartridge that shall be added
* @param cartridge
* the cartridge that shall be added
* @throws OpenShiftException
*/
public IEmbeddedCartridge addEmbeddableCartridge(ICartridge cartridge) throws OpenShiftException;

/**
* Adds the given embeddable cartridges to this application.
*
* @param cartridges the cartridges that shall be added
* @param cartridges
* the cartridges that shall be added
* @throws OpenShiftException
*/
public List<IEmbeddedCartridge> addEmbeddableCartridges(ICartridge... cartridges) throws OpenShiftException;
Expand Down Expand Up @@ -182,8 +191,8 @@ public IEmbeddedCartridge getEmbeddedCartridge(String cartridgeName)
throws OpenShiftException;

/**
* Returns the embedded cartridge in this application. Returns <code>null</code> if none was
* found.
* Returns the embedded cartridge in this application. Returns
* <code>null</code> if none was found.
*
* @param cartridge
* @return the embedded cartridge
Expand All @@ -205,19 +214,19 @@ public IEmbeddedCartridge getEmbeddedCartridge(IEmbeddableCartridge cartridge)
public void removeEmbeddedCartridge(IEmbeddableCartridge cartridge) throws OpenShiftException;

/**
* Removes the given embedded cartridges in this application that are equal to the
* given IEmbeddableCartridge. Does nothing if the cartridge is not present
* in this application.
* Removes the given embedded cartridges in this application that are equal
* to the given IEmbeddableCartridge. Does nothing if the cartridge is not
* present in this application.
*
* @param cartridges the cartridges that shall get removed
* @param cartridges
* the cartridges that shall get removed
* @throws OpenShiftException
*/
public void removeEmbeddedCartridges(Collection<IEmbeddableCartridge> cartridges) throws OpenShiftException;


/**
* Returns the gear groups for this application.
* The collection is never cached, so each call will trigger a request to the OpenShift Broker.
* Returns the gear groups for this application. The collection is never
* cached, so each call will trigger a request to the OpenShift Broker.
*
* @return the collection of {@link IGearGroup} for this application.
* @throws OpenShiftException
Expand Down Expand Up @@ -321,6 +330,15 @@ public IEmbeddedCartridge getEmbeddedCartridge(IEmbeddableCartridge cartridge)
*/
public void scaleUp() throws OpenShiftException;

/**
* Sets the deployment type for this application. Can be either "binary" or
* "git" currently.
*
* @param deploymentType
* @return the deployment type that was set
*/
public String setDeploymentType(String deploymentType);

/**
* Add application alias
*
Expand Down Expand Up @@ -359,9 +377,11 @@ public IEmbeddedCartridge getEmbeddedCartridge(IEmbeddableCartridge cartridge)
* initialized out of the library, since the user's SSH settings may depend
* on the runtime environment (Eclipse, etc.).
*
* @param session the SSH session
* @param session
* the SSH session
*
* @deprecated use {@link IApplicationSSHSession#setSSHSession(com.jcraft.jsch.Session)}
* @deprecated use
* {@link IApplicationSSHSession#setSSHSession(com.jcraft.jsch.Session)}
*/
public void setSSHSession(Session session);

Expand Down Expand Up @@ -454,36 +474,45 @@ public IEmbeddedCartridge getEmbeddedCartridge(IEmbeddableCartridge cartridge)
/**
* Checks if the environment variable is present in the application.
*
* @param name Name of the environment variable
* @return <code>true</code> if the current instance has IEnvironmentVariables to return <br>
* <code>false</code> if the current instance has no IEnvironmentVariables to return
* @param name
* Name of the environment variable
* @return <code>true</code> if the current instance has
* IEnvironmentVariables to return <br>
* <code>false</code> if the current instance has no
* IEnvironmentVariables to return
* @throws OpenShiftSSHOperationException
*/
public boolean hasEnvironmentVariable(String name) throws OpenShiftException;

/**
* Adds an environment variable to this application.
* Adds an environment variable to this application.
*
* @param name key associated with the variable to add
* @param value value of the new variable
* @throws OpenShiftSSHOperationException - if the variable already exists
* @param name
* key associated with the variable to add
* @param value
* value of the new variable
* @throws OpenShiftSSHOperationException
* - if the variable already exists
*/
public IEnvironmentVariable addEnvironmentVariable(String name, String value) throws OpenShiftException;

/**
* Updates an environment variable to this application.
*
* @param name key associated with the variable to update
* @param value value of the new variable
* @throws OpenShiftSSHOperationException - if the variable already exists
* @param name
* key associated with the variable to update
* @param value
* value of the new variable
* @throws OpenShiftSSHOperationException
* - if the variable already exists
*/
public IEnvironmentVariable updateEnvironmentVariable(String name, String value) throws OpenShiftException;


/**
* Adds a map of environment variables to the application
*
* @param environmentVariables Map<String,String> of environment variables
* @param environmentVariables
* Map<String,String> of environment variables
* @throws OpenShiftSSHOperationException
*/
public Map<String, IEnvironmentVariable> addEnvironmentVariables(Map<String, String> environmentVariables)
Expand All @@ -492,44 +521,60 @@ public Map<String, IEnvironmentVariable> addEnvironmentVariables(Map<String, Str
/**
* Return the environment variable for the specified name
*
* @param name key to be used to locate the environment variable
* @param name
* key to be used to locate the environment variable
* @return IEnvironmentVariable associated with the provided key
* @throws OpenShiftSSHOperationException - thrown if the key does not exist
* @throws OpenShiftSSHOperationException
* - thrown if the key does not exist
*/
public IEnvironmentVariable getEnvironmentVariable(String name) throws OpenShiftException;

/**
* Return the environment variables value for the specified name
*
* @param name key to be used to locate the environment variable
* @param name
* key to be used to locate the environment variable
* @return String value associated with the provided key
* @throws OpenShiftSSHOperationException - thrown if the key does not exist
* @throws OpenShiftSSHOperationException
* - thrown if the key does not exist
*/
public String getEnvironmentVariableValue(String name);

/**
* Removes the environment variables with the given name from this application.
* Removes the environment variables with the given name from this
* application.
*
* @param name key associated with the IEnvironmentVariable to be removed
* @param name
* key associated with the IEnvironmentVariable to be removed
* @return
* @throws OpenShiftException - thrown if there is no IEnvironmentVariable associated with the explicit parameter.
* @throws OpenShiftException
* - thrown if there is no IEnvironmentVariable associated with
* the explicit parameter.
*/
public void removeEnvironmentVariable(String name) throws OpenShiftException;

/**
* Removes the environment variables with the given name from this application.
* Removes the environment variables with the given name from this
* application.
*
* @param environmentVariable IEnvironmentVariable instance which should be removed
* @param environmentVariable
* IEnvironmentVariable instance which should be removed
* @return
* @throws OpenShiftException - thrown if there is no instance of IEnvironmentVariable available to be removed
* @throws OpenShiftException
* - thrown if there is no instance of IEnvironmentVariable
* available to be removed
*/
public void removeEnvironmentVariable(IEnvironmentVariable environmentVariable);

/**
* Used to determine if environment variables exist and are available to be retrieved
* Used to determine if environment variables exist and are available to be
* retrieved
*
* @return Returns <code>true</code> if this application can list its environment variables. <br>
* Returns <code>false</code> if it cannot. Internally this translates to the presence of the link to list environment variables.
* @return Returns <code>true</code> if this application can list its
* environment variables. <br>
* Returns <code>false</code> if it cannot. Internally this
* translates to the presence of the link to list environment
* variables.
*
* @see #getEnvironmentVariablesMap()
* @see #getEnvironmentVariable(String)
Expand All @@ -538,9 +583,11 @@ public Map<String, IEnvironmentVariable> addEnvironmentVariables(Map<String, Str
public boolean canGetEnvironmentVariables();

/**
* Used to determine if the current instance is able to update environment variables.
* Used to determine if the current instance is able to update environment
* variables.
*
* @return Returns <code>true</code> if this application can augment its environment variables.<br>
* @return Returns <code>true</code> if this application can augment its
* environment variables.<br>
* Returns <code>false</code> if it cannot. <br>
*
* @see #addEnvironmentVariable(String, String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public interface IApplicationSSHSession {
* @return true if the SSH session provided to the application
* is still valid (connected).
*/
public boolean isSSHSessionConnected();
public boolean isConnected();

/**
* Returns the list of forwardable ports on OpenShift for this application.
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/com/openshift/client/IUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,30 @@ public interface IUser extends IOpenShiftResource {

public List<IOpenShiftSSHKey> getSSHKeys() throws OpenShiftException;

/**
* Deprecated, use {@link #addSSHKey(String, ISSHPublicKey)}
*
* @param name key name to use
* @param key the key to put/add
* @return
* @throws OpenShiftException
*/
@Deprecated
public IOpenShiftSSHKey putSSHKey(String name, ISSHPublicKey key) throws OpenShiftException;

/**
* Adds the given ssh key with the given name. Key names and public keys have to be unique. Throws
* OpenShiftSSHKeyException if either the key name or the public key are already used.
*
* @param name
* the name to identify the key
* @param key
* the key to add
* @return
* @throws OpenShiftException
*/
public IOpenShiftSSHKey addSSHKey(String name, ISSHPublicKey key) throws OpenShiftException;

public IOpenShiftSSHKey getSSHKeyByName(String name) throws OpenShiftUnknonwSSHKeyTypeException, OpenShiftException;

public IOpenShiftSSHKey getSSHKeyByPublicKey(String publicKey) throws OpenShiftUnknonwSSHKeyTypeException, OpenShiftException;
Expand All @@ -52,6 +74,9 @@ public interface IUser extends IOpenShiftResource {

public boolean hasSSHPublicKey(String publicKey) throws OpenShiftUnknonwSSHKeyTypeException, OpenShiftException;

public boolean removeSSHKey(String name);

@Deprecated
public void deleteKey(String name);

public int getMaxGears();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/openshift/client/SSHPublicKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private void init(File publicKeyFile) throws OpenShiftException, FileNotFoundExc
Matcher matcher = PUBLICKEY_PATTERN.matcher(keyWithIdAndComment);
if (!matcher.find()
|| matcher.groupCount() < 1) {
throw new OpenShiftException("Could not load public key from file \"{0}\"", publicKeyFile.getAbsolutePath());
throw new OpenShiftException("Could not load public key from file \"{0}\": unknown key format.", publicKeyFile.getAbsolutePath());
}

setKeyType(matcher.group(1));
Expand Down
Loading