Skip to content

Commit 1d679db

Browse files
perf: delete feature flag checks for vm images as they are now GA (#244)
Co-authored-by: danieltaox <danieltaox@gmail.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 1f8d45d commit 1d679db

File tree

6 files changed

+27
-53
lines changed

6 files changed

+27
-53
lines changed

src/lib/nodes/create.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
import { handleNodesError, nodesClient } from "../../nodesClient.ts";
2222
import { getPricePerGpuHourFromQuote, getQuote } from "../buy/index.tsx";
2323
import { GPUS_PER_NODE } from "../constants.ts";
24-
import { isFeatureEnabled } from "../posthog.ts";
2524
import {
2625
createNodesTable,
2726
durationOption,
@@ -130,6 +129,12 @@ const create = new Command("create")
130129
}
131130
}),
132131
)
132+
.addOption(
133+
new Option(
134+
"-i, --image <image-id>",
135+
"ID of the VM image to boot on the nodes. View available images with `sf node images list`.",
136+
),
137+
)
133138
.addOption(yesOption)
134139
.addOption(jsonOption)
135140
.hook("preAction", (command) => {
@@ -492,18 +497,4 @@ async function createNodesAction(
492497
}
493498
}
494499

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

src/lib/nodes/image/index.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Command } from "@commander-js/extra-typings";
2-
import { isFeatureEnabled } from "../../posthog.ts";
32
import list from "./list.tsx";
43
import show from "./show.tsx";
54
import upload from "./upload.ts";
@@ -30,11 +29,4 @@ Examples:\n
3029
image.help();
3130
});
3231

33-
export async function addImage(program: Command) {
34-
const imagesEnabled = await isFeatureEnabled("custom-vm-images");
35-
if (imagesEnabled) {
36-
program.addCommand(image);
37-
}
38-
}
39-
4032
export default image;

src/lib/nodes/index.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
11
import console from "node:console";
22
import type { Command } from "@commander-js/extra-typings";
33

4-
import { addCreate } from "./create.ts";
4+
import create from "./create.ts";
55
import deleteCommand from "./delete.ts";
66
import extend from "./extend.ts";
77
import get from "./get.tsx";
8-
import { addImage } from "./image/index.ts";
8+
import image from "./image/index.ts";
99
import list from "./list.tsx";
1010
import logs from "./logs.ts";
11-
import { addRedeploy } from "./redeploy.ts";
11+
import redeploy from "./redeploy.ts";
1212
import release from "./release.ts";
1313
import set from "./set.ts";
1414
import ssh from "./ssh.ts";
1515

16-
export async function registerNodes(program: Command) {
16+
export function registerNodes(program: Command) {
1717
const nodes = program
1818
.command("nodes")
1919
.alias("node")
2020
.showHelpAfterError()
2121
.description("Manage compute nodes")
2222
.addCommand(list)
2323
.addCommand(get)
24+
.addCommand(create)
2425
.addCommand(extend)
2526
.addCommand(release)
2627
.addCommand(deleteCommand)
28+
.addCommand(redeploy)
2729
.addCommand(set)
2830
.addCommand(ssh)
29-
.addCommand(logs);
30-
31-
await addImage(nodes);
32-
await addCreate(nodes);
33-
await addRedeploy(nodes);
31+
.addCommand(logs)
32+
.addCommand(image);
3433

3534
const baseHelpText = nodes.helpInformation();
3635

src/lib/nodes/redeploy.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import chalk from "chalk";
88
import ora from "ora";
99

1010
import { handleNodesError, nodesClient } from "../../nodesClient.ts";
11-
import { isFeatureEnabled } from "../posthog.ts";
1211
import {
1312
createNodesTable,
1413
jsonOption,
@@ -50,6 +49,12 @@ const redeploy = new Command("redeploy")
5049
"If set, any configuration left empty will be cleared in the new VM (default: inherits from current VM)",
5150
),
5251
)
52+
.addOption(
53+
new Option(
54+
"-i, --image <image-id>",
55+
"ID of the VM image to use for the new VM (inherits from current VM if not specified)",
56+
),
57+
)
5358
.addOption(yesOption)
5459
.addOption(jsonOption)
5560
.addHelpText(
@@ -288,18 +293,4 @@ async function redeployNodeAction(
288293
}
289294
}
290295

291-
// Remove this once the feature flag is enabled by default
292-
export async function addRedeploy(program: Command) {
293-
const imagesEnabled = await isFeatureEnabled("custom-vm-images");
294-
if (imagesEnabled) {
295-
redeploy.addOption(
296-
new Option(
297-
"-i, --image <image-id>",
298-
"ID of the VM image to use for the new VM (inherits from current VM if not specified)",
299-
),
300-
);
301-
}
302-
program.addCommand(redeploy);
303-
}
304-
305296
export default redeploy;

src/lib/posthog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const trackEvent = ({
6262
}
6363
};
6464

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

6767
/**
6868
* Checks if a feature is enabled for the current user.

src/lib/vm/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Command } from "@commander-js/extra-typings";
33
import boxen from "boxen";
44
import chalk from "chalk";
55
import { nodesClient } from "../../nodesClient.ts";
6-
import { addImage } from "../nodes/image/index.ts";
6+
import image from "../nodes/image/index.ts";
77
import { pluralizeNodes } from "../nodes/utils.ts";
88
import list from "./list.ts";
99
import logs from "./logs.ts";
@@ -62,8 +62,9 @@ export async function registerVM(program: Command) {
6262

6363
registerSsh(vm);
6464

65-
vm.addCommand(list).addCommand(logs).addCommand(replace).addCommand(script);
66-
67-
// Add images command if feature flag is enabled
68-
await addImage(vm);
65+
vm.addCommand(list)
66+
.addCommand(logs)
67+
.addCommand(replace)
68+
.addCommand(script)
69+
.addCommand(image);
6970
}

0 commit comments

Comments
 (0)