All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev.galasa.kubernetes.internal.resources.DeploymentImpl Maven / Gradle / Ivy

There is a newer version: 0.34.0
Show newest version
/*
 * Licensed Materials - Property of IBM
 * 
 * (c) Copyright IBM Corp. 2020.
 */
package dev.galasa.kubernetes.internal.resources;

import java.util.List;

import dev.galasa.kubernetes.IDeployment;
import dev.galasa.kubernetes.IPodLog;
import dev.galasa.kubernetes.KubernetesManagerException;
import dev.galasa.kubernetes.internal.KubernetesNamespaceImpl;
import io.kubernetes.client.openapi.models.V1Deployment;
import io.kubernetes.client.util.Yaml;

/**
 * Deployment Implementation
 * 
 * @author Michael Baylis
 *
 */
public class DeploymentImpl extends ReplicaSetHolder implements IDeployment {
    
    private final KubernetesNamespaceImpl namespace;
    private final V1Deployment deployment;

    public DeploymentImpl(KubernetesNamespaceImpl namespace, V1Deployment deployment) {
        this.namespace   = namespace;
        this.deployment = deployment;
    }

    @Override
    public String getName() {
        return deployment.getMetadata().getName();
    }

    @Override
    public TYPE getType() {
        return TYPE.Deployment;
    }

    @Override
    public String getYaml() {
        return Yaml.dump(this.deployment);
    }
    
    @Override
    public void refresh() throws KubernetesManagerException {
       throw new UnsupportedOperationException("Not developed yet"); //TODO
    }

    @Override
    public List getPodLogs(String container) throws KubernetesManagerException {
        if (deployment.getSpec() == null || deployment.getSpec().getSelector() == null) {
            throw new KubernetesManagerException("Missing Selector");
        }

        return getPodLogs(this.namespace.getCluster().getApi(), this.deployment.getSpec().getSelector(), this.namespace.getId(), container);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy