Skip to content
Merged
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
21 changes: 6 additions & 15 deletions src/lib/nodes/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
import { handleNodesError, nodesClient } from "../../nodesClient.ts";
import { getPricePerGpuHourFromQuote, getQuote } from "../buy/index.tsx";
import { GPUS_PER_NODE } from "../constants.ts";
import { isFeatureEnabled } from "../posthog.ts";
import {
createNodesTable,
durationOption,
Expand Down Expand Up @@ -130,6 +129,12 @@ const create = new Command("create")
}
}),
)
.addOption(
new Option(
"-i, --image <image-id>",
"ID of the VM image to boot on the nodes. View available images with `sf node images list`.",
),
)
.addOption(yesOption)
.addOption(jsonOption)
.hook("preAction", (command) => {
Expand Down Expand Up @@ -492,18 +497,4 @@ async function createNodesAction(
}
}

// Remove this once the feature flag is enabled by default
export async function addCreate(program: Command) {
const imagesEnabled = await isFeatureEnabled("custom-vm-images");
if (imagesEnabled) {
create.addOption(
new Option(
"-i, --image <image-id>",
"ID of the VM image to boot on the nodes. View available images with `sf node images list`.",
),
);
}
program.addCommand(create);
}

export default create;
8 changes: 0 additions & 8 deletions src/lib/nodes/image/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Command } from "@commander-js/extra-typings";
import { isFeatureEnabled } from "../../posthog.ts";
import list from "./list.tsx";
import show from "./show.tsx";
import upload from "./upload.ts";
Expand Down Expand Up @@ -30,11 +29,4 @@ Examples:\n
image.help();
});

export async function addImage(program: Command) {
const imagesEnabled = await isFeatureEnabled("custom-vm-images");
if (imagesEnabled) {
program.addCommand(image);
}
}

export default image;
17 changes: 8 additions & 9 deletions src/lib/nodes/index.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
import console from "node:console";
import type { Command } from "@commander-js/extra-typings";

import { addCreate } from "./create.ts";
import create from "./create.ts";
import deleteCommand from "./delete.ts";
import extend from "./extend.ts";
import get from "./get.tsx";
import { addImage } from "./image/index.ts";
import image from "./image/index.ts";
import list from "./list.tsx";
import logs from "./logs.ts";
import { addRedeploy } from "./redeploy.ts";
import redeploy from "./redeploy.ts";
import release from "./release.ts";
import set from "./set.ts";
import ssh from "./ssh.ts";

export async function registerNodes(program: Command) {
export function registerNodes(program: Command) {
const nodes = program
.command("nodes")
.alias("node")
.showHelpAfterError()
.description("Manage compute nodes")
.addCommand(list)
.addCommand(get)
.addCommand(create)
.addCommand(extend)
.addCommand(release)
.addCommand(deleteCommand)
.addCommand(redeploy)
.addCommand(set)
.addCommand(ssh)
.addCommand(logs);

await addImage(nodes);
await addCreate(nodes);
await addRedeploy(nodes);
.addCommand(logs)
.addCommand(image);

const baseHelpText = nodes.helpInformation();

Expand Down
21 changes: 6 additions & 15 deletions src/lib/nodes/redeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import chalk from "chalk";
import ora from "ora";

import { handleNodesError, nodesClient } from "../../nodesClient.ts";
import { isFeatureEnabled } from "../posthog.ts";
import {
createNodesTable,
jsonOption,
Expand Down Expand Up @@ -50,6 +49,12 @@ const redeploy = new Command("redeploy")
"If set, any configuration left empty will be cleared in the new VM (default: inherits from current VM)",
),
)
.addOption(
new Option(
"-i, --image <image-id>",
"ID of the VM image to use for the new VM (inherits from current VM if not specified)",
),
)
.addOption(yesOption)
.addOption(jsonOption)
.addHelpText(
Expand Down Expand Up @@ -288,18 +293,4 @@ async function redeployNodeAction(
}
}

// Remove this once the feature flag is enabled by default
export async function addRedeploy(program: Command) {
const imagesEnabled = await isFeatureEnabled("custom-vm-images");
if (imagesEnabled) {
redeploy.addOption(
new Option(
"-i, --image <image-id>",
"ID of the VM image to use for the new VM (inherits from current VM if not specified)",
),
);
}
program.addCommand(redeploy);
}

export default redeploy;
2 changes: 1 addition & 1 deletion src/lib/posthog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const trackEvent = ({
}
};

type FeatureFlags = "procurements" | "zones" | "custom-vm-images";
type FeatureFlags = "procurements" | "zones";

/**
* Checks if a feature is enabled for the current user.
Expand Down
11 changes: 6 additions & 5 deletions src/lib/vm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Command } from "@commander-js/extra-typings";
import boxen from "boxen";
import chalk from "chalk";
import { nodesClient } from "../../nodesClient.ts";
import { addImage } from "../nodes/image/index.ts";
import image from "../nodes/image/index.ts";
import { pluralizeNodes } from "../nodes/utils.ts";
import list from "./list.ts";
import logs from "./logs.ts";
Expand Down Expand Up @@ -62,8 +62,9 @@ export async function registerVM(program: Command) {

registerSsh(vm);

vm.addCommand(list).addCommand(logs).addCommand(replace).addCommand(script);

// Add images command if feature flag is enabled
await addImage(vm);
vm.addCommand(list)
.addCommand(logs)
.addCommand(replace)
.addCommand(script)
.addCommand(image);
}