-
Notifications
You must be signed in to change notification settings - Fork 1.1k
refactor(wrangler): move telemetry events from yargs middleware to command handlers #12055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
64b7a24
c2cdad2
7e9344a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,30 +13,6 @@ import { runWrangler } from "../helpers/run-wrangler"; | |
| import { mockAccount, setWranglerConfig } from "./utils"; | ||
| import type { SSHPublicKeyItem } from "@cloudflare/containers-shared"; | ||
|
|
||
| const MOCK_DEPLOYMENTS_COMPLEX_RESPONSE = ` | ||
| "{ | ||
| \\"id\\": \\"1\\", | ||
| \\"type\\": \\"default\\", | ||
| \\"created_at\\": \\"123\\", | ||
| \\"account_id\\": \\"123\\", | ||
| \\"vcpu\\": 4, | ||
| \\"memory\\": \\"400MB\\", | ||
| \\"memory_mib\\": 400, | ||
| \\"version\\": 1, | ||
| \\"image\\": \\"hello\\", | ||
| \\"location\\": { | ||
| \\"name\\": \\"sfo06\\", | ||
| \\"enabled\\": true | ||
| }, | ||
| \\"network\\": { | ||
| \\"mode\\": \\"public\\", | ||
| \\"ipv4\\": \\"1.1.1.1\\" | ||
| }, | ||
| \\"placements_ref\\": \\"http://ref\\", | ||
| \\"node_group\\": \\"metal\\" | ||
| }" | ||
| `; | ||
|
|
||
| function mockDeploymentPost() { | ||
| msw.use( | ||
| http.post( | ||
|
|
@@ -103,7 +79,7 @@ describe("cloudchamber create", () => { | |
| expect(std.out).toMatchInlineSnapshot(` | ||
| "wrangler cloudchamber create | ||
|
|
||
| Create a new deployment | ||
| Create a new deployment [alpha] | ||
|
|
||
| GLOBAL FLAGS | ||
| -c, --config Path to Wrangler configuration file [string] | ||
|
|
@@ -230,7 +206,32 @@ describe("cloudchamber create", () => { | |
| ); | ||
| // so testing the actual UI will be harder than expected | ||
| // TODO: think better on how to test UI actions | ||
| expect(std.out).toMatchInlineSnapshot(MOCK_DEPLOYMENTS_COMPLEX_RESPONSE); | ||
| expect(std.out).toMatchInlineSnapshot(` | ||
| " | ||
| ⛅️ wrangler x.x.x | ||
| ────────────────── | ||
| { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before the changes, the output was valid JSON, was that a req?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. I'll find out. |
||
| \\"id\\": \\"1\\", | ||
| \\"type\\": \\"default\\", | ||
| \\"created_at\\": \\"123\\", | ||
| \\"account_id\\": \\"123\\", | ||
| \\"vcpu\\": 4, | ||
| \\"memory\\": \\"400MB\\", | ||
| \\"memory_mib\\": 400, | ||
| \\"version\\": 1, | ||
| \\"image\\": \\"hello\\", | ||
| \\"location\\": { | ||
| \\"name\\": \\"sfo06\\", | ||
| \\"enabled\\": true | ||
| }, | ||
| \\"network\\": { | ||
| \\"mode\\": \\"public\\", | ||
| \\"ipv4\\": \\"1.1.1.1\\" | ||
| }, | ||
| \\"placements_ref\\": \\"http://ref\\", | ||
| \\"node_group\\": \\"metal\\" | ||
| }" | ||
| `); | ||
| }); | ||
|
|
||
| it("should create deployment with instance type (detects no interactivity)", async () => { | ||
|
|
@@ -253,7 +254,12 @@ describe("cloudchamber create", () => { | |
| await runWrangler( | ||
| "cloudchamber create --image hello:world --location sfo06 --var HELLO:WORLD --var YOU:CONQUERED --instance-type lite --ipv4 true" | ||
| ); | ||
| expect(std.out).toMatchInlineSnapshot(`"{}"`); | ||
| expect(std.out).toMatchInlineSnapshot(` | ||
| " | ||
| ⛅️ wrangler x.x.x | ||
| ────────────────── | ||
| {}" | ||
| `); | ||
| }); | ||
|
|
||
| it("properly reads wrangler config", async () => { | ||
|
|
@@ -274,7 +280,32 @@ describe("cloudchamber create", () => { | |
| await runWrangler( | ||
| "cloudchamber create --var HELLO:WORLD --var YOU:CONQUERED" | ||
| ); | ||
| expect(std.out).toMatchInlineSnapshot(MOCK_DEPLOYMENTS_COMPLEX_RESPONSE); | ||
| expect(std.out).toMatchInlineSnapshot(` | ||
| " | ||
| ⛅️ wrangler x.x.x | ||
| ────────────────── | ||
| { | ||
| \\"id\\": \\"1\\", | ||
| \\"type\\": \\"default\\", | ||
| \\"created_at\\": \\"123\\", | ||
| \\"account_id\\": \\"123\\", | ||
| \\"vcpu\\": 4, | ||
| \\"memory\\": \\"400MB\\", | ||
| \\"memory_mib\\": 400, | ||
| \\"version\\": 1, | ||
| \\"image\\": \\"hello\\", | ||
| \\"location\\": { | ||
| \\"name\\": \\"sfo06\\", | ||
| \\"enabled\\": true | ||
| }, | ||
| \\"network\\": { | ||
| \\"mode\\": \\"public\\", | ||
| \\"ipv4\\": \\"1.1.1.1\\" | ||
| }, | ||
| \\"placements_ref\\": \\"http://ref\\", | ||
| \\"node_group\\": \\"metal\\" | ||
| }" | ||
| `); | ||
| expect(std.err).toMatchInlineSnapshot(`""`); | ||
| }); | ||
|
|
||
|
|
@@ -306,7 +337,12 @@ describe("cloudchamber create", () => { | |
| await runWrangler( | ||
| "cloudchamber create --var HELLO:WORLD --var YOU:CONQUERED" | ||
| ); | ||
| expect(std.out).toMatchInlineSnapshot(`"{}"`); | ||
| expect(std.out).toMatchInlineSnapshot(` | ||
| " | ||
| ⛅️ wrangler x.x.x | ||
| ────────────────── | ||
| {}" | ||
| `); | ||
| expect(std.err).toMatchInlineSnapshot(`""`); | ||
| }); | ||
|
|
||
|
|
@@ -349,7 +385,32 @@ describe("cloudchamber create", () => { | |
| await runWrangler( | ||
| "cloudchamber create --image hello:world --location sfo06 --var HELLO:WORLD --var YOU:CONQUERED --all-ssh-keys --ipv4" | ||
| ); | ||
| expect(std.out).toMatchInlineSnapshot(MOCK_DEPLOYMENTS_COMPLEX_RESPONSE); | ||
| expect(std.out).toMatchInlineSnapshot(` | ||
| " | ||
| ⛅️ wrangler x.x.x | ||
| ────────────────── | ||
| { | ||
| \\"id\\": \\"1\\", | ||
| \\"type\\": \\"default\\", | ||
| \\"created_at\\": \\"123\\", | ||
| \\"account_id\\": \\"123\\", | ||
| \\"vcpu\\": 4, | ||
| \\"memory\\": \\"400MB\\", | ||
| \\"memory_mib\\": 400, | ||
| \\"version\\": 1, | ||
| \\"image\\": \\"hello\\", | ||
| \\"location\\": { | ||
| \\"name\\": \\"sfo06\\", | ||
| \\"enabled\\": true | ||
| }, | ||
| \\"network\\": { | ||
| \\"mode\\": \\"public\\", | ||
| \\"ipv4\\": \\"1.1.1.1\\" | ||
| }, | ||
| \\"placements_ref\\": \\"http://ref\\", | ||
| \\"node_group\\": \\"metal\\" | ||
| }" | ||
| `); | ||
| }); | ||
|
|
||
| it("can't create deployment due to lack of fields (json)", async () => { | ||
|
|
@@ -364,8 +425,11 @@ describe("cloudchamber create", () => { | |
| // so testing the actual UI will be harder than expected | ||
| // TODO: think better on how to test UI actions | ||
| expect(std.out).toMatchInlineSnapshot(` | ||
| " | ||
| [32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose[0m" | ||
| `); | ||
| " | ||
| ⛅️ wrangler x.x.x | ||
| ────────────────── | ||
|
|
||
| [32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose[0m" | ||
| `); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,13 +29,7 @@ describe("cloudchamber image", () => { | |
| expect(std.out).toMatchInlineSnapshot(` | ||
| "wrangler cloudchamber registries | ||
|
|
||
| Configure registries via Cloudchamber | ||
|
|
||
| COMMANDS | ||
| wrangler cloudchamber registries configure Configure Cloudchamber to pull from specific registries | ||
| wrangler cloudchamber registries credentials [domain] get a temporary password for a specific domain | ||
| wrangler cloudchamber registries remove [domain] removes the registry at the given domain | ||
| wrangler cloudchamber registries list list registries configured for this account | ||
| Configure registries via Cloudchamber [alpha] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this wanted ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps I missed a namespace definition here... |
||
|
|
||
| GLOBAL FLAGS | ||
| -c, --config Path to Wrangler configuration file [string] | ||
|
|
@@ -73,10 +67,13 @@ describe("cloudchamber image", () => { | |
| // so testing the actual UI will be harder than expected | ||
| // TODO: think better on how to test UI actions | ||
| expect(std.out).toMatchInlineSnapshot(` | ||
| "{ | ||
| \\"domain\\": \\"docker.io\\" | ||
| }" | ||
| `); | ||
| " | ||
| ⛅️ wrangler x.x.x | ||
| ────────────────── | ||
|
Comment on lines
+70
to
+72
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question about JSON output... |
||
| { | ||
| \\"domain\\": \\"docker.io\\" | ||
| }" | ||
| `); | ||
| }); | ||
|
|
||
| it("should create an image registry (no interactivity)", async () => { | ||
|
|
@@ -100,7 +97,12 @@ describe("cloudchamber image", () => { | |
| expect(std.err).toMatchInlineSnapshot(`""`); | ||
| // so testing the actual UI will be harder than expected | ||
| // TODO: think better on how to test UI actions | ||
| expect(std.out).toMatchInlineSnapshot(`"jwt"`); | ||
| expect(std.out).toMatchInlineSnapshot(` | ||
| " | ||
| ⛅️ wrangler x.x.x | ||
| ────────────────── | ||
| jwt" | ||
| `); | ||
| }); | ||
|
|
||
| it("should remove an image registry (no interactivity)", async () => { | ||
|
|
@@ -118,7 +120,12 @@ describe("cloudchamber image", () => { | |
| ); | ||
| await runWrangler("cloudchamber registries remove docker.io"); | ||
| expect(std.err).toMatchInlineSnapshot(`""`); | ||
| expect(std.out).toMatchInlineSnapshot(`"{}"`); | ||
| expect(std.out).toMatchInlineSnapshot(` | ||
| " | ||
| ⛅️ wrangler x.x.x | ||
| ────────────────── | ||
| {}" | ||
| `); | ||
| }); | ||
|
|
||
| it("should list registries (no interactivity)", async () => { | ||
|
|
@@ -145,7 +152,10 @@ describe("cloudchamber image", () => { | |
| await runWrangler("cloudchamber registries list"); | ||
| expect(std.err).toMatchInlineSnapshot(`""`); | ||
| expect(std.out).toMatchInlineSnapshot(` | ||
| "[ | ||
| " | ||
| ⛅️ wrangler x.x.x | ||
| ────────────────── | ||
| [ | ||
| { | ||
| \\"public_key\\": \\"\\", | ||
| \\"domain\\": \\"docker.io\\" | ||
|
|
@@ -182,8 +192,6 @@ describe("cloudchamber image list", () => { | |
| expect(std.out).toMatchInlineSnapshot(` | ||
| "wrangler cloudchamber images list | ||
|
|
||
| List images in the Cloudflare managed registry | ||
|
|
||
| GLOBAL FLAGS | ||
| -c, --config Path to Wrangler configuration file [string] | ||
| --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string] | ||
|
|
@@ -224,7 +232,10 @@ describe("cloudchamber image list", () => { | |
| await runWrangler("cloudchamber images list"); | ||
| expect(std.err).toMatchInlineSnapshot(`""`); | ||
| expect(std.out).toMatchInlineSnapshot(` | ||
| "REPOSITORY TAG | ||
| " | ||
| ⛅️ wrangler x.x.x | ||
| ────────────────── | ||
| REPOSITORY TAG | ||
| one hundred | ||
| one ten | ||
| two thousand | ||
|
|
@@ -260,7 +271,10 @@ describe("cloudchamber image list", () => { | |
| await runWrangler("cloudchamber images list --filter '^two$'"); | ||
| expect(std.err).toMatchInlineSnapshot(`""`); | ||
| expect(std.out).toMatchInlineSnapshot(` | ||
| "REPOSITORY TAG | ||
| " | ||
| ⛅️ wrangler x.x.x | ||
| ────────────────── | ||
| REPOSITORY TAG | ||
| two thousand | ||
| two twenty" | ||
| `); | ||
|
|
@@ -294,7 +308,10 @@ describe("cloudchamber image list", () => { | |
| await runWrangler("cloudchamber images list"); | ||
| expect(std.err).toMatchInlineSnapshot(`""`); | ||
| expect(std.out).toMatchInlineSnapshot(` | ||
| "REPOSITORY TAG | ||
| " | ||
| ⛅️ wrangler x.x.x | ||
| ────────────────── | ||
| REPOSITORY TAG | ||
| one hundred | ||
| one ten | ||
| two thousand | ||
|
|
@@ -330,7 +347,10 @@ describe("cloudchamber image list", () => { | |
| await runWrangler("cloudchamber images list --json"); | ||
| expect(std.err).toMatchInlineSnapshot(`""`); | ||
| expect(std.out).toMatchInlineSnapshot(` | ||
| "[ | ||
| " | ||
| ⛅️ wrangler x.x.x | ||
| ────────────────── | ||
| [ | ||
| { | ||
| \\"name\\": \\"one\\", | ||
| \\"tags\\": [ | ||
|
|
@@ -384,7 +404,10 @@ describe("cloudchamber image list", () => { | |
| await runWrangler("cloudchamber images list --json"); | ||
| expect(std.err).toMatchInlineSnapshot(`""`); | ||
| expect(std.out).toMatchInlineSnapshot(` | ||
| "[ | ||
| " | ||
| ⛅️ wrangler x.x.x | ||
| ────────────────── | ||
| [ | ||
| { | ||
| \\"name\\": \\"one\\", | ||
| \\"tags\\": [ | ||
|
|
@@ -434,8 +457,6 @@ describe("cloudchamber image delete", () => { | |
| expect(std.out).toMatchInlineSnapshot(` | ||
| "wrangler cloudchamber images delete <image> | ||
|
|
||
| Remove an image from the Cloudflare managed registry | ||
|
|
||
| POSITIONALS | ||
| image Image and tag to delete, of the form IMAGE:TAG [string] [required] | ||
|
|
||
|
|
@@ -488,7 +509,12 @@ describe("cloudchamber image delete", () => { | |
| await runWrangler("cloudchamber images delete one:hundred"); | ||
| expect(std.err).toMatchInlineSnapshot(`""`); | ||
| expect(std.out).toMatchInlineSnapshot( | ||
| `"Deleted one:hundred (some-digest)"` | ||
| ` | ||
| " | ||
| ⛅️ wrangler x.x.x | ||
| ────────────────── | ||
| Deleted one:hundred (some-digest)" | ||
| ` | ||
| ); | ||
| }); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't look inline to me 🤔