Skip to content

Commit

Permalink
Allows uploads with both cron triggers and smart placement enabled (#…
Browse files Browse the repository at this point in the history
…4219)

Revert "Prevents uploads with both cron triggers and smart placement enabled (#3390)"

This reverts commit b5b46b4.

Co-authored-by: Max Peterson <mpeterson@cloudflare.com>
  • Loading branch information
maxwellpeterson and Max Peterson authored Oct 27, 2023
1 parent a027b57 commit 0453b44
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 79 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-carpets-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

Allows uploads with both cron triggers and smart placement enabled
56 changes: 1 addition & 55 deletions packages/wrangler/src/__tests__/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ describe("normalizeAndValidateConfig()", () => {
first_party_worker: true,
logpush: true,
placement: {
mode: "off",
mode: "smart",
},
};

Expand Down Expand Up @@ -4791,60 +4791,6 @@ describe("normalizeAndValidateConfig()", () => {
});
});

describe("[placement]", () => {
it("should error if both placement and triggers are configured", () => {
const { diagnostics } = normalizeAndValidateConfig(
{
triggers: {
crons: [1111],
},
placement: { mode: "smart" },
} as unknown as RawConfig,
undefined,
{ env: undefined }
);

expect(diagnostics.hasWarnings()).toBe(false);
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
"Processing wrangler configuration:
- You cannot configure both [triggers] and [placement] in your wrangler.toml. Placement is not supported with cron triggers."
`);
});
it("should not error if triggers are configured and placement is set off", () => {
const { diagnostics } = normalizeAndValidateConfig(
{
triggers: {
crons: [1111],
},
placement: { mode: "off" },
} as unknown as RawConfig,
undefined,
{ env: undefined }
);

expect(diagnostics.hasWarnings()).toBe(false);
expect(diagnostics.hasErrors()).toBe(false);
});
it("should not error if placement is configured and triggers is empty array", () => {
const expectedConfig: RawEnvironment = {
triggers: { crons: [] },
placement: {
mode: "smart",
},
};
const { config, diagnostics } = normalizeAndValidateConfig(
expectedConfig,
undefined,
{ env: undefined }
);

expect(config).toEqual(expect.objectContaining({ ...expectedConfig }));

expect(diagnostics.hasWarnings()).toBe(false);
expect(diagnostics.hasErrors()).toBe(false);
});
});

describe("(deprecated)", () => {
it("should remove and warn about deprecated properties", () => {
const environment: RawEnvironment = {
Expand Down
21 changes: 0 additions & 21 deletions packages/wrangler/src/config/validation-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,27 +533,6 @@ export const validateAdditionalProperties = (
return true;
};

/**
* Add a diagnostic error for any configurations that include both cron triggers and smart placement
*/
export const validateSmartPlacementConfig = (
diagnostics: Diagnostics,
placement: { mode: "off" | "smart" } | undefined,
triggers:
| {
crons: string[];
}
| undefined
): boolean => {
if (placement?.mode === "smart" && !!triggers?.crons?.length) {
diagnostics.errors.push(
`You cannot configure both [triggers] and [placement] in your wrangler.toml. Placement is not supported with cron triggers.`
);
return false;
}
return true;
};

/**
* Get the names of the bindings collection in `value`.
*
Expand Down
3 changes: 0 additions & 3 deletions packages/wrangler/src/config/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
appendEnvName,
getBindingNames,
isValidName,
validateSmartPlacementConfig,
} from "./validation-helpers";
import type { Config, DevConfig, RawConfig, RawDevConfig } from "./config";
import type {
Expand Down Expand Up @@ -238,8 +237,6 @@ export function normalizeAndValidateConfig(
[...Object.keys(config), "env"]
);

validateSmartPlacementConfig(diagnostics, config.placement, config.triggers);

experimental(diagnostics, rawConfig, "assets");

return { config, diagnostics };
Expand Down

0 comments on commit 0453b44

Please sign in to comment.