Skip to content

feat: CGW strategy + plugin architecture + CI workflows#67

Merged
osmman merged 3 commits intomainfrom
cgw-cli-strategy
Apr 28, 2026
Merged

feat: CGW strategy + plugin architecture + CI workflows#67
osmman merged 3 commits intomainfrom
cgw-cli-strategy

Conversation

@osmman
Copy link
Copy Markdown
Contributor

@osmman osmman commented Apr 27, 2026

Summary

  • CGW download strategy: downloads CLI binaries (cosign, gitsign, rekor-cli, ec, tuftool) from Red Hat content gateway via CGW_URL env var
  • Plugin architecture: refactored all CLI strategies from a monolithic switch-case into self-registering sub-packages under pkg/strategy/ with init() auto-registration, named business logic functions, and a shared strategy.Register()/strategy.Get()/strategy.Has() registry
  • Comprehensive tests: every strategy has TestRegistered, TestStrategy, TestStrategyError with httptest mocks, fake k8s client (openshift), Docker API mock (container), and local git repo (git). Shared helpers in pkg/strategy/testutil/
  • CI workflows: ci.yml (lint + unit tests on PR/push) and e2e.yml (full Kind + RHTAS deployment, cross-repo triggerable via workflow_dispatch)

Strategy modules

Strategy Env vars Description
local Finds binary on PATH
cli_server CLI_SERVER_URL Downloads .gz from CLI server
cgw CGW_URL Downloads tar.gz from content gateway
openshift Looks up ConsoleCLIDownload CRD
container CONTAINER_IMAGE, CONTAINER_PATH Extracts binary from container image
git GIT_URL, GIT_BRANCH, GIT_BUILD_DIR Clones repo and runs go build

Other changes

  • go.mod bumped to go 1.24 (enables t.Context() in tests)
  • kubernetes.ConsoleCLIDownload() accepts controller.Reader param for testability
  • Old pkg/clients/clistrategy.go deleted, replaced by pkg/clients/strategies.go (blank imports)

Test plan

  • go test ./pkg/... -v -count=1 — 22 unit tests pass
  • go build ./... — full project builds
  • actionlint — both workflows pass
  • act push -j unit-test — CI workflow verified locally via act
  • E2E workflow — requires GitHub Actions runners (Kind + RHTAS stack)

🤖 Generated with Claude Code

Add a new `cgw` CLI strategy that downloads CLI binaries from the
Red Hat content gateway (developers.redhat.com). This enables
downloading release binaries without requiring an OpenShift cluster
or a CLI server.

Set CLI_STRATEGY=cgw and CGW_URL to the content gateway base URL
(e.g. https://developers.redhat.com/content-gateway/file/cgw/RHTAS/1.4.0).

Made-with: Cursor
@osmman osmman requested review from bouskaJ and petrpinkas April 27, 2026 15:27
@osmman osmman force-pushed the cgw-cli-strategy branch from f8a2ad5 to 61a199c Compare April 27, 2026 15:38
…cture

Replace the monolithic switch-based PreferredSetupStrategy() in
pkg/clients/clistrategy.go with a plugin registry pattern under
pkg/strategy/. Each strategy (local, cli_server, cgw, openshift,
container, git) is now a self-contained package with init()
auto-registration, named business logic functions for testability,
and standardized tests (TestRegistered, TestStrategy, TestStrategyError).

Key changes:
- pkg/strategy/strategy.go: Registry with Register(), Get(), Has()
- Each strategy in its own sub-package with init() registration
- Business logic extracted into named functions (not nested closures)
- kubernetes.ConsoleCLIDownload() accepts controller.Reader for testability
- container.go: extracted dockerAPI interface for mock testing
- Shared test helpers in pkg/strategy/testutil/
- All tests use t.Context() (Go 1.24+), httptest mocks, no network calls
- New env vars: CONTAINER_IMAGE, CONTAINER_PATH, GIT_URL, GIT_BRANCH, GIT_BUILD_DIR
- go.mod bumped to go 1.24

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@osmman osmman force-pushed the cgw-cli-strategy branch 3 times, most recently from 8e4e00a to 1ec3b5d Compare April 28, 2026 09:49
Replace the old validate.yml (lint-only) with two workflows:

- ci.yml: lint (golangci-lint v2.8.0) + unit tests on every PR/push
- e2e.yml: full E2E against a Kind cluster with RHTAS stack deployed
  via secure-sign-operator's kind-cluster action. Supports
  workflow_dispatch for cross-repo triggering with operator_image
  and operator_ref inputs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@osmman osmman force-pushed the cgw-cli-strategy branch from 1ec3b5d to 300baca Compare April 28, 2026 09:55
@osmman osmman merged commit d2d8992 into main Apr 28, 2026
6 checks passed
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.

2 participants