mvp-ai's picture
download
raw
2.89 kB
// Copyright (c) 2026 the Zuke contributors
// SPDX-License-Identifier: MIT
/**
* The `aws eks` service — pointing `kubectl` at a cluster.
*
* ```ts
* import { AwsTasks } from "@zuke/aws";
* await AwsTasks.eksUpdateKubeconfig((s) =>
* s.name("prod").region("eu-west-1").kubeconfig(".kube/config")
* );
* ```
*
* @module
*/
import { option } from "./validate.ts";
import { AwsSettings } from "./settings.ts";
/** Settings for `aws eks update-kubeconfig`. */
export class AwsEksUpdateKubeconfigSettings extends AwsSettings {
#name?: string;
#kubeconfig?: string;
#alias?: string;
#userAlias?: string;
#roleArn?: string;
#dryRun = false;
/** The cluster (`--name`). */
name(cluster: string): this {
this.#name = cluster;
return this;
}
/** The kubeconfig file to write (`--kubeconfig`); `~/.kube/config` by default. */
kubeconfig(path: string): this {
this.#kubeconfig = path;
return this;
}
/** The context's name (`--alias`); the cluster ARN by default. */
alias(name: string): this {
this.#alias = name;
return this;
}
/** The user entry's name (`--user-alias`). */
userAlias(name: string): this {
this.#userAlias = name;
return this;
}
/** A role to assume when authenticating to the cluster (`--role-arn`). */
roleArn(arn: string): this {
this.#roleArn = arn;
return this;
}
/** Print the configuration instead of writing it (`--dry-run`). */
dryRun(): this {
this.#dryRun = true;
return this;
}
/** Emit `eks update-kubeconfig` with its options. */
protected override leadingTokens(): string[] {
if (this.#name === undefined) {
throw new Error(
"AwsTasks.eksUpdateKubeconfig: no cluster named — add .name('prod').",
);
}
const argv = ["eks", "update-kubeconfig", option("--name", this.#name)];
if (this.#kubeconfig !== undefined) {
argv.push(option("--kubeconfig", this.#kubeconfig));
}
if (this.#alias !== undefined) argv.push(option("--alias", this.#alias));
if (this.#userAlias !== undefined) {
argv.push(option("--user-alias", this.#userAlias));
}
if (this.#roleArn !== undefined) {
argv.push(option("--role-arn", this.#roleArn));
}
if (this.#dryRun) argv.push("--dry-run");
return argv;
}
}
/** Settings for `aws eks describe-cluster`. */
export class AwsEksDescribeClusterSettings extends AwsSettings {
#name?: string;
/** The cluster (`--name`). */
name(cluster: string): this {
this.#name = cluster;
return this;
}
/** Emit `eks describe-cluster` with the cluster. */
protected override leadingTokens(): string[] {
if (this.#name === undefined) {
throw new Error(
"AwsTasks.eksDescribeCluster: no cluster named — add .name('prod').",
);
}
return ["eks", "describe-cluster", option("--name", this.#name)];
}
}

Xet Storage Details

Size:
2.89 kB
·
Xet hash:
3d72b6c4df1fb5edcda82ddfef71109e6ea0a0f71c73069fc5ae61eb7cfa87d7

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.