-
Notifications
You must be signed in to change notification settings - Fork 731
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add default image for cloudchamber create
Add a default image when using "wrangler cloudchamber create". This image is docker.io/cloudflare/hello-world which is a simple HTTP server that runs on Cloudflare's container platform. This commit also augments validation to both the `cloudchamber create` and `cloudchamber modify` commands to ensure the provided image contains a tag and adheres to the format in the OCI specification.
- Loading branch information
Showing
6 changed files
with
139 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"wrangler": minor | ||
--- | ||
|
||
Add a default image for cloudchamber create and modify commands |
56 changes: 56 additions & 0 deletions
56
packages/wrangler/src/__tests__/cloudchamber/common.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { parseImageName } from "../../cloudchamber/common"; | ||
|
||
describe("parseImageName", () => { | ||
it("works", () => { | ||
type TestCase = [ | ||
input: string, | ||
expected: { name?: string; tag?: string; err?: boolean }, | ||
]; | ||
const cases: TestCase[] = [ | ||
// Multiple domains | ||
[ | ||
"docker.io/cloudflare/hello-world:1.0", | ||
{ name: "docker.io/cloudflare/hello-world", tag: "1.0" }, | ||
], | ||
|
||
// Domain with port | ||
[ | ||
"localhost:7777/web:local", | ||
{ name: "localhost:7777/web", tag: "local" }, | ||
], | ||
|
||
// No domain | ||
["hello-world:1.0", { name: "hello-world", tag: "1.0" }], | ||
|
||
// With sha256 digest | ||
["hello/world:1.0@sha256:abcdef0123456789", { name: "hello/world", tag: "1.0" }], | ||
|
||
// Invalid name | ||
["bad image name:1", { err: true }], | ||
|
||
// Missing tag | ||
["no-tag", { err: true }], | ||
["no-tag:", { err: true }], | ||
|
||
// sha256 digest but no tag | ||
["no-tag@sha256:abcdef0123456789", { err: true }], | ||
|
||
// Invalid tag | ||
["no-tag::", { err: true }], | ||
|
||
// latest tag | ||
["name:latest", { err: true }], | ||
|
||
// Too many colons | ||
["registry.com:1234/foobar:4444/image:sometag", { err: true }], | ||
]; | ||
|
||
for (const c of cases) { | ||
const [input, expected] = c; | ||
const result = parseImageName(input); | ||
expect(result.name).toEqual(expected.name); | ||
expect(result.tag).toEqual(expected.tag); | ||
expect(result.err !== undefined).toEqual(expected.err === true); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters