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

dev.galasa.kubernetes.internal.properties.KubernetesNodePortProxy 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.properties;

import java.net.URL;

import dev.galasa.framework.spi.cps.CpsProperties;
import dev.galasa.kubernetes.KubernetesManagerException;
import dev.galasa.kubernetes.internal.KubernetesClusterImpl;


/**
 * Kubernetes Node Port Proxy Hostname CPS Property
 * 
 * @galasa.cps.property
 * 
 * @galasa.name kubernetes.cluster.XXXX.nodeport.proxy.hostname
 * 
 * @galasa.description Provides the hostname that NodePorts can be accessed on.
 * 
 * @galasa.required No
 * 
 * @galasa.default The hostname as specified in the API URL
 * 
 * @galasa.valid_values A valid URL hostname
 * 
 * @galasa.examples 
 * kubernetes.cluster.K8S.nodeport.proxy.hostname=cluster.org
 * 
 */
public class KubernetesNodePortProxy extends CpsProperties {

    public static String get(KubernetesClusterImpl cluster) throws KubernetesManagerException {
        try {
            String hostname = getStringNulled(KubernetesPropertiesSingleton.cps(), "cluster." + cluster.getId(), "nodeport.proxy.hostname");
            if (hostname != null) {
                return hostname;
            }
            URL api = KubernetesUrl.get(cluster);
            return api.getHost();
        } catch (Exception e) {
            throw new KubernetesManagerException("Problem retrieving the nodeport proxy hostname for the cluster " + cluster.getId(), e);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy