Skip to content

[augerctl] Support watch for get#93

Open
wzshiming wants to merge 1 commit intoetcd-io:mainfrom
wzshiming:feat/augerctl-get-watch
Open

[augerctl] Support watch for get#93
wzshiming wants to merge 1 commit intoetcd-io:mainfrom
wzshiming:feat/augerctl-get-watch

Conversation

@wzshiming
Copy link
Copy Markdown
Member

@wzshiming wzshiming commented Aug 13, 2024

part of #3

Test

Preparation cluster

Create a cluster and expose etcd port, to facilitate the creation of a cluster using kwokctl, this can be any other k8s cluster

# brew install kwok
kwokctl create cluster --etcd-port 2379

Watch leases changes

augerctl get leases -n kube-system -w

@wzshiming wzshiming force-pushed the feat/augerctl-get-watch branch 2 times, most recently from a2a05ca to 48e7cce Compare August 14, 2024 02:31
@wzshiming wzshiming marked this pull request as ready for review August 14, 2024 02:32
@wzshiming wzshiming force-pushed the feat/augerctl-get-watch branch from 48e7cce to 855e529 Compare August 14, 2024 02:35
@wzshiming
Copy link
Copy Markdown
Member Author

/cc @jmhbnz
/cc @siyuanfoundation

@jmhbnz
Copy link
Copy Markdown
Member

jmhbnz commented Sep 3, 2024

Hey @wzshiming - I'll review this one next, can you please rebase to fix conflicts, thanks! 🙏🏻

@wzshiming wzshiming force-pushed the feat/augerctl-get-watch branch from 855e529 to bfce023 Compare September 3, 2024 11:29
@wzshiming
Copy link
Copy Markdown
Member Author

Done, thank you for reviewing it 😄

clientv3 "go.etcd.io/etcd/client/v3"
)

func (c *client) Watch(ctx context.Context, prefix string, opOpts ...OpOption) error {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey @wzshiming - General question, have you put any thought into potential approaches for writing tests for augerctl? To add new features it gets easier over time if we have tests to verify existing features don't break.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure, my original plan was to add the e2e test after the subcommand get.

@wzshiming wzshiming force-pushed the feat/augerctl-get-watch branch from bfce023 to 1a58621 Compare September 9, 2024 08:54
@hwdef
Copy link
Copy Markdown
Contributor

hwdef commented Apr 3, 2026

@wzshiming
Hi, will you continue doing this PR?

@wzshiming wzshiming force-pushed the feat/augerctl-get-watch branch from 1a58621 to 53fbbfe Compare April 8, 2026 07:15
Copilot AI review requested due to automatic review settings April 8, 2026 07:15
@k8s-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: wzshiming
Once this PR has been reviewed and has the lgtm label, please assign wenjiaswe for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Signed-off-by: Shiming Zhang <wzshiming@hotmail.com>
@wzshiming wzshiming force-pushed the feat/augerctl-get-watch branch from 53fbbfe to 0c7870f Compare April 8, 2026 07:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds watch support to augerctl get, enabling streaming updates from etcd (similar to kubectl get -w) as part of the broader effort to provide kubectl-like direct-etcd operations.

Changes:

  • Extend the etcd client abstraction with Watch, plus a WithRevision option and PrevValue support in KeyValue.
  • Add --watch/-w and --watch-only flags to augerctl get, wiring them to the new watch implementation.
  • Update YAML/JSON printers to fall back to printing PrevValue when the current value is absent (e.g., delete events), and document watch usage.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pkg/client/client.go Adds Watch to the interface, introduces WithRevision, and extends KeyValue with PrevValue.
pkg/client/client_watch.go New etcd watch implementation that streams events into the existing response callback.
augerctl/command/get_command.go Adds CLI flags and control flow to list-then-watch or watch-only.
augerctl/command/printer_yaml.go Prints PrevValue when Value is missing during watch output.
augerctl/command/printer_json.go Prints PrevValue when Value is missing during watch output.
augerctl/README.md Documents augerctl get ... -w usage and kubectl equivalence guidance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 97 to +99

cmd.Flags().BoolVarP(&flags.Watch, "watch", "w", false, "after listing/getting the requested object, watch for changes")
cmd.Flags().BoolVar(&flags.WatchOnly, "watch-only", false, "watch for changes to the requested object(s), without listing/getting first")
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

--watch-only currently requires --watch (and otherwise errors), which differs from kubectl semantics and makes --watch-only awkward to use. Consider making --watch-only imply watch mode (i.e., treat --watch-only as equivalent to --watch --watch-only) and enforce mutual exclusion in flag validation instead of requiring both flags.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants