Skip to content

Commit

Permalink
Add --partition-id flag to deploy (#31431)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 2863fd190b37b34c2aad91be4a313065ae7bbf78
  • Loading branch information
emmaling27 authored and Convex, Inc. committed Nov 8, 2024
1 parent 4450b36 commit 1fb3905
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions npm-packages/convex/src/cli/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export async function deploymentCredentialsOrConfigure(
teamSlug,
projectSlug,
deploymentOptions,
partitionId,
});
await updateEnvAndConfigForDeploymentSelection(ctx, {
url,
Expand Down Expand Up @@ -423,6 +424,7 @@ async function ensureDeploymentProvisioned(
teamSlug: string;
projectSlug: string;
deploymentOptions: DeploymentOptions;
partitionId: number | undefined;
},
): Promise<DeploymentDetails> {
switch (options.deploymentOptions.kind) {
Expand All @@ -433,6 +435,7 @@ async function ensureDeploymentProvisioned(
ctx,
{ teamSlug: options.teamSlug, projectSlug: options.projectSlug },
options.deploymentOptions.kind,
options.partitionId,
);
return {
...credentials,
Expand Down
2 changes: 2 additions & 0 deletions npm-packages/convex/src/cli/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export const deploy = new Command("deploy")
.conflicts("preview-create"),
)
.addOption(new Option("--live-component-sources").hideHelp())
.addOption(new Option("--partition-id <id>").hideHelp())
.showHelpAfterError()
.action(async (cmdOptions) => {
const ctx = oneoffContext();
Expand Down Expand Up @@ -284,6 +285,7 @@ async function deployToExistingDeployment(
url?: string | undefined;
writePushRequest?: string | undefined;
liveComponentSources?: boolean | undefined;
partitionId?: string | undefined;
},
) {
const deploymentSelection = deploymentSelectionFromOptions({
Expand Down
14 changes: 12 additions & 2 deletions npm-packages/convex/src/cli/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export type DeploymentSelection =
| { kind: "deployKey" }
| { kind: "previewName"; previewName: string }
| { kind: "deploymentName"; deploymentName: string }
| { kind: "ownProd" }
| { kind: "ownProd"; partitionId?: number | undefined }
| { kind: "ownDev" }
| { kind: "urlWithAdminKey"; url: string; adminKey: string }
| { kind: "urlWithLogin"; url: string };
Expand All @@ -154,6 +154,7 @@ export type DeploymentSelectionOptions = {
deploymentName?: string | undefined;
url?: string | undefined;
adminKey?: string | undefined;
partitionId?: string | undefined;
};

export function deploymentSelectionFromOptions(
Expand All @@ -176,7 +177,13 @@ export function deploymentSelectionFromOptions(
if (adminKey !== undefined) {
return { kind: "deployKey" };
}
return { kind: options.prod === true ? "ownProd" : "ownDev" };
const partitionId = options.partitionId
? parseInt(options.partitionId)
: undefined;
return {
kind: options.prod === true ? "ownProd" : "ownDev",
partitionId,
};
}

// Deploy
Expand Down Expand Up @@ -342,6 +349,7 @@ async function fetchDeploymentCredentialsWithinCurrentProjectInner(
url: "deployment/authorize_prod",
data: {
deploymentName: configuredDeployment,
partitionId: deploymentSelection.partitionId,
},
});
case "previewName":
Expand Down Expand Up @@ -514,6 +522,7 @@ export async function fetchDeploymentCredentialsProvisioningDevOrProdMaybeThrows
ctx: Context,
{ teamSlug, projectSlug }: { teamSlug: string; projectSlug: string },
deploymentType: DeploymentType,
partitionId: number | undefined,
): Promise<{
deploymentName: string;
deploymentUrl: string;
Expand All @@ -527,6 +536,7 @@ export async function fetchDeploymentCredentialsProvisioningDevOrProdMaybeThrows
teamSlug,
projectSlug,
deploymentType,
partitionId,
},
});
const deploymentName = data.deploymentName;
Expand Down

0 comments on commit 1fb3905

Please sign in to comment.