Skip to content

Commit 2ee8c4a

Browse files
hasip-timurtaspetebacondarwin
authored andcommitted
refactor: Always fill OpenAPI configuration in deployContainers, even in dry-run mode
Updated the deployContainers function to ensure that the OpenAPI configuration is filled regardless of the dryRun flag. This change is necessary for proper API access during container building. Additionally, modified the apply function to only execute when not in dry-run mode.
1 parent 07416ba commit 2ee8c4a

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

packages/wrangler/src/cloudchamber/deploy.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,14 @@ export async function deployContainers(
6565
return;
6666
}
6767

68-
if (!dryRun) {
69-
await fillOpenAPIConfiguration(
70-
config,
71-
isNonInteractiveOrCI(),
72-
containersScope
73-
);
74-
}
68+
// Always fill OpenAPI configuration when containers are defined, even in dry-run mode
69+
// because maybeBuildContainer needs to call loadAccount() which requires API access
70+
await fillOpenAPIConfiguration(
71+
config,
72+
isNonInteractiveOrCI(),
73+
containersScope
74+
);
75+
7576
const pathToDocker = getDockerPath();
7677
for (const container of config.containers) {
7778
const version = await fetchVersion(
@@ -123,15 +124,18 @@ export async function deployContainers(
123124
container.configuration.image = buildResult.image;
124125
container.image = buildResult.image;
125126

126-
await apply(
127-
{
128-
skipDefaults: false,
129-
json: true,
130-
env,
131-
imageUpdateRequired: buildResult.pushed,
132-
},
133-
configuration
134-
);
127+
// Only apply the configuration if not in dry-run mode
128+
if (!dryRun) {
129+
await apply(
130+
{
131+
skipDefaults: false,
132+
json: true,
133+
env,
134+
imageUpdateRequired: buildResult.pushed,
135+
},
136+
configuration
137+
);
138+
}
135139
}
136140
}
137141

packages/wrangler/src/deploy/deploy.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import PQueue from "p-queue";
1111
import { Response } from "undici";
1212
import { syncAssets } from "../assets";
1313
import { fetchListResult, fetchResult } from "../cfetch";
14+
import { fillOpenAPIConfiguration } from "../cloudchamber/common";
1415
import { deployContainers, maybeBuildContainer } from "../cloudchamber/deploy";
1516
import { configFileName, formatConfigSnippet } from "../config";
17+
import { containersScope } from "../containers";
1618
import { getBindings, provisionBindings } from "../deployment-bundle/bindings";
1719
import { bundleWorker } from "../deployment-bundle/bundle";
1820
import { printBundleSize } from "../deployment-bundle/bundle-reporter";
@@ -30,6 +32,7 @@ import { getMigrationsToUpload } from "../durable";
3032
import { getDockerPath } from "../environment-variables/misc-variables";
3133
import { UserError } from "../errors";
3234
import { getFlag } from "../experimental-flags";
35+
import { isNonInteractiveOrCI } from "../is-interactive";
3336
import { logger } from "../logger";
3437
import { getMetricsUsageHeaders } from "../metrics";
3538
import { isNavigatorDefined } from "../navigator-user-agent";
@@ -786,6 +789,14 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
786789

787790
if (props.dryRun) {
788791
if (config.containers) {
792+
// Set up OpenAPI configuration for container building in dry-run mode
793+
// This is needed because maybeBuildContainer calls loadAccount() which requires API access
794+
await fillOpenAPIConfiguration(
795+
config,
796+
isNonInteractiveOrCI(),
797+
containersScope
798+
);
799+
789800
for (const container of config.containers) {
790801
await maybeBuildContainer(
791802
container,

0 commit comments

Comments
 (0)