Skip to content

feat(ctl): add marketplace browsing commands (list, search, show)#1128

Open
iddocohen wants to merge 13 commits into
developfrom
ic-feat-add-marketplace-browsing
Open

feat(ctl): add marketplace browsing commands (list, search, show)#1128
iddocohen wants to merge 13 commits into
developfrom
ic-feat-add-marketplace-browsing

Conversation

@iddocohen

@iddocohen iddocohen commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Why

infrahubctl marketplace get <namespace/name> can download a schema or collection, but only if you already know its exact identifier. There is no way to discover what the marketplace offers.

Goal: let users browse and inspect marketplace content directly from the CLI.

Non-goals: no changes to get/download behavior; no new marketplace API endpoints (uses the existing list/detail REST endpoints).

What changed

Behavioral — three new commands under infrahubctl marketplace:

  • list [--collections] [--limit N] [--json] — browse schemas (default) or collections
  • search <term> [--collections] [--limit N] [--json] — filter the catalog via the API search= param
  • show <namespace/name> [--collection] [--json] — full details of one item (versions/members, dependencies), with schema/collection auto-detect

Implementation notes:

  • Reuses the existing marketplace.py helpers (HTTP client, identifier parsing, host/error handling) — raw dicts, no new models and no new dependencies
  • Rich tables by default; --json emits parseable JSON on stdout while status/notes go to stderr (clean for piping)
  • Cursor-based pagination: fetches all pages by default; --limit N caps output to a single page with a Showing N of <total> footer
  • Error taxonomy: 4xx → exit 1 (not-found/invalid input), 5xx/transport → exit 2 (network)

What stayed the same: the existing get/download command is untouched; no schema changes; the marketplace URL still resolves from --marketplace-url / INFRAHUB_MARKETPLACE_URL / config.

How to review

  • Core: infrahub_sdk/ctl/marketplace.py — new list/search/show commands and their helpers
  • Tests: tests/unit/ctl/test_marketplace_app.py
  • Generated (mechanical): docs/docs/infrahubctl/infrahubctl-marketplace.mdx

How to test

uv run pytest tests/unit/ctl/test_marketplace_app.py -v
uv run infrahubctl marketplace list
uv run infrahubctl marketplace search vlan
uv run infrahubctl marketplace show infrahub/vlan-translation

Impact & rollout

  • Backward compatibility: additive only; no breaking changes
  • Config/env changes: none (reuses the existing marketplace_url setting)
  • Deployment notes: safe to deploy

Checklist

  • Tests added/updated
  • Changelog entry added (changelog/+marketplace-browsing.added.md)
  • External docs updated (regenerated infrahubctl-marketplace.mdx)

Summary by cubic

Add marketplace browsing to infrahubctl so users can discover schemas and collections from the CLI. get behavior and config are unchanged; docs now mention browsing in the CLI overview.

  • New Features

    • infrahubctl marketplace list [--collections] [--limit N] [--json] — list schemas (default) or collections; follows cursor pagination; --limit caps to one page and shows a “Showing N of ” footer.
    • infrahubctl marketplace search <term> [--collections] [--limit N] [--json] — filter results via the API search= param; same pagination behavior.
    • infrahubctl marketplace show <namespace/name> [--collection] [--json] — full details with auto-detect; shows versions/members and dependencies.
    • Rich tables by default; --json prints parseable JSON to stdout while notes go to stderr; reuses existing marketplace helpers with no new dependencies.
  • Bug Fixes

    • Classify errors consistently: 4xx → exit 1; 5xx or transport errors → exit 2.
    • Stop pagination when has_next_page is true but the cursor is missing.
    • Keep show --json stdout clean (collision note goes to stderr).
    • Treat invalid JSON bodies as network errors with clear messaging.

Written for commit 445c037. Summary will update on new commits.

Review in cubic

@iddocohen iddocohen added the type/feature New feature or request label Jul 2, 2026
@github-actions github-actions Bot added the type/documentation Improvements or additions to documentation label Jul 2, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 4 files

Re-trigger cubic

@iddocohen iddocohen marked this pull request as ready for review July 2, 2026 21:05
@iddocohen iddocohen requested a review from a team as a code owner July 2, 2026 21:05
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 2, 2026

Copy link
Copy Markdown

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 445c037
Status: ✅  Deploy successful!
Preview URL: https://7ffb9515.infrahub-sdk-python.pages.dev
Branch Preview URL: https://ic-feat-add-marketplace-brow.infrahub-sdk-python.pages.dev

View logs

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.50649% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/ctl/marketplace.py 93.50% 3 Missing and 7 partials ⚠️
@@             Coverage Diff             @@
##           develop    #1128      +/-   ##
===========================================
+ Coverage    82.16%   82.30%   +0.14%     
===========================================
  Files          138      138              
  Lines        11898    12051     +153     
  Branches      1784     1810      +26     
===========================================
+ Hits          9776     9919     +143     
- Misses        1572     1575       +3     
- Partials       550      557       +7     
Flag Coverage Δ
integration-tests 40.82% <12.98%> (-0.35%) ⬇️
python-3.10 55.75% <93.50%> (+0.49%) ⬆️
python-3.11 55.73% <93.50%> (+0.49%) ⬆️
python-3.12 55.73% <93.50%> (+0.47%) ⬆️
python-3.13 55.73% <93.50%> (+0.47%) ⬆️
python-3.14 55.73% <93.50%> (+0.49%) ⬆️
python-filler-3.12 22.46% <0.00%> (-0.30%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/ctl/marketplace.py 92.88% <93.50%> (+0.62%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/documentation Improvements or additions to documentation type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant