Skip to content
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

[CLI Refresh] Add build id commands #469

Merged

Conversation

antlai-temporal
Copy link
Contributor

What was changed

Implements

./temporal task-queue get-build-id-reachability
./temporal task-queue get-build-ids
./temporal task-queue update-build-ids add-new-compatible
./temporal task-queue update-build-ids add-new-default
./temporal task-queue update-build-ids promote-id-in-set
./temporal task-queue update-build-ids promote-set

Checklist

  1. Closes
    [CLI Refresh] Implement temporal task-queue build-ID commands (update- and get-) #468

@antlai-temporal antlai-temporal changed the base branch from main to cli-rewrite February 17, 2024 01:07
Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, only minor comments, and only the JSON field-name one I think is really required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would support combining this code and the next code into commands.taskqueue_buildids.go if you'd like since they're pretty small.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering about that, but the commands are at different levels, keeping all the sub commands of update_build_id in a separate file makes it a bit easier to find...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, though we don't over-optimize for discoverability or we'd put every command in its own file (or force every sub command to be in a file with its adjacent ones). But this is fine. You may want to separate the tests too. For discoverability, often you prefer to test foo.go in foo_test.go.

Comment on lines 28 to 30
BuildIds []string
DefaultForSet string
IsDefaultSet bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll probably want to provide "json:buildIds" type of struct tags for these since we usually want our JSON as camelCase (even if old CLI wasn't as kind/consistent).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return cctx.Printer.PrintStructured(items, printer.StructuredOptions{Table: &printer.TableOptions{}})
}

// Missing in the SDK?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't had a need to convert these to strings yet in the SDK I guess, but would support a PR there to add a String() to this type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is going away with the versioning rewrite, but I will make sure we have something like that after the rewrite...

Comment on lines 42 to 44
if cctx.JSONOutput {
return cctx.Printer.PrintStructured(items, printer.StructuredOptions{})
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can just get rid of this. Println doesn't print when JSON set, and Table is ignored when JSON set, so the code below will do what you want. So basically PrintStructured is abstracted for reuse for just this kind of use case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, much cleaner thanks!

Comment on lines 9 to 10
func updateBuildIds(cctx *CommandContext, parent *TemporalTaskQueueCommand, options *client.UpdateWorkerBuildIdCompatibilityOptions) error {
cl, err := parent.ClientOptions.dialClient(cctx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func updateBuildIds(cctx *CommandContext, parent *TemporalTaskQueueCommand, options *client.UpdateWorkerBuildIdCompatibilityOptions) error {
cl, err := parent.ClientOptions.dialClient(cctx)
func (c *TemporalTaskQueueUpdateBuildIdsCommand) updateBuildIds(cctx *CommandContext, options *client.UpdateWorkerBuildIdCompatibilityOptions) error {
cl, err := c.Parent.ClientOptions.dialClient(cctx)

Can make the common piece the receiver if you wanted to just c.Parent.updateBuildIds(cctx, options) in other commands below without having a top-level function. But not required or anything.

Copy link
Contributor Author

@antlai-temporal antlai-temporal Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't realize I had a base command built by the parser... That's great thanks!

Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor thing about test file name at #469 (comment), nothing big, LGTM

@antlai-temporal antlai-temporal merged commit a833592 into temporalio:cli-rewrite Feb 26, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants