/** * Returns the current {@link Cluster} for the current context */ public static Cluster getCluster(Config config, Context context) { Cluster cluster = null; if (config != null && context != null) { String clusterName = context.getCluster(); if (clusterName != null) { List<NamedCluster> clusters = config.getClusters(); if (clusters != null) { for (NamedCluster namedCluster : clusters) { if (clusterName.equals(namedCluster.getName())) { cluster = namedCluster.getCluster(); } } } } } return cluster; } }
public NamedClusterBuilder(NamedCluster instance,Boolean validationEnabled){ this.fluent = this; this.withCluster(instance.getCluster()); this.withName(instance.getName()); this.validationEnabled = validationEnabled; }
public NamedClusterBuilder(NamedClusterFluent<?> fluent,NamedCluster instance,Boolean validationEnabled){ this.fluent = fluent; fluent.withCluster(instance.getCluster()); fluent.withName(instance.getName()); this.validationEnabled = validationEnabled; } public NamedClusterBuilder(NamedCluster instance){
public NamedClusterFluentImpl(NamedCluster instance){ this.withCluster(instance.getCluster()); this.withName(instance.getName()); }
/** * Returns the current {@link Cluster} for the current context */ public static Cluster getCluster(Config config, Context context) { Cluster cluster = null; if (config != null && context != null) { String clusterName = context.getCluster(); if (clusterName != null) { List<NamedCluster> clusters = config.getClusters(); if (clusters != null) { for (NamedCluster namedCluster : clusters) { if (clusterName.equals(namedCluster.getName())) { cluster = namedCluster.getCluster(); } } } } } return cluster; } }
Optional<NamedCluster> foundCluster = Iterables.tryFind(kubeconfig.getClusters(), c -> c.getName().equals(clusterName)); if (!foundCluster.isPresent()) { throw new IllegalStateException(String.format("Cluster %s not found", clusterName));