Skip to content

Commit 08b37f8

Browse files
authored
Revert "use userConfigPath instead of redirected one (#10005)" (#10037)
This reverts commit 64d71b1.
1 parent 64d71b1 commit 08b37f8

File tree

7 files changed

+5
-122
lines changed

7 files changed

+5
-122
lines changed

.changeset/breezy-regions-press.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/containers-shared/src/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ export function isDir(path: string) {
104104
/** returns true if it is a dockerfile, false if it is a registry link, throws if neither */
105105
export const isDockerfile = (
106106
image: string,
107-
/** The original (non-redirected) user config path */
108107
configPath: string | undefined
109108
): boolean => {
110109
const baseDir = configPath ? path.dirname(configPath) : process.cwd();

packages/wrangler/src/__tests__/cloudchamber/deploy.test.ts

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -346,113 +346,6 @@ describe("wrangler deploy with containers", () => {
346346
expect(std.warn).toMatchInlineSnapshot(`""`);
347347
});
348348

349-
it("resolve the dockerfile based on the non-redirected userConfigPath rather than the actual config path", async () => {
350-
vi.stubEnv("WRANGLER_DOCKER_BIN", "/usr/bin/docker");
351-
mockGetVersion("Galaxy-Class");
352-
353-
vi.mocked(spawn)
354-
.mockImplementationOnce(mockDockerInfo())
355-
.mockImplementationOnce(
356-
mockDockerBuild(
357-
"my-container",
358-
"Galaxy",
359-
"FROM scratch",
360-
// note that the cwd for the test is not the same as the cwd that the wrangler command is running in
361-
// fortunately we are using an absolute path
362-
process.cwd()
363-
)
364-
)
365-
.mockImplementationOnce(mockDockerImageInspect("my-container", "Galaxy"))
366-
.mockImplementationOnce(mockDockerLogin("mockpassword"))
367-
.mockImplementationOnce(
368-
mockDockerManifestInspect("some-account-id/my-container", true)
369-
)
370-
.mockImplementationOnce(
371-
mockDockerTag("my-container", "some-account-id/my-container", "Galaxy")
372-
)
373-
.mockImplementationOnce(
374-
mockDockerPush("some-account-id/my-container", "Galaxy")
375-
)
376-
.mockImplementationOnce(
377-
mockDockerImageDelete("some-account-id/my-container", "Galaxy")
378-
);
379-
380-
mockContainersAccount();
381-
382-
const wranglerConfig = {
383-
main: "index.js",
384-
durable_objects: {
385-
bindings: [
386-
{
387-
name: "EXAMPLE_DO_BINDING",
388-
class_name: "ExampleDurableObject",
389-
},
390-
],
391-
},
392-
containers: [
393-
{
394-
name: "my-container",
395-
max_instances: 10,
396-
class_name: "ExampleDurableObject",
397-
image: "./Dockerfile",
398-
},
399-
],
400-
migrations: [{ tag: "v1", new_sqlite_classes: ["ExampleDurableObject"] }],
401-
};
402-
// user wrangler config
403-
writeWranglerConfig(wranglerConfig, "./wrangler.json");
404-
// set up redirected config
405-
fs.mkdirSync(".wrangler/deploy", { recursive: true });
406-
fs.writeFileSync(
407-
".wrangler/deploy/config.json",
408-
JSON.stringify({ configPath: "./wrangler.json" })
409-
);
410-
writeWranglerConfig(
411-
{ ...wranglerConfig, main: "../../index.js" },
412-
".wrangler/deploy/wrangler.json"
413-
);
414-
// dockerfile is in the root of the project
415-
fs.writeFileSync("Dockerfile", "FROM scratch");
416-
mockGetApplications([]);
417-
418-
mockGenerateImageRegistryCredentials();
419-
420-
mockCreateApplication({
421-
name: "my-container",
422-
max_instances: 10,
423-
durable_objects: { namespace_id: "1" },
424-
configuration: {
425-
image:
426-
getCloudflareContainerRegistry() +
427-
"/some-account-id/my-container:Galaxy",
428-
},
429-
});
430-
431-
await runWrangler("deploy");
432-
expect(std.info).toMatchInlineSnapshot(`
433-
"Using redirected Wrangler configuration.
434-
- Configuration being used: \\".wrangler/deploy/wrangler.json\\"
435-
- Original user's configuration: \\"wrangler.json\\"
436-
- Deploy configuration file: \\".wrangler/deploy/config.json\\""
437-
`);
438-
expect(std.out).toMatchInlineSnapshot(`
439-
"Total Upload: xx KiB / gzip: xx KiB
440-
Worker Startup Time: 100 ms
441-
Your Worker has access to the following bindings:
442-
Binding Resource
443-
env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
444-
445-
Uploaded test-name (TIMINGS)
446-
Building image my-container:Galaxy
447-
Image does not exist remotely, pushing: registry.cloudflare.com/some-account-id/my-container:Galaxy
448-
Deployed test-name triggers (TIMINGS)
449-
https://test-name.test-sub-domain.workers.dev
450-
Current Version ID: Galaxy-Class"
451-
`);
452-
453-
expect(std.err).toMatchInlineSnapshot(`""`);
454-
expect(std.warn).toMatchInlineSnapshot(`""`);
455-
});
456349
it("should support deploying a worker with multiple containers", async () => {
457350
mockGetVersion(
458351
"Galaxy-Class",

packages/wrangler/src/api/startDevWorker/ConfigController.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,7 @@ async function resolveConfig(
400400
// container API client is properly set so that we can get the correct permissions
401401
// from the cloudchamber API to pull from the repository.
402402
const needsPulling = resolved.containers?.some(
403-
(c) =>
404-
!isDockerfile(c.image ?? c.configuration?.image, config.userConfigPath)
403+
(c) => !isDockerfile(c.image ?? c.configuration?.image, config.configPath)
405404
);
406405
if (needsPulling && !resolved.dev.remote) {
407406
await fillOpenAPIConfiguration(config, containersScope);

packages/wrangler/src/cloudchamber/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ export async function buildCommand(
246246
},
247247
getDockerPath() ?? args.pathToDocker,
248248
args.push,
249-
config.userConfigPath,
249+
config.configPath,
250250
container
251251
);
252252
}

packages/wrangler/src/cloudchamber/deploy.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export async function maybeBuildContainer(
1717
imageTag: string,
1818
dryRun: boolean,
1919
pathToDocker: string,
20-
/** The original (non-redirected) user config path */
2120
configPath?: string
2221
): Promise<{ image: string; imageUpdated: boolean }> {
2322
try {
@@ -121,7 +120,7 @@ export async function deployContainers(
121120
versionId,
122121
dryRun,
123122
pathToDocker,
124-
config.userConfigPath
123+
config.configPath
125124
);
126125
container.configuration ??= {};
127126
container.configuration.image = buildResult.image;

packages/wrangler/src/deploy/deploy.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -786,8 +786,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
786786
const hasDockerfiles = config.containers.some((container) =>
787787
isDockerfile(
788788
container.image ?? container.configuration?.image,
789-
// this is the original (non-redirected) config path
790-
config.userConfigPath
789+
config.configPath
791790
)
792791
);
793792
if (hasDockerfiles) {
@@ -803,7 +802,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
803802
workerTag ?? "worker-tag",
804803
props.dryRun,
805804
dockerPath,
806-
config.userConfigPath
805+
config.configPath
807806
);
808807
}
809808
}

0 commit comments

Comments
 (0)