Skip to content

[Draft] Cli#753

Draft
jhivandb wants to merge 17 commits intowso2:mainfrom
jhivandb:cli
Draft

[Draft] Cli#753
jhivandb wants to merge 17 commits intowso2:mainfrom
jhivandb:cli

Conversation

@jhivandb
Copy link
Copy Markdown

Purpose

Describe the problems, issues, or needs driving this feature/fix and include links to related issues in the following format: Resolves issue1, issue2, etc.

Goals

Describe the solutions that this feature/fix will introduce to resolve the problems described above

Approach

Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI (email documentation@wso2.com to review all UI text). Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here.

User stories

Summary of user stories addressed by this change>

Release note

Brief description of the new feature or bug fix as it will appear in the release notes

Documentation

Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter �N/A� plus brief explanation of why there�s no doc impact

Training

Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable

Certification

Type �Sent� when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to certification@wso2.com and NOT pasted in this PR. If there is no impact on certification exams, type �N/A� and explain why.

Marketing

Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable

Automation tests

  • Unit tests

    Code coverage information

  • Integration tests

    Details about the test cases and coverage

Security checks

Samples

Provide high-level details about the samples related to this feature

Related PRs

List any other related PRs

Migrations (if applicable)

Describe migration steps and platforms on which migration has been tested

Test environment

List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested

Learning

Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 87cc756c-628b-4afe-81d1-469b7e524863

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

jhivandb added 15 commits April 27, 2026 16:38
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.
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.

1 participant