use of io.fabric8.kubernetes.api.model.KubernetesListBuilder in project fabric8-maven-plugin by fabric8io.
the class RevisionHistoryEnricherTest method testDefaultRevisionHistoryLimit.
@Test
public void testDefaultRevisionHistoryLimit() throws JsonProcessingException {
// Given
KubernetesListBuilder builder = new KubernetesListBuilder().addNewDeploymentItem().endDeploymentItem();
RevisionHistoryEnricher enricher = new RevisionHistoryEnricher(context);
// When
enricher.addMissingResources(builder);
// Then
assertRevisionHistory(builder.build(), Configs.asInt(RevisionHistoryEnricher.Config.limit.def()));
}
use of io.fabric8.kubernetes.api.model.KubernetesListBuilder in project fabric8-maven-plugin by fabric8io.
the class RevisionHistoryEnricherTest method testCustomRevisionHistoryLimit.
@Test
public void testCustomRevisionHistoryLimit() throws JsonProcessingException {
// Setup mock behaviour
final String revisionNumber = "10";
new Expectations() {
{
context.getConfig();
result = prepareEnricherConfig(revisionNumber);
}
};
// Given
KubernetesListBuilder builder = new KubernetesListBuilder().addNewDeploymentItem().endDeploymentItem();
RevisionHistoryEnricher enricher = new RevisionHistoryEnricher(context);
// When
enricher.addMissingResources(builder);
// Then
assertRevisionHistory(builder.build(), Integer.parseInt(revisionNumber));
}
use of io.fabric8.kubernetes.api.model.KubernetesListBuilder in project fabric8-maven-plugin by fabric8io.
the class KubernetesResourceUtilTest method readWholeDir.
@Test
public void readWholeDir() throws IOException {
ResourceVersioning v = new ResourceVersioning().withCoreVersion("v2").withExtensionsVersion("extensions/v2");
KubernetesListBuilder builder = KubernetesResourceUtil.readResourceFragmentsFrom(v, "pong", new File(fabric8Dir, "read-dir").listFiles());
KubernetesList list = builder.build();
assertEquals(2, list.getItems().size());
for (HasMetadata item : list.getItems()) {
assertTrue("Service".equals(item.getKind()) || "ReplicationController".equals(item.getKind()));
assertEquals("pong", item.getMetadata().getName());
assertEquals("v2", item.getApiVersion());
}
}
use of io.fabric8.kubernetes.api.model.KubernetesListBuilder in project fabric8-maven-plugin by fabric8io.
the class DebugEnricher method addMissingResources.
@Override
public void addMissingResources(KubernetesListBuilder builder) {
if (debugEnabled()) {
int count = 0;
List<HasMetadata> items = builder.getItems();
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'");
}
}
use of io.fabric8.kubernetes.api.model.KubernetesListBuilder in project fabric8-maven-plugin by fabric8io.
the class KubernetesResourceUtil method readResourceFragmentsFrom.
/**
* Read all Kubernetes resource fragments from a directory and create a {@link KubernetesListBuilder} which
* can be adapted later.
*
* @param apiVersions the api versions to use
* @param defaultName the default name to use when none is given
* @param resourceFiles files to add.
* @return the list builder
* @throws IOException
*/
public static KubernetesListBuilder readResourceFragmentsFrom(ResourceVersioning apiVersions, String defaultName, File[] resourceFiles) throws IOException {
KubernetesListBuilder builder = new KubernetesListBuilder();
if (resourceFiles != null) {
for (File file : resourceFiles) {
HasMetadata resource = getResource(apiVersions, file, defaultName);
builder.addToItems(resource);
}
}
return builder;
}
Aggregations