Java Code Examples for io.fabric8.kubernetes.api.model.KubernetesListBuilder#buildItems()
The following examples show how to use
io.fabric8.kubernetes.api.model.KubernetesListBuilder#buildItems() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseEnricher.java From jkube with Eclipse Public License 2.0 | 6 votes |
/** * This method just makes sure that the replica count provided in XML config * overrides the default option; and resource fragments are always given * topmost priority. * * @param builder kubernetes list builder containing objects * @param xmlResourceConfig xml resource config from plugin configuration * @param defaultValue default value * @return resolved replica count */ protected int getReplicaCount(KubernetesListBuilder builder, ResourceConfig xmlResourceConfig, int defaultValue) { if (xmlResourceConfig != null) { List<HasMetadata> items = builder.buildItems(); for (HasMetadata item : items) { if (item instanceof Deployment && ((Deployment)item).getSpec().getReplicas() != null) { return ((Deployment)item).getSpec().getReplicas(); } if (item instanceof DeploymentConfig && ((DeploymentConfig)item).getSpec().getReplicas() != null) { return ((DeploymentConfig)item).getSpec().getReplicas(); } } return xmlResourceConfig.getReplicas() > 0 ? xmlResourceConfig.getReplicas() : defaultValue; } return defaultValue; }
Example 2
Source File: DebugEnricher.java From jkube with Eclipse Public License 2.0 | 6 votes |
@Override public void create(PlatformMode platformMode, KubernetesListBuilder builder) { if (debugEnabled()) { int count = 0; List<HasMetadata> items = builder.buildItems(); if (items != null) { for (HasMetadata item : items) { if (enableDebug(item)) { count++; } } } if (count > 0) { builder.withItems(items); } log.verbose("Enabled debugging on " + count + " resource(s) thanks to the " + ENABLE_DEBUG_MAVEN_PROPERTY + " property"); } else { log.verbose("Debugging not enabled. To enable try setting the " + ENABLE_DEBUG_MAVEN_PROPERTY + " maven or system property to 'true'"); } }
Example 3
Source File: KubernetesResourceUtil.java From jkube with Eclipse Public License 2.0 | 5 votes |
public static void removeItemFromKubernetesBuilder(KubernetesListBuilder builder, HasMetadata item) { List<HasMetadata> items = builder.buildItems(); List<HasMetadata> newListItems = new ArrayList<>(); for(HasMetadata listItem : items) { if(!listItem.equals(item)) { newListItems.add(listItem); } } builder.withItems(newListItems); }
Example 4
Source File: KubernetesResourceUtil.java From jkube with Eclipse Public License 2.0 | 5 votes |
public static boolean checkForKind(KubernetesListBuilder builder, String... kinds) { Set<String> kindSet = new HashSet<>(Arrays.asList(kinds)); for (HasMetadata item : builder.buildItems()) { if (kindSet.contains(item.getKind())) { return true; } } return false; }
Example 5
Source File: ServiceAccountEnricher.java From jkube with Eclipse Public License 2.0 | 5 votes |
private ServiceAccount getServiceAccountFromList(KubernetesListBuilder builder, String serviceAccountName) { for(HasMetadata item : builder.buildItems()) { if(item instanceof ServiceAccount && item.getMetadata().getName().equals(serviceAccountName)) { return (ServiceAccount)item; } } return null; }
Example 6
Source File: RemoveBuildAnnotationsEnricher.java From jkube with Eclipse Public License 2.0 | 5 votes |
@Override public void enrich(PlatformMode platformMode, KubernetesListBuilder builder) { List<HasMetadata> items = builder.buildItems(); for (HasMetadata item : items) { removeBuildAnnotations(item); } }
Example 7
Source File: ProjectEnricher.java From jkube with Eclipse Public License 2.0 | 5 votes |
@Override public void create(PlatformMode platformMode, KubernetesListBuilder builder) { if(platformMode == PlatformMode.openshift) { for(HasMetadata item : builder.buildItems()) { if(item instanceof Namespace) { Project project = convertToProject((Namespace) item); removeItemFromKubernetesBuilder(builder, item); builder.addToItems(project); } } } }
Example 8
Source File: ExposeEnricher.java From jkube with Eclipse Public License 2.0 | 5 votes |
@Override public void create(PlatformMode platformMode, KubernetesListBuilder builder) { List<HasMetadata> items = builder.buildItems(); if (items != null) { for (HasMetadata item : items) { if (item instanceof Service) { Service service = (Service) item; enrichService(service); } } } }