Skip to content

feat(adaptive/traces): add policy CRUD commands#293

Merged
radiohead merged 6 commits intomainfrom
feat/adaptive-traces-policy-commands
Mar 31, 2026
Merged

feat(adaptive/traces): add policy CRUD commands#293
radiohead merged 6 commits intomainfrom
feat/adaptive-traces-policy-commands

Conversation

@csmarchbanks
Copy link
Copy Markdown
Contributor

@csmarchbanks csmarchbanks commented Mar 30, 2026

Summary

  • Add direct CLI commands for managing Adaptive Traces sampling policies under adaptive traces policies
  • Supports full CRUD: list, get, create, update, delete
  • Complements the existing K8s-style resource adapter (gcx resources get/push/pull/delete) with a more ergonomic provider-specific interface

New Commands

Command Description
policies list List all policies (table/wide/json/yaml output)
policies get <id> Get a single policy by ID (default yaml)
policies create -f <file> Create from JSON/YAML file or stdin (-)
policies update <id> -f <file> Update by ID from JSON/YAML file or stdin
policies delete <id>... Delete with confirmation prompt (--force to skip)

Test plan

  • All existing traces client tests pass
  • New tests for policy table codec (table, wide, error, empty, decode)
  • New tests for JSON and YAML input parsing
  • Integration-style tests for list, create, and delete via httptest servers
  • Manual testing against a live Grafana Cloud stack

🤖 Generated with Claude Code

csmarchbanks and others added 2 commits March 30, 2026 12:11
Add direct CLI commands for managing Adaptive Traces sampling policies
under `adaptive traces policies`, complementing the existing resource
adapter (gcx resources get/push/pull/delete) with a more ergonomic
provider-specific interface.

New commands:
- policies list: list all policies (table/wide/json/yaml)
- policies get <id>: get a single policy by ID
- policies create -f <file>: create from JSON/YAML file or stdin
- policies update <id> -f <file>: update by ID from file or stdin
- policies delete <id>...: delete with confirmation (--force to skip)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@csmarchbanks csmarchbanks marked this pull request as ready for review March 30, 2026 18:19
- Use %w instead of %v for YAML error wrapping (errorlint)
- Replace require with assert in HTTP handler (testifylint)
- Remove unused newTestCommand function (unused)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@claude
Copy link
Copy Markdown

claude bot commented Mar 30, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@csmarchbanks csmarchbanks force-pushed the feat/adaptive-traces-policy-commands branch from 7717f5b to d6fb77e Compare March 31, 2026 10:46
Copy link
Copy Markdown
Collaborator

@radiohead radiohead left a comment

Choose a reason for hiding this comment

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

Summary

  • 1 Critical: TypedCRUD invariant violation (CONSTITUTION.md)
  • 3 Major: Non-TTY delete blocking, sequential delete partial-failure, stdout mixing
  • 3 Minor: Confusing error message, duplicate opts, unbounded ReadAll

See inline comments for details.

Strengths

  • Clean Options pattern adherence
  • Good codec + integration test coverage
  • Proper url.PathEscape, safe YAML parsing, context propagation
  • Correct CLI grammar: adaptive traces policies {verb}

This comment has been generated by Claude Code

csmarchbanks and others added 2 commits March 31, 2026 05:09
- Use TypedCRUD[Policy] instead of raw client for all policy CRUD ops
- Move diagnostic output (Success, Info, prompts) to stderr
- Auto-reject delete confirmation in non-TTY contexts with clear error
- Collect all delete errors instead of stopping on first failure
- Merge duplicate create/update opts into shared policyFileOpts
- Use YAML-only parsing (superset of JSON) with cleaner error
- Add 10 MB size limit to policy file reads

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adapter-registered resources must use standard CRUD verbs (list, get,
create, update, delete). Alternative verbs (show, describe, search) are
reserved for provider-only resources without adapters.

Also adds missing Validate() to policiesDeleteOpts per Options pattern.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@csmarchbanks
Copy link
Copy Markdown
Contributor Author

@radiohead I have added a couple of commits to address all the changes. Please take another look.

@radiohead
Copy link
Copy Markdown
Collaborator

@radiohead I have added a couple of commits to address all the changes. Please take another look.

Approved, thank you!

@radiohead radiohead merged commit e874b87 into main Mar 31, 2026
11 checks passed
@radiohead radiohead deleted the feat/adaptive-traces-policy-commands branch March 31, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants