Conversation
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Generates an Agent Manager Service Go client and types from the local OpenAPI spec via oapi-codegen, plus a `make am-gen-client` target to regenerate. The generated package lives under internal/am/clients/amsvc/gen.
Introduces the building blocks the am subcommands compose:
iostreams: stdin/stdout/stderr wrapper with TTY detection
render: JSON success/error envelope + typed CLIError codes
prompter: line-prompt confirmation (typed-name deletion)
cmdutil: Factory (config + IOStreams + HTTP + AM client builder),
org/project resolution, scope helper, server-error mapping
Also extends config: adds Config.Save() so callers no longer pass the
path back in, drops the unused current_project field, marks the runtime
Path field as yaml:"-" so it isn't persisted, and tightens error
messages to Go conventions. Adds round-trip + missing-file tests.
Switches the CLI bootstrap and login command to the new shared infrastructure: amcmd loads config and builds a Factory, the root command silences Cobra's default error formatting in favor of typed JSON envelopes, and login renders success/error envelopes via render. After login, am peeks at the user's organizations (limit=2) and, if exactly one is available, persists it as current_org so subsequent commands can omit --org. Drops the explicit AuthStyleInHeader (oauth2's default for confidential clients) and the unused Name field on auth.LoginOptions. Wraps Main's exit code through os.Exit so child goroutines (if any) can flush.
Adds the first project-scoped commands on top of the new factory. Each command resolves --org/--project (falling back to the instance's captured current_org), calls the generated AM client, and renders the result as a JSON envelope. am agent delete requires either --yes or a typed-name confirmation prompt; when stdin is not a terminal, it returns a CONFIRMATION_REQUIRED error instead of silently deleting. Includes table-driven tests for the four delete branches (non-TTY without --yes, mismatched confirmation, 204 success, server 404).
Move CLIError and the wire-format error codes to a new internal/am/clierr package. render now owns only Scope, the envelope writers, and a private "already rendered" sentinel exposed via IsRendered. RenderError is renamed to render.Error. JSON wire format is unchanged.
Flag checks for --url and --client-id/--client-secret used bare clierr.New(InvalidFlag, ...) which bypassed the FlagError wrapper and exited 1 instead of 2. Matches the exit-code contract in amcmd.Main.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Goals
Approach
User stories
Release note
Documentation
Training
Certification
Marketing
Automation tests
Security checks
Samples
Related PRs
Migrations (if applicable)
Test environment
Learning