Search in sources :

Example 96 with HasMetadata

use of io.fabric8.kubernetes.api.model.HasMetadata in project fabric8-maven-plugin by fabric8io.

the class DebugEnricher method enableDebug.

private boolean enableDebug(HasMetadata entity) {
    if (entity instanceof Deployment) {
        Deployment resource = (Deployment) entity;
        DeploymentSpec spec = resource.getSpec();
        if (spec != null) {
            return enableDebugging(entity, spec.getTemplate());
        }
    } else if (entity instanceof ReplicaSet) {
        ReplicaSet resource = (ReplicaSet) entity;
        ReplicaSetSpec spec = resource.getSpec();
        if (spec != null) {
            return enableDebugging(entity, spec.getTemplate());
        }
    } else if (entity instanceof ReplicationController) {
        ReplicationController resource = (ReplicationController) entity;
        ReplicationControllerSpec spec = resource.getSpec();
        if (spec != null) {
            return enableDebugging(entity, spec.getTemplate());
        }
    } else if (entity instanceof DeploymentConfig) {
        DeploymentConfig resource = (DeploymentConfig) entity;
        DeploymentConfigSpec spec = resource.getSpec();
        if (spec != null) {
            return enableDebugging(entity, spec.getTemplate());
        }
    }
    return false;
}
Also used : DeploymentSpec(io.fabric8.kubernetes.api.model.extensions.DeploymentSpec) ReplicaSetSpec(io.fabric8.kubernetes.api.model.extensions.ReplicaSetSpec) ReplicationController(io.fabric8.kubernetes.api.model.ReplicationController) Deployment(io.fabric8.kubernetes.api.model.extensions.Deployment) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) DeploymentConfigSpec(io.fabric8.openshift.api.model.DeploymentConfigSpec) ReplicaSet(io.fabric8.kubernetes.api.model.extensions.ReplicaSet) ReplicationControllerSpec(io.fabric8.kubernetes.api.model.ReplicationControllerSpec)

Example 97 with HasMetadata

use of io.fabric8.kubernetes.api.model.HasMetadata in project fabric8-maven-plugin by fabric8io.

the class KubernetesResourceUtilTest method job.

@Test
public void job() throws Exception {
    HasMetadata ret = getResource(DEFAULT_RESOURCE_VERSIONING, new File(fabric8Dir, "job.yml"), "app");
    assertEquals("Job", ret.getKind());
    assertEquals(JOB_VERSION, ret.getApiVersion());
}
Also used : HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) File(java.io.File) Test(org.junit.Test)

Example 98 with HasMetadata

use of io.fabric8.kubernetes.api.model.HasMetadata in project fabric8-maven-plugin by fabric8io.

the class KubernetesResourceUtilTest method withValue.

@Test
public void withValue() throws IOException {
    HasMetadata ret = getResource(DEFAULT_RESOURCE_VERSIONING, new File(fabric8Dir, "named-svc.yaml"), "app");
    assertEquals(API_VERSION, ret.getApiVersion());
    assertEquals("Service", ret.getKind());
    assertEquals("pong", ret.getMetadata().getName());
}
Also used : HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) File(java.io.File) Test(org.junit.Test)

Example 99 with HasMetadata

use of io.fabric8.kubernetes.api.model.HasMetadata in project fabric8-maven-plugin by fabric8io.

the class KubernetesResourceUtilTest method noNameInFileAndNotInMetadata.

@Test
public void noNameInFileAndNotInMetadata() throws IOException {
    HasMetadata ret = getResource(DEFAULT_RESOURCE_VERSIONING, new File(fabric8Dir, "svc.yml"), "app");
    assertEquals("Service", ret.getKind());
    assertEquals("app", ret.getMetadata().getName());
}
Also used : HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) File(java.io.File) Test(org.junit.Test)

Example 100 with HasMetadata

use of io.fabric8.kubernetes.api.model.HasMetadata in project fabric8-maven-plugin by fabric8io.

the class KubernetesResourceUtilTest method containsKind.

@Test
public void containsKind() throws Exception {
    HasMetadata ret = getResource(DEFAULT_RESOURCE_VERSIONING, new File(fabric8Dir, "contains_kind.yml"), "app");
    assertEquals("ReplicationController", ret.getKind());
}
Also used : HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) File(java.io.File) Test(org.junit.Test)

Aggregations

HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)90 Test (org.junit.Test)27 ArrayList (java.util.ArrayList)25 File (java.io.File)24 IOException (java.io.IOException)24 Template (io.fabric8.openshift.api.model.Template)19 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)18 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)18 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)18 KubernetesList (io.fabric8.kubernetes.api.model.KubernetesList)17 DeploymentConfig (io.fabric8.openshift.api.model.DeploymentConfig)16 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)14 ReplicationController (io.fabric8.kubernetes.api.model.ReplicationController)14 Service (io.fabric8.kubernetes.api.model.Service)14 URL (java.net.URL)11 HashMap (java.util.HashMap)11 ReplicaSet (io.fabric8.kubernetes.api.model.extensions.ReplicaSet)10 Map (java.util.Map)10 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)10 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)9