// Path: core/src/main/java/com/liveperson/ephemerals/deploy/Deployment.java
// public final class Deployment {
// 
//     /*
//      * Deployment ID: composed by DeploymentUnit name + random string.
//      */
//     private final String id;
// 
//     private final DeploymentUnit deploymentUnit;
// 
//     private final DeploymentConfiguration deploymentConfiguration;
// 
//     public Deployment(Builder builder) {
//         this.deploymentUnit = builder.deploymentUnit;
//         this.deploymentConfiguration = builder.deploymentConfiguration;
//         this.id = DeploymentIdentifierGenerator.generate(builder.deploymentUnit.getName());
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public DeploymentUnit getDeploymentUnit() {
//         return deploymentUnit;
//     }
// 
//     public DeploymentConfiguration getDeploymentConfiguration() {
//         return deploymentConfiguration;
//     }
// 
//     /**
//      *
//      */
//     public static class DeploymentIdentifierGenerator {
// 
//         private final static SecureRandom random = new SecureRandom();
// 
//         public static String generate(String prefix) {
//             return prefix + "-" + new BigInteger(32, random).toString(32);
//         }
//     }
// 
//     public static class Builder {
// 
//         private DeploymentUnit deploymentUnit;
//         private DeploymentConfiguration deploymentConfiguration;
// 
//         public Builder (DeploymentUnit deploymentUnit, DeploymentConfiguration deploymentConfiguration) {
//             this.deploymentUnit = deploymentUnit;
//             this.deploymentConfiguration = deploymentConfiguration;
//         }
// 
//         public Deployment build() {
//             return new Deployment(this);
//         }
//     }
// 
// }
// 
// Path: core/src/main/java/com/liveperson/ephemerals/deploy/unit/ContainerizedDeploymentUnit.java
// public class ContainerizedDeploymentUnit extends DeploymentUnit {
// 
//     private String image;
// 
//     public ContainerizedDeploymentUnit(Builder builder) {
//         super(builder);
//         this.image = builder.image;
//     }
// 
//     public String getImage() {
//         return image;
//     }
// 
//     public static class Builder extends DeploymentUnit.Builder {
// 
//         private String image;
// 
//         public Builder(String name, String image) {
//             super(name);
//             this.image = image;
//         }
// 
//         public ContainerizedDeploymentUnit build() {
//             return new ContainerizedDeploymentUnit(this);
//         }
// 
//     }
// 
// 
// }
// 
// Path: providers/kubernetes/src/main/java/com/liveperson/ephemerals/provider/kubernetes/KubernetesDeploymentHandler.java
// public final static String DEPLOYMENT_LABEL_KEY = "ephemeral-id";


import com.liveperson.ephemerals.deploy.Deployment;
import com.liveperson.ephemerals.deploy.probe.*;
import com.liveperson.ephemerals.deploy.unit.ContainerizedDeploymentUnit;
import com.liveperson.ephemerals.deploy.volume.*;
import io.fabric8.kubernetes.api.model.*;
import io.fabric8.kubernetes.api.model.Probe;
import io.fabric8.kubernetes.api.model.Volume;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import static com.liveperson.ephemerals.provider.kubernetes.KubernetesDeploymentHandler.DEPLOYMENT_LABEL_KEY;
                    .withPeriodSeconds(probe.getPeriod())
                    .withFailureThreshold(10)
                    .build();
        }
        else if (probe instanceof CommandProbe) {
            return new ProbeBuilder()
                    .withExec(
                            new ExecActionBuilder()
                                    .withCommand(((CommandProbe) probe).getCmd())
                                    .build()
                    )
                    .withTimeoutSeconds(probe.getTimeout())
                    .withInitialDelaySeconds(probe.getDelay())
                    .withPeriodSeconds(probe.getPeriod())
                    .withFailureThreshold(10)
                    .build();
        }
        else throw new UnsupportedOperationException("Unsupported probe type " + probe.getClass().getName());
    }

    @Override
    public ReplicationController replicationController(Deployment deployment) {

        ReplicationController rc = new ReplicationControllerBuilder()
                .withNewMetadata()
                .withName(deployment.getId())
                .addToLabels(DEPLOYMENT_LABEL_KEY,deployment.getId())
                .endMetadata()
                .withNewSpec()
                .withReplicas(deployment.getDeploymentConfiguration().getReplicas())
// Path: core/src/main/java/com/liveperson/ephemerals/deploy/Deployment.java
// public final class Deployment {
// 
//     /*
//      * Deployment ID: composed by DeploymentUnit name + random string.
//      */
//     private final String id;
// 
//     private final DeploymentUnit deploymentUnit;
// 
//     private final DeploymentConfiguration deploymentConfiguration;
// 
//     public Deployment(Builder builder) {
//         this.deploymentUnit = builder.deploymentUnit;
//         this.deploymentConfiguration = builder.deploymentConfiguration;
//         this.id = DeploymentIdentifierGenerator.generate(builder.deploymentUnit.getName());
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public DeploymentUnit getDeploymentUnit() {
//         return deploymentUnit;
//     }
// 
//     public DeploymentConfiguration getDeploymentConfiguration() {
//         return deploymentConfiguration;
//     }
// 
//     /**
//      *
//      */
//     public static class DeploymentIdentifierGenerator {
// 
//         private final static SecureRandom random = new SecureRandom();
// 
//         public static String generate(String prefix) {
//             return prefix + "-" + new BigInteger(32, random).toString(32);
//         }
//     }
// 
//     public static class Builder {
// 
//         private DeploymentUnit deploymentUnit;
//         private DeploymentConfiguration deploymentConfiguration;
// 
//         public Builder (DeploymentUnit deploymentUnit, DeploymentConfiguration deploymentConfiguration) {
//             this.deploymentUnit = deploymentUnit;
//             this.deploymentConfiguration = deploymentConfiguration;
//         }
// 
//         public Deployment build() {
//             return new Deployment(this);
//         }
//     }
// 
// }
// 
// Path: core/src/main/java/com/liveperson/ephemerals/deploy/unit/ContainerizedDeploymentUnit.java
// public class ContainerizedDeploymentUnit extends DeploymentUnit {
// 
//     private String image;
// 
//     public ContainerizedDeploymentUnit(Builder builder) {
//         super(builder);
//         this.image = builder.image;
//     }
// 
//     public String getImage() {
//         return image;
//     }
// 
//     public static class Builder extends DeploymentUnit.Builder {
// 
//         private String image;
// 
//         public Builder(String name, String image) {
//             super(name);
//             this.image = image;
//         }
// 
//         public ContainerizedDeploymentUnit build() {
//             return new ContainerizedDeploymentUnit(this);
//         }
// 
//     }
// 
// 
// }
// 
// Path: providers/kubernetes/src/main/java/com/liveperson/ephemerals/provider/kubernetes/KubernetesDeploymentHandler.java
// public final static String DEPLOYMENT_LABEL_KEY = "ephemeral-id";


// Path: providers/kubernetes/src/main/java/com/liveperson/ephemerals/provider/kubernetes/DefaultKubernetesDeploymentStrategy.java
import com.liveperson.ephemerals.deploy.Deployment;
import com.liveperson.ephemerals.deploy.probe.*;
import com.liveperson.ephemerals.deploy.unit.ContainerizedDeploymentUnit;
import com.liveperson.ephemerals.deploy.volume.*;
import io.fabric8.kubernetes.api.model.*;
import io.fabric8.kubernetes.api.model.Probe;
import io.fabric8.kubernetes.api.model.Volume;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import static com.liveperson.ephemerals.provider.kubernetes.KubernetesDeploymentHandler.DEPLOYMENT_LABEL_KEY;

                    .withPeriodSeconds(probe.getPeriod())
                    .withFailureThreshold(10)
                    .build();
        }
        else if (probe instanceof CommandProbe) {
            return new ProbeBuilder()
                    .withExec(
                            new ExecActionBuilder()
                                    .withCommand(((CommandProbe) probe).getCmd())
                                    .build()
                    )
                    .withTimeoutSeconds(probe.getTimeout())
                    .withInitialDelaySeconds(probe.getDelay())
                    .withPeriodSeconds(probe.getPeriod())
                    .withFailureThreshold(10)
                    .build();
        }
        else throw new UnsupportedOperationException("Unsupported probe type " + probe.getClass().getName());
    }

    @Override
    public ReplicationController replicationController(Deployment deployment) {

        ReplicationController rc = new ReplicationControllerBuilder()
                .withNewMetadata()
                .withName(deployment.getId())
                .addToLabels(DEPLOYMENT_LABEL_KEY,deployment.getId())
                .endMetadata()
                .withNewSpec()
                .withReplicas(deployment.getDeploymentConfiguration().getReplicas())
                .addToSelector(DEPLOYMENT_LABEL_KEY,deployment.getId())