@hashgraph/solo
Version:
An opinionated CLI tool to deploy and manage private Hedera Networks.
75 lines • 2.73 kB
JavaScript
// SPDX-License-Identifier: Apache-2.0
import { existsSync } from 'node:fs';
/**
* Authentication parameters for a Kubernetes cluster.
*/
export class KubeAuthentication {
apiServer;
caFile;
context;
skipTlsVerification;
tlsServerName;
token;
configFile;
/**
* The name of the Helm argument for the Kubernetes API server address and port number.
*/
static API_SERVER_ARG_NAME = 'kube-apiserver';
/**
* The name of the Helm argument for the Kubernetes CA certificate file.
*/
static CA_FILE_ARG_NAME = 'kube-ca-file';
/**
* The name of the Helm argument for the Kubernetes context.
*/
static CONTEXT_ARG_NAME = 'kube-context';
/**
* The name of the Helm argument for whether to skip TLS verification.
*/
static SKIP_TLS_VERIFICATION_ARG_NAME = 'kube-insecure-skip-tls-verify';
/**
* The name of the Helm argument for the TLS server name.
*/
static TLS_SERVER_NAME_ARG_NAME = 'kube-tls-server-name';
/**
* The name of the Helm argument for the bearer token.
*/
static TOKEN_ARG_NAME = 'kube-token';
/**
* The name of the Helm argument for the Kubernetes config file.
*/
static CONFIG_FILE_ARG_NAME = 'kubeconfig';
constructor(apiServer, caFile, context, skipTlsVerification, tlsServerName, token, configFile) {
this.apiServer = apiServer;
this.caFile = caFile;
this.context = context;
this.skipTlsVerification = skipTlsVerification;
this.tlsServerName = tlsServerName;
this.token = token;
this.configFile = configFile;
}
apply(builder) {
if (this.apiServer?.trim()) {
builder.argument(KubeAuthentication.API_SERVER_ARG_NAME, this.apiServer);
}
if (this.caFile && existsSync(this.caFile)) {
builder.argument(KubeAuthentication.CA_FILE_ARG_NAME, this.caFile);
}
if (this.context?.trim()) {
builder.argument(KubeAuthentication.CONTEXT_ARG_NAME, this.context);
}
if (this.skipTlsVerification !== undefined) {
builder.argument(KubeAuthentication.SKIP_TLS_VERIFICATION_ARG_NAME, this.skipTlsVerification.toString());
}
if (this.tlsServerName?.trim()) {
builder.argument(KubeAuthentication.TLS_SERVER_NAME_ARG_NAME, this.tlsServerName);
}
if (this.token?.trim()) {
builder.argument(KubeAuthentication.TOKEN_ARG_NAME, this.token);
}
if (this.configFile && existsSync(this.configFile)) {
builder.argument(KubeAuthentication.CONFIG_FILE_ARG_NAME, this.configFile);
}
}
}
//# sourceMappingURL=kube-authentication.js.map