use of io.fabric8.arquillian.kubernetes.log.Logger in project fabric8-maven-plugin by fabric8io.
the class ResourceValidatorTest method testValidKubernetesResourcesDirectory.
@Test
public void testValidKubernetesResourcesDirectory() throws IOException, URISyntaxException {
// Given
URL fileUrl = ResourceValidatorTest.class.getResource("/validations/kubernetes");
// When
ResourceValidator resourceValidator = new ResourceValidator(Paths.get(fileUrl.toURI()).toFile(), ResourceClassifier.KUBERNETES, logger);
int resources = resourceValidator.validate();
// Then
Assert.assertEquals(2, resources);
}
use of io.fabric8.arquillian.kubernetes.log.Logger in project fabric8-maven-plugin by fabric8io.
the class ResourceValidatorTest method testInvalidKubernetesPodSpec.
@Test
public void testInvalidKubernetesPodSpec() throws IOException, URISyntaxException {
// Given
URL fileUrl = ResourceValidatorTest.class.getResource("/validations/kubernetes-deploy-invalid.yml");
// When
ResourceValidator resourceValidator = new ResourceValidator(Paths.get(fileUrl.toURI()).toFile(), ResourceClassifier.KUBERNETES, logger);
// Then
thrown.expect(ConstraintViolationException.class);
thrown.expect(Matchers.hasProperty("constraintViolations", IsCollectionWithSize.hasSize(2)));
// On
resourceValidator.validate();
}
use of io.fabric8.arquillian.kubernetes.log.Logger in project fabric8-maven-plugin by fabric8io.
the class ResourceValidatorTest method testValidOpenShiftResources.
@Test
public void testValidOpenShiftResources() throws IOException, URISyntaxException {
// Given
URL fileUrl = ResourceValidatorTest.class.getResource("/validations/openshift-deploymentconfig.yml");
// When
ResourceValidator resourceValidator = new ResourceValidator(Paths.get(fileUrl.toURI()).toFile(), ResourceClassifier.OPENSHIFT, logger);
int resources = resourceValidator.validate();
// Then
Assert.assertEquals(1, resources);
}
use of io.fabric8.arquillian.kubernetes.log.Logger in project fabric8-maven-plugin by fabric8io.
the class ResourceValidatorTest method testValidOpenshiftResourcesDirectory.
@Test
public void testValidOpenshiftResourcesDirectory() throws IOException, URISyntaxException {
// Given
URL fileUrl = ResourceValidatorTest.class.getResource("/validations/openshift");
// When
ResourceValidator resourceValidator = new ResourceValidator(Paths.get(fileUrl.toURI()).toFile(), ResourceClassifier.OPENSHIFT, logger);
int resources = resourceValidator.validate();
// Then
Assert.assertEquals(2, resources);
}
use of io.fabric8.arquillian.kubernetes.log.Logger in project fabric8-maven-plugin by fabric8io.
the class KubernetesClientUtil method withSelector.
public static FilterWatchListDeletable<Pod, PodList, Boolean, Watch, Watcher<Pod>> withSelector(NonNamespaceOperation<Pod, PodList, DoneablePod, PodResource<Pod, DoneablePod>> pods, LabelSelector selector, Logger log) {
FilterWatchListDeletable<Pod, PodList, Boolean, Watch, Watcher<Pod>> answer = pods;
Map<String, String> matchLabels = selector.getMatchLabels();
if (matchLabels != null && !matchLabels.isEmpty()) {
answer = answer.withLabels(matchLabels);
}
List<LabelSelectorRequirement> matchExpressions = selector.getMatchExpressions();
if (matchExpressions != null) {
for (LabelSelectorRequirement expression : matchExpressions) {
String key = expression.getKey();
List<String> values = expression.getValues();
if (Strings.isNullOrBlank(key)) {
log.warn("Ignoring empty key in selector expression %s", expression);
continue;
}
if (values == null || values.isEmpty()) {
log.warn("Ignoring empty values in selector expression %s", expression);
continue;
}
String[] valuesArray = values.toArray(new String[values.size()]);
String operator = expression.getOperator();
switch(operator) {
case "In":
answer = answer.withLabelIn(key, valuesArray);
break;
case "NotIn":
answer = answer.withLabelNotIn(key, valuesArray);
break;
default:
log.warn("Ignoring unknown operator %s in selector expression %s", operator, expression);
}
}
}
return answer;
}
Aggregations