use of io.fabric8.kubernetes.api.model.HasMetadata in project kie-wb-common by kiegroup.
the class OpenShiftClient method getDeploymentConfig.
private DeploymentConfig getDeploymentConfig(KubernetesList list, String svcName) {
if (list != null) {
List<HasMetadata> items = list.getItems();
String dcName = null;
for (HasMetadata item : items) {
if (item instanceof Service && item.getMetadata().getName().equals(svcName)) {
Map<String, String> selector = ((Service) item).getSpec().getSelector();
dcName = selector.get("deploymentconfig");
if (dcName == null) {
dcName = selector.get("deploymentConfig");
}
break;
}
}
if (dcName != null) {
for (HasMetadata item : items) {
if (item instanceof DeploymentConfig && item.getMetadata().getName().equals(dcName)) {
return (DeploymentConfig) item;
}
}
}
}
return null;
}
use of io.fabric8.kubernetes.api.model.HasMetadata in project kie-wb-common by kiegroup.
the class OpenShiftTemplate method load.
@SuppressWarnings({ "rawtypes", "unchecked" })
private Template load(InputStream templateStream) {
String generatedName = Utils.randomString("template-", 10);
Template temp = null;
Object item = Serialization.unmarshal(templateStream);
if (item instanceof Template) {
temp = (Template) item;
} else if (item instanceof HasMetadata) {
HasMetadata h = (HasMetadata) item;
temp = new TemplateBuilder().withNewMetadata().withName(generatedName).withNamespace(h != null && h.getMetadata() != null ? h.getMetadata().getNamespace() : null).endMetadata().withObjects(h).build();
} else if (item instanceof KubernetesResourceList) {
List<HasMetadata> list = ((KubernetesResourceList<HasMetadata>) item).getItems();
temp = new TemplateBuilder().withNewMetadata().withName(generatedName).endMetadata().withObjects(list.toArray(new HasMetadata[list.size()])).build();
} else if (item instanceof HasMetadata[]) {
temp = new TemplateBuilder().withNewMetadata().withName(generatedName).endMetadata().withObjects((HasMetadata[]) item).build();
} else if (item instanceof Collection) {
List<HasMetadata> items = new ArrayList<>();
for (Object o : (Collection) item) {
if (o instanceof HasMetadata) {
items.add((HasMetadata) o);
}
}
temp = new TemplateBuilder().withNewMetadata().withName(generatedName).endMetadata().withObjects(items.toArray(new HasMetadata[items.size()])).build();
}
return temp;
}
use of io.fabric8.kubernetes.api.model.HasMetadata in project fabric8-maven-plugin by fabric8io.
the class ExposeEnricher method addMissingResources.
@Override
public void addMissingResources(KubernetesListBuilder builder) {
int serviceCount = 0;
List<HasMetadata> items = builder.getItems();
if (items != null) {
for (HasMetadata item : items) {
if (item instanceof Service) {
Service service = (Service) item;
enrichService(service);
serviceCount++;
}
}
}
}
use of io.fabric8.kubernetes.api.model.HasMetadata in project fabric8-maven-plugin by fabric8io.
the class DependencyEnricherTest method checkUniqueResources.
private boolean checkUniqueResources(List<HasMetadata> resourceList) {
Map<KindAndName, Integer> resourceMap = new HashMap<>();
for (int index = 0; index < resourceList.size(); index++) {
KindAndName aKey = new KindAndName(resourceList.get(index));
if (resourceMap.containsKey(aKey))
return false;
resourceMap.put(aKey, index);
}
return true;
}
use of io.fabric8.kubernetes.api.model.HasMetadata in project fabric8-maven-plugin by fabric8io.
the class NameEnricher method getOrCreateMetadata.
private ObjectMeta getOrCreateMetadata(HasMetadata resource) {
ObjectMeta metadata = resource.getMetadata();
if (metadata == null) {
metadata = new ObjectMeta();
resource.setMetadata(metadata);
}
return metadata;
}
Aggregations