core/src/main/java/io/fabric8/maven/core/service/ApplyService.java
private void applyEntity(Object dto, String sourceName) throws Exception {
        if (dto instanceof Pod) {
            applyPod((Pod) dto, sourceName);
        } else if (dto instanceof ReplicationController) {
            applyReplicationController((ReplicationController) dto, sourceName);
        } else if (dto instanceof Service) {
            applyService((Service) dto, sourceName);
        } else if (dto instanceof Route) {
            applyRoute((Route) dto, sourceName);
        } else if (dto instanceof BuildConfig) {
            applyBuildConfig((BuildConfig) dto, sourceName);
        } else if (dto instanceof DeploymentConfig) {
            DeploymentConfig resource = (DeploymentConfig) dto;
            OpenShiftClient openShiftClient = getOpenShiftClient();
            if (openShiftClient != null) {
                applyResource(resource, sourceName, openShiftClient.deploymentConfigs());
            } else {
                log.warn("Not connected to OpenShift cluster so cannot apply entity " + dto);
            }
        } else if (dto instanceof RoleBinding) {
            applyRoleBinding((RoleBinding) dto, sourceName);
        } else if (dto instanceof Role) {
            Role resource = (Role) dto;
            OpenShiftClient openShiftClient = getOpenShiftClient();
            if (openShiftClient != null) {
                applyResource(resource, sourceName, openShiftClient.rbac().roles());
            } else {
                log.warn("Not connected to OpenShift cluster so cannot apply entity " + dto);
            }
        } else if (dto instanceof ImageStream) {
            applyImageStream((ImageStream) dto, sourceName);
        } else if (dto instanceof OAuthClient) {
            applyOAuthClient((OAuthClient) dto, sourceName);
        } else if (dto instanceof Template) {
            applyTemplate((Template) dto, sourceName);
        } else if (dto instanceof ServiceAccount) {
            applyServiceAccount((ServiceAccount) dto, sourceName);
        } else if (dto instanceof Secret) {
            applySecret((Secret) dto, sourceName);
        } else if (dto instanceof ConfigMap) {
            applyResource((ConfigMap) dto, sourceName, kubernetesClient.configMaps());
        } else if (dto instanceof DaemonSet) {
            applyResource((DaemonSet) dto, sourceName, kubernetesClient.extensions().daemonSets());
        } else if (dto instanceof Deployment) {
            applyResource((Deployment) dto, sourceName, kubernetesClient.extensions().deployments());
        } else if (dto instanceof ReplicaSet) {
            applyResource((ReplicaSet) dto, sourceName, kubernetesClient.extensions().replicaSets());
        } else if (dto instanceof StatefulSet) {
            applyResource((StatefulSet) dto, sourceName, kubernetesClient.apps().statefulSets());
        } else if (dto instanceof Ingress) {
            applyResource((Ingress) dto, sourceName, kubernetesClient.extensions().ingresses());
        } else if (dto instanceof PersistentVolumeClaim) {
            applyPersistentVolumeClaim((PersistentVolumeClaim) dto, sourceName);
        } else if (dto instanceof HasMetadata) {
            HasMetadata entity = (HasMetadata) dto;
            try {
                log.info("Applying " + getKind(entity) + " " + getName(entity) + " from " + sourceName);
                kubernetesClient.resource(entity).inNamespace(getNamespace()).createOrReplace();
            } catch (Exception e) {
                onApplyError("Failed to create " + getKind(entity) + " from " + sourceName + ". " + e, e);
            }
        } else {
            throw new IllegalArgumentException("Unknown entity type " + dto);
        }
    }
private void applyEntity(Object dto, String sourceName) throws Exception {
        if (dto instanceof Pod) {
            applyPod((Pod) dto, sourceName);
        } else if (dto instanceof ReplicationController) {
            applyReplicationController((ReplicationController) dto, sourceName);
        } else if (dto instanceof Service) {
            applyService((Service) dto, sourceName);
        } else if (dto instanceof Route) {
            applyRoute((Route) dto, sourceName);
        } else if (dto instanceof BuildConfig) {
            applyBuildConfig((BuildConfig) dto, sourceName);
        } else if (dto instanceof DeploymentConfig) {
            DeploymentConfig resource = (DeploymentConfig) dto;
            OpenShiftClient openShiftClient = getOpenShiftClient();
            if (openShiftClient != null) {
                applyResource(resource, sourceName, openShiftClient.deploymentConfigs());
            } else {
                log.warn("Not connected to OpenShift cluster so cannot apply entity " + dto);
            }
        } else if (dto instanceof RoleBinding) {
            applyRoleBinding((RoleBinding) dto, sourceName);
        } else if (dto instanceof Role) {
            Role resource = (Role) dto;
            OpenShiftClient openShiftClient = getOpenShiftClient();
            if (openShiftClient != null) {
                applyResource(resource, sourceName, openShiftClient.rbac().roles());
            } else {
                log.warn("Not connected to OpenShift cluster so cannot apply entity " + dto);
            }
        } else if (dto instanceof ImageStream) {
            applyImageStream((ImageStream) dto, sourceName);
        } else if (dto instanceof OAuthClient) {
            applyOAuthClient((OAuthClient) dto, sourceName);
        } else if (dto instanceof Template) {
            applyTemplate((Template) dto, sourceName);
        } else if (dto instanceof ServiceAccount) {
            applyServiceAccount((ServiceAccount) dto, sourceName);
        } else if (dto instanceof Secret) {
            applySecret((Secret) dto, sourceName);
        } else if (dto instanceof ConfigMap) {
            applyResource((ConfigMap) dto, sourceName, kubernetesClient.configMaps());
        } else if (dto instanceof DaemonSet) {
            applyResource((DaemonSet) dto, sourceName, kubernetesClient.extensions().daemonSets());
        } else if (dto instanceof Deployment) {
            applyResource((Deployment) dto, sourceName, kubernetesClient.extensions().deployments());
        } else if (dto instanceof ReplicaSet) {
            applyResource((ReplicaSet) dto, sourceName, kubernetesClient.extensions().replicaSets());
        } else if (dto instanceof StatefulSet) {
            applyResource((StatefulSet) dto, sourceName, kubernetesClient.apps().statefulSets());
        } else if (dto instanceof Ingress) {
            applyResource((Ingress) dto, sourceName, kubernetesClient.extensions().ingresses());
        } else if (dto instanceof PersistentVolumeClaim) {
            applyPersistentVolumeClaim((PersistentVolumeClaim) dto, sourceName);
        } else if (dto instanceof HasMetadata) {
            HasMetadata entity = (HasMetadata) dto;
            try {
                log.info("Applying " + getKind(entity) + " " + getName(entity) + " from " + sourceName);
                kubernetesClient.resource(entity).inNamespace(getNamespace()).createOrReplace();
            } catch (Exception e) {
                onApplyError("Failed to create " + getKind(entity) + " from " + sourceName + ". " + e, e);
            }
        } else {
            throw new IllegalArgumentException("Unknown entity type " + dto);
        }
    }
private void applyEntity ( Object dto , String sourceName ) throws Exception { if ( dto instanceof Pod ) { applyPod ( ( Pod ) dto , sourceName ) ; } else if ( dto instanceof ReplicationController ) { applyReplicationController ( ( ReplicationController ) dto , sourceName ) ; } else if ( dto instanceof Service ) { applyService ( ( Service ) dto , sourceName ) ; } else if ( dto instanceof Route ) { applyRoute ( ( Route ) dto , sourceName ) ; } else if ( dto instanceof BuildConfig ) { applyBuildConfig ( ( BuildConfig ) dto , sourceName ) ; } else if ( dto instanceof DeploymentConfig ) { DeploymentConfig resource = ( DeploymentConfig ) dto ; OpenShiftClient openShiftClient = getOpenShiftClient ( ) ; if ( openShiftClient != null ) { applyResource ( resource , sourceName , openShiftClient . deploymentConfigs ( ) ) ; } else { log . warn ( "Not connected to OpenShift cluster so cannot apply entity " + dto ) ; } } else if ( dto instanceof RoleBinding ) { applyRoleBinding ( ( RoleBinding ) dto , sourceName ) ; } else if ( dto instanceof Role ) { Role resource = ( Role ) dto ; OpenShiftClient openShiftClient = getOpenShiftClient ( ) ; if ( openShiftClient != null ) { applyResource ( resource , sourceName , openShiftClient . rbac ( ) . roles ( ) ) ; } else { log . warn ( "Not connected to OpenShift cluster so cannot apply entity " + dto ) ; } } else if ( dto instanceof ImageStream ) { applyImageStream ( ( ImageStream ) dto , sourceName ) ; } else if ( dto instanceof OAuthClient ) { applyOAuthClient ( ( OAuthClient ) dto , sourceName ) ; } else if ( dto instanceof Template ) { applyTemplate ( ( Template ) dto , sourceName ) ; } else if ( dto instanceof ServiceAccount ) { applyServiceAccount ( ( ServiceAccount ) dto , sourceName ) ; } else if ( dto instanceof Secret ) { applySecret ( ( Secret ) dto , sourceName ) ; } else if ( dto instanceof ConfigMap ) { applyResource ( ( ConfigMap ) dto , sourceName , kubernetesClient . configMaps ( ) ) ; } else if ( dto instanceof DaemonSet ) { applyResource ( ( DaemonSet ) dto , sourceName , kubernetesClient . extensions ( ) . daemonSets ( ) ) ; } else if ( dto instanceof Deployment ) { applyResource ( ( Deployment ) dto , sourceName , kubernetesClient . extensions ( ) . deployments ( ) ) ; } else if ( dto instanceof ReplicaSet ) { applyResource ( ( ReplicaSet ) dto , sourceName , kubernetesClient . extensions ( ) . replicaSets ( ) ) ; } else if ( dto instanceof StatefulSet ) { applyResource ( ( StatefulSet ) dto , sourceName , kubernetesClient . apps ( ) . statefulSets ( ) ) ; } else if ( dto instanceof Ingress ) { applyResource ( ( Ingress ) dto , sourceName , kubernetesClient . extensions ( ) . ingresses ( ) ) ; } else if ( dto instanceof PersistentVolumeClaim ) { applyPersistentVolumeClaim ( ( PersistentVolumeClaim ) dto , sourceName ) ; } else if ( dto instanceof HasMetadata ) { HasMetadata entity = ( HasMetadata ) dto ; try { log . info ( "Applying " + getKind ( entity ) + " " + getName ( entity ) + " from " + sourceName ) ; kubernetesClient . resource ( entity ) . inNamespace ( getNamespace ( ) ) . createOrReplace ( ) ; } catch ( Exception e ) { onApplyError ( "Failed to create " + getKind ( entity ) + " from " + sourceName + ". " + e , e ) ; } } else { throw new IllegalArgumentException ( "Unknown entity type " + dto ) ; } }
Applies the given DTOs onto the Kubernetes master
Applies the given DTOs onto the Kubernetes master