A Chi-based HTTP server implementing the ROSA Trusted Actions API, automatically generated from OpenAPI specifications using oapi-codegen.
- Go 1.21+
- Node.js 16+ (for OpenAPI bundling)
- Make
- Git
# Build and run
make build
make run
# The server starts on :8080 by defaultThe server normally requires live OCM credentials and a reachable JWKS endpoint.
Set ROSA_TA_ENABLE_AUTH=false to bypass both — the server injects a hardcoded
dev-user identity with the SREP role so every endpoint is reachable without a
token.
Warning: never set
ROSA_TA_ENABLE_AUTH=falseoutside a local or CI environment.
For OSD / ROSA clusters, retrieve the admin kubeconfig via OCM using the cluster's internal ID:
INTERNAL_ID="<your-cluster-internal-id>"
ocm get /api/clusters_mgmt/v1/clusters/${INTERNAL_ID}/credentials \
| jq -r .kubeconfig \
> /tmp/${INTERNAL_ID}.kubeconfigexport ROSA_TA_ENABLE_AUTH=false
export ROSA_TA_KUBECONFIG=/tmp/${INTERNAL_ID}.kubeconfig
go run ./cmd/server/ --log-level debugYou should see:
WARN Auth disabled — using mock identity 'dev-user' with SREP role. Do not use in production.
INFO Using kubeconfig provider for cluster access (local mode)
INFO Starting server addr=:8080
curl -s http://localhost:8080/health | jq .{"status":"healthy","version":"dev","build_date":"unknown","git_commit":"unknown"}No Authorization header required — mock auth injects the identity automatically.
curl -s http://localhost:8080/api/v0/trusted-actions/ | jq .The request body accepts optional params to control which resource is fetched.
Defaults to listing pods in the default namespace.
# List pods in the default namespace (default params)
curl -s -X POST http://localhost:8080/api/v0/trusted-actions/cluster-info/run \
-H 'Content-Type: application/json' \
-d '{"target_cluster": "local"}' | jq .
# List all namespaces
curl -s -X POST http://localhost:8080/api/v0/trusted-actions/cluster-info/run \
-H 'Content-Type: application/json' \
-d '{
"target_cluster": "local",
"params": {"resource": "namespaces", "version": "v1"}
}' | jq .
# Get a specific pod
curl -s -X POST http://localhost:8080/api/v0/trusted-actions/cluster-info/run \
-H 'Content-Type: application/json' \
-d '{
"target_cluster": "local",
"params": {
"resource": "pods",
"namespace": "kube-system",
"name": "coredns-<id>",
"version": "v1"
}
}' | jq .A successful response looks like:
{
"id": "...",
"action": "cluster-info",
"status": "succeeded",
"target_cluster": "local",
"output": [ ... ],
"completed_at": "..."
}| Param | Default | Description |
|---|---|---|
resource |
pods |
Kubernetes resource type (e.g. namespaces, nodes) |
namespace |
default |
Namespace to query (omit for cluster-scoped resources) |
name |
(empty) | Specific resource name — omit to list all |
version |
v1 |
API version |
group |
(empty) | API group (empty = core group) |
The OpenAPI specification lives in the openapi/ directory. The build process bundles the multi-file spec and generates Go server code:
# Regenerate API code from the local spec
make generate
# Validate the OpenAPI spec
make validate-spec
# Preview API docs in the browser
npm run preview-docs# Build
make build
# Run tests
make test
# Integration tests
make test-integration
# Code quality
make lint
make fmt./bin/rosa-trusted-actions-server --listen-addr=":3000" --log-level="debug" --log-json# AWS Configuration
export AWS_REGION="us-east-1"
export AWS_ACCESS_KEY_ID="your-key"
export AWS_SECRET_ACCESS_KEY="your-secret"
# Application Configuration
export ROSA_TA_S3_BUCKET="trusted-actions-bucket"
export ROSA_TA_ALLOWED_ACCOUNTS="123456789012,987654321098"
# Authorization
export ROSA_TA_ROLES_CONFIG="configs/role_mapping.yaml"
export ROSA_TA_JWK_CERT_FILE="" # optional
export ROSA_TA_JWK_CERT_URL="https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/certs"
export ROSA_TA_OCM_BASE_URL="https://api.openshift.com"
export ROSA_TA_OCM_CLIENT_ID="some-client-id"
export ROSA_TA_OCM_CLIENT_SECRET="xxxxxxxxxxxxxxx"
export ROSA_TA_OCM_TOKEN=""Copy .env.example to .env and customize.
Base path: /api/v0/trusted-actions
GET /- List available Trusted ActionsGET /{action}- Describe a specific actionPOST /{action}/run- Execute a Trusted ActionGET /runs- List executionsGET /runs/{id}- Get execution detailsGET /audit- API call audit logGET /health- Health check
rosa-trusted-actions-server/
├── cmd/server/ # Main application
├── docs/ # API documentation (ReDoc)
├── internal/
│ ├── handlers/ # API handlers
│ ├── middleware/ # HTTP middleware
│ ├── config/ # Configuration
│ └── openapi/ # Generated code (committed, don't edit)
├── openapi/ # OpenAPI 3.0 specification (source of truth)
├── scripts/ # Helper scripts
└── Makefile # Build automation
Run make help for all available targets.