From 5fe52365c20c25f99757e6b509eb0d4ff9672eae Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 15 Feb 2026 09:44:56 +0000 Subject: [PATCH 1/2] Initial plan From 826670b4287b9604acbd3c5f64ce36ee194982ef Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 15 Feb 2026 09:47:29 +0000 Subject: [PATCH 2/2] Add metadata CLI command and document Metadata, Users/Bots, and Drift commands in README Co-authored-by: aatarasoff <3737657+aatarasoff@users.noreply.github.com> --- README.md | 94 +++++++++++++++++++++++++++++++++++++++++++++++++ cmd/metadata.go | 57 ++++++++++++++++++++++++++++++ cmd/root.go | 2 ++ 3 files changed, 153 insertions(+) create mode 100644 cmd/metadata.go diff --git a/README.md b/README.md index a7fd16a..740a3a4 100644 --- a/README.md +++ b/README.md @@ -313,6 +313,100 @@ pbuf modules delete [module_name] The command deletes all the tags and proto files associated with the module. +##### Get Metadata + +The metadata command allows you to get parsed metadata (packages) for a module tag. + +```bash +pbuf metadata get [module_name] [tag] +``` + +Replace `[module_name]` with the name of the module. Replace `[tag]` with the tag to get metadata for. + +> If `module_name` is not provided, the `name` from `pbuf.yaml` is used. + +#### Users / Bots + +The `users` command group allows you to manage users, bots, and permissions. + +##### Create User or Bot + +```bash +pbuf users create [name] --type user|bot +``` + +Replace `[name]` with the user or bot name. The `--type` flag defaults to `user`. + +##### List Users + +```bash +pbuf users list [--page-size 50] [--page 0] +``` + +##### Get User + +```bash +pbuf users get [id] +``` + +##### Update User + +```bash +pbuf users update [id] [--name new_name] [--active] [--inactive] +``` + +Only one of `--active` or `--inactive` can be set at a time. + +##### Delete User + +```bash +pbuf users delete [id] +``` + +##### Regenerate Token + +```bash +pbuf users regenerate-token [id] +``` + +##### Grant Permission + +```bash +pbuf users grant-permission [user_id] [module_name] --permission read|write|admin +``` + +##### Revoke Permission + +```bash +pbuf users revoke-permission [user_id] [module_name] +``` + +##### List Permissions + +```bash +pbuf users list-permissions [user_id] +``` + +#### Drift Detection + +The `drift` command group allows you to manage drift detection events. + +##### List Drift Events + +```bash +pbuf drift list [--unacknowledged-only] +``` + +The `--unacknowledged-only` flag defaults to `true` and filters to only unacknowledged events. + +##### Get Module Drift Events + +```bash +pbuf drift module [module_name] [--tag tag_name] +``` + +Replace `[module_name]` with the name of the module. Use the optional `--tag` flag to filter by tag name. + --- ### Configuration (`pbuf.yaml`) diff --git a/cmd/metadata.go b/cmd/metadata.go new file mode 100644 index 0000000..299f9d8 --- /dev/null +++ b/cmd/metadata.go @@ -0,0 +1,57 @@ +package cmd + +import ( + v1 "github.com/pbufio/pbuf-cli/gen/pbuf-registry/v1" + "github.com/pbufio/pbuf-cli/internal/model" + "github.com/spf13/cobra" +) + +func NewMetadataCmd(config *model.Config, client v1.MetadataServiceClient) *cobra.Command { + metadataCmd := &cobra.Command{ + Use: "metadata", + Short: "Metadata", + Long: "Metadata is a command to interact with module metadata", + RunE: func(cmd *cobra.Command, args []string) error { + return cmd.Help() + }, + } + + metadataCmd.AddCommand(newGetMetadataCmd(config, client)) + + return metadataCmd +} + +func newGetMetadataCmd(config *model.Config, client v1.MetadataServiceClient) *cobra.Command { + getCmd := &cobra.Command{ + Use: "get [module_name] [tag]", + Short: "Get metadata", + Long: "Get is a command to get parsed metadata (packages) for a module tag", + Args: cobra.RangeArgs(0, 2), + RunE: func(cmd *cobra.Command, args []string) error { + moduleName := config.Name + if len(args) > 0 { + moduleName = args[0] + } + if moduleName == "" { + return cmd.Help() + } + + tag := "" + if len(args) > 1 { + tag = args[1] + } + + resp, err := client.GetMetadata(cmd.Context(), &v1.GetMetadataRequest{ + Name: moduleName, + Tag: tag, + }) + if err != nil { + return err + } + + return printJSON(resp) + }, + } + + return getCmd +} diff --git a/cmd/root.go b/cmd/root.go index aa7e4d8..0972f5c 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -71,12 +71,14 @@ func NewRootCmd() *cobra.Command { registryClient := v1.NewRegistryClient(conn) usersClient := v1.NewUserServiceClient(conn) driftClient := v1.NewDriftServiceClient(conn) + metadataClient := v1.NewMetadataServiceClient(conn) rootCmd.AddCommand(NewModuleCmd(modulesConfig, registryClient)) rootCmd.AddCommand(NewVendorCmd(modulesConfig, netrcAuth, registryClient)) rootCmd.AddCommand(NewAuthCmd(modulesConfig, usr, netrcAuth)) rootCmd.AddCommand(NewUsersCmd(modulesConfig, usersClient)) rootCmd.AddCommand(NewDriftCmd(modulesConfig, driftClient)) + rootCmd.AddCommand(NewMetadataCmd(modulesConfig, metadataClient)) } else { rootCmd.AddCommand(NewVendorCmd(modulesConfig, netrcAuth, nil)) }