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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.openshift.restclient.ResourceKind;
import com.openshift.restclient.capability.CapabilityVisitor;
import com.openshift.restclient.capability.ICapability;
import com.openshift.restclient.model.IProject;
import com.openshift.restclient.model.IResource;

/**
Expand All @@ -37,6 +38,7 @@ public abstract class KubernetesResource implements IResource, ResourcePropertyK
private IClient client;
private Map<Class<? extends ICapability>, ICapability> capabilities = new HashMap<Class<? extends ICapability>, ICapability>();
private Map<String, String []> propertyKeys;
private IProject project;

protected KubernetesResource(ModelNode node, IClient client, Map<String, String []> propertyKeys){
this.node = node;
Expand Down Expand Up @@ -74,6 +76,14 @@ public <T extends ICapability, R> R accept(CapabilityVisitor<T, R> visitor, R un
return unsupportedValue;
}

@Override
public IProject getProject() {
if(this.project == null) {
this.project = client.get(ResourceKind.Project, getNamespace(), "");
}
return this.project;
}

@Override
public Map<String, String> getAnnotations() {
return asMap(ANNOTATIONS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public Project(ModelNode node, IClient client, Map<String, String []> propertyKe
initializeCapabilities(getModifiableCapabilities(), this, getClient());
}


@Override
public IProject getProject() {
return this;
}

@Override
public String getNamespace() {
if(StringUtils.isEmpty(super.getNamespace()))
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/openshift/restclient/model/IResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ public interface IResource extends ICapable {
*/
String getNamespace();

/**
* Return the project of the resource which
* corresponds to the namespace
* @return
*/
IProject getProject();

/**
* Retrieves the labels associated with the resource
* @return
Expand Down