Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,20 @@ public static K8sContext create(Connection connection) {
info = "Using token authentication.";
apiClient = Config.fromToken(server, token);
apiClient.setApiKeyPrefix("Bearer");
} else if (kubeconfig == null) {
info = "Using default configuration from ./kube/config.";
try {
apiClient = Config.defaultClient();
} catch (IOException e) {
throw new RuntimeException(e);
}
} else {
if (kubeconfig == null) {
kubeconfig = System.getProperty("user.home") + "/.kube/config";
}
info = "Using kubeconfig from " + kubeconfig + ".";
try (Reader r = Files.newBufferedReader(Paths.get(kubeconfig))) {
KubeConfig kubeConfig = KubeConfig.loadKubeConfig(r);
kubeConfig.setFile(new File(kubeconfig));
if (namespace == null) {
namespace = kubeConfig.getNamespace();
}
if (namespace == null) {
namespace = DEFAULT_NAMESPACE;
}
apiClient = ClientBuilder.kubeconfig(kubeConfig).build();
} catch (IOException e) {
throw new RuntimeException(e);
Expand All @@ -119,6 +121,8 @@ public static K8sContext create(Connection connection) {
apiClient.setBasePath(server);
}

info += " Using namespace " + namespace + ".";

if (truststore != null) {
try {
InputStream in = Files.newInputStream(Paths.get(truststore));
Expand Down Expand Up @@ -259,6 +263,6 @@ private static String getPodNamespace() {
if (namespace != null) {
return namespace;
}
return DEFAULT_NAMESPACE;
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,19 @@ public K8sPipelineTable(K8sContext context) {

@Override
public Row toRow(V1alpha1Pipeline obj) {
V1alpha1PipelineStatus status = Objects.requireNonNull(obj.getStatus());
return new Row(Objects.requireNonNull(obj.getMetadata()).getName(), Boolean.TRUE.equals(status.getReady()),
Boolean.TRUE.equals(status.getFailed()), status.getMessage());
final boolean ready;
final boolean failed;
final String msg;
if (obj.getStatus() != null) {
ready = Boolean.TRUE.equals(obj.getStatus().getReady());
failed = Boolean.TRUE.equals(obj.getStatus().getFailed());
msg = obj.getStatus().getMessage();
} else {
ready = false;
failed = false;
msg = null;
}
return new Row(Objects.requireNonNull(obj.getMetadata()).getName(), ready, failed, msg);
}

@Override
Expand Down
Loading