Skip to content

Commit 6e32bb7

Browse files
committed
feat(webapp): add hasComputeAccess feature flag for private beta org opt-in
1 parent 2397101 commit 6e32bb7

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

apps/webapp/app/v3/featureFlags.server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const FEATURE_FLAG = {
99
hasLogsPageAccess: "hasLogsPageAccess",
1010
hasAiAccess: "hasAiAccess",
1111
hasAiModelsAccess: "hasAiModelsAccess",
12+
hasComputeAccess: "hasComputeAccess",
1213
} as const;
1314

1415
const FeatureFlagCatalog = {
@@ -19,6 +20,7 @@ const FeatureFlagCatalog = {
1920
[FEATURE_FLAG.hasLogsPageAccess]: z.coerce.boolean(),
2021
[FEATURE_FLAG.hasAiAccess]: z.coerce.boolean(),
2122
[FEATURE_FLAG.hasAiModelsAccess]: z.coerce.boolean(),
23+
[FEATURE_FLAG.hasComputeAccess]: z.coerce.boolean(),
2224
};
2325

2426
type FeatureFlagKey = keyof typeof FeatureFlagCatalog;

apps/webapp/app/v3/services/computeTemplateCreation.server.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ComputeGatewayClient } from "@internal/compute";
22
import { env } from "~/env.server";
33
import { logger } from "~/services/logger.server";
44
import type { PrismaClientOrTransaction } from "~/db.server";
5+
import { FEATURE_FLAG, makeFlag } from "~/v3/featureFlags.server";
56

67
type TemplateCreationMode = "required" | "shadow" | "skip";
78

@@ -28,14 +29,26 @@ export class ComputeTemplateCreationService {
2829
defaultWorkerGroup: {
2930
select: { workloadType: true },
3031
},
32+
organization: {
33+
select: { featureFlags: true },
34+
},
3135
},
3236
});
3337

3438
if (project?.defaultWorkerGroup?.workloadType === "MICROVM") {
3539
return "required";
3640
}
3741

38-
// TODO: check private beta feature flag for org
42+
const flag = makeFlag(prisma);
43+
const hasComputeAccess = await flag({
44+
key: FEATURE_FLAG.hasComputeAccess,
45+
defaultValue: false,
46+
overrides: (project?.organization?.featureFlags as Record<string, unknown>) ?? {},
47+
});
48+
49+
if (hasComputeAccess) {
50+
return "required";
51+
}
3952

4053
const rolloutPct = Number(env.COMPUTE_TEMPLATE_SHADOW_ROLLOUT_PCT ?? "0");
4154
if (rolloutPct > 0 && Math.random() * 100 < rolloutPct) {

0 commit comments

Comments
 (0)