use of io.fabric8.maven.core.util.KindAndName 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.maven.core.util.KindAndName in project fabric8-maven-plugin by fabric8io.
the class OpenShiftDependencyResources method addOpenShiftResources.
public void addOpenShiftResources(List<HasMetadata> items, boolean isAppCatalog) {
for (HasMetadata item : items) {
if (item instanceof Template) {
Template template = (Template) item;
if (!KubernetesResourceUtil.isAppCatalogResource(template) && !isAppCatalog) {
List<HasMetadata> objects = notNullList(template.getObjects());
String sourceUrl = getSourceUrlAnnotation(template);
if (Strings.isNotBlank(sourceUrl)) {
for (HasMetadata object : objects) {
setSourceUrlAnnotationIfNotSet(object, sourceUrl);
}
}
addOpenShiftResources(objects, isAppCatalog);
mergeParametersIntoMap(templateParameters, notNullList(template.getParameters()));
continue;
}
}
KindAndName key = new KindAndName(item);
HasMetadata old = openshiftDependencyResources.get(key);
if (old != null && !isAppCatalog) {
log.warn("Duplicate OpenShift resources for %s at %s and %s", key, getSourceUrlAnnotation(old), getSourceUrlAnnotation(item));
}
openshiftDependencyResources.put(key, item);
}
}
use of io.fabric8.maven.core.util.KindAndName in project fabric8-maven-plugin by fabric8io.
the class OpenShiftDependencyResources method convertKubernetesItemToOpenShift.
/**
* Returns the OpenShift dependency for the given resource if there is one
*/
public HasMetadata convertKubernetesItemToOpenShift(HasMetadata item) {
KindAndName key = new KindAndName(item);
HasMetadata answer = openshiftDependencyResources.get(key);
if (answer == null && item instanceof Deployment) {
key = new KindAndName("DeploymentConfig", getName(item));
answer = openshiftDependencyResources.get(key);
}
return answer;
}
use of io.fabric8.maven.core.util.KindAndName in project fabric8-maven-plugin by fabric8io.
the class OpenShiftDependencyResources method addMissingResources.
public void addMissingResources(List<HasMetadata> objects) {
Map<KindAndName, HasMetadata> itemMap = new HashMap<>();
for (HasMetadata item : objects) {
itemMap.put(new KindAndName(item), item);
}
// lets add any openshift specific dependencies (OAuthClient etc) which are not already added
for (Map.Entry<KindAndName, HasMetadata> entry : openshiftDependencyResources.entrySet()) {
KindAndName key = entry.getKey();
HasMetadata dependency = entry.getValue();
if (!itemMap.containsKey(key)) {
objects.add(dependency);
}
}
}
use of io.fabric8.maven.core.util.KindAndName in project fabric8-maven-plugin by fabric8io.
the class OpenShiftOverrideResources method overrideResource.
/**
* Applies any overrides if we have any for the given item
*/
public HasMetadata overrideResource(HasMetadata item) {
KindAndName key = new KindAndName(item);
HasMetadata override = map.get(key);
if (override != null) {
log.info("Overriding " + key);
HasMetadata answer = KubernetesResourceUtil.mergeResources(item, override, log, false);
if (answer != null) {
return answer;
}
}
return item;
}
Aggregations