Aller au contenu principal

ADR-001: stoactl CLI Design

Status: Proposed Date: 2026-01-24 Author: Christophe ABOULICAM Related: CAB-899

Context

STOA needs a CLI that enables GitOps workflows and CI/CD integration. DevOps teams expect a declarative, kubectl-like experience for infrastructure-as-code patterns.

Requirements

  1. GitOps-native: stoactl apply -f as the primary workflow
  2. Familiar UX: kubectl/helm/terraform muscle memory
  3. CI/CD-friendly: Non-interactive, scriptable, exit codes
  4. Multi-context: Switch between environments easily
  5. Idempotent: Safe to run repeatedly

Decision

Create stoactl as a separate, declarative CLI following the kubectl pattern.

Naming Convention

stoactl <verb> <resource> [name] [flags]
VerbDescriptionExample
getList/describe resourcesstoactl get apis
applyCreate or update from filestoactl apply -f api.yaml
deleteRemove resourcestoactl delete api billing-api
describeDetailed viewstoactl describe api billing-api
logsStream logsstoactl logs api billing-api -f
configManage contextsstoactl config use-context prod

Resources

ResourceAliasesDescription
apiapisAPI definitions
subscriptionsub, subsAPI subscriptions
apikeykey, keysAPI credentials
tenanttenantsTenant configurations
contractuac, contractsUAC contracts
policypoliciesRate limits, CORS, etc.

Resource Definitions (YAML)

API Definition

apiVersion: stoa.io/v1
kind: API
metadata:
name: billing-api
namespace: acme # tenant
labels:
team: finance
spec:
version: v2
description: "Invoice and payment management"
upstream:
url: https://billing.internal.acme.com
timeout: 30s
retries: 3
routing:
path: /billing
stripPath: true
methods: [GET, POST, PUT, DELETE]
authentication:
required: true
providers:
- type: apikey
header: X-API-Key
- type: jwt
issuer: https://auth.<YOUR_DOMAIN>/realms/acme
policies:
rateLimit:
requestsPerHour: 10000
cors:
origins: ["https://*.acme.com"]
cache:
enabled: true
ttlSeconds: 300
catalog:
visibility: public
categories: [Finance, Billing]

Subscription Definition

apiVersion: stoa.io/v1
kind: Subscription
metadata:
name: mobile-app-billing
namespace: acme
spec:
apiRef:
name: billing-api
plan: premium
application:
name: ACME Mobile App
owner: mobile-team@acme.com
quotas:
requestsPerMonth: 1000000

Configuration File

Location: ~/.stoa/config

apiVersion: stoa.io/v1
kind: Config
current-context: production

contexts:
- name: production
context:
server: https://api.<YOUR_DOMAIN>
tenant: acme

- name: staging
context:
server: https://api.staging.gostoa.dev
tenant: acme-staging

- name: local
context:
server: http://localhost:8080
tenant: dev

Command Examples

# Context management
stoactl config set-context prod --server=https://api.<YOUR_DOMAIN> --tenant=acme
stoactl config use-context prod
stoactl auth login

# CRUD operations
stoactl get apis
stoactl get api billing-api -o yaml
stoactl apply -f api.yaml
stoactl apply -f api.yaml --dry-run
stoactl diff -f api.yaml
stoactl delete api billing-api

# Output formats
stoactl get apis -o wide
stoactl get apis -o yaml
stoactl get apis -o json

Exit Codes

CodeMeaning
0Success
1General error
2Misuse (bad flags)
3Authentication failed
4Resource not found
5Conflict
6Validation error

Implementation

Technology: Go

  • Single binary distribution
  • Cobra/Viper CLI libraries
  • Cross-platform compilation
  • kubectl/helm ecosystem familiarity

Distribution

ChannelCommandStatus
Homebrewbrew install stoa-platform/tap/stoactlPlanned Q3 2026
BinaryGitHub ReleasesPlanned Q3 2026
Dockerdocker run ghcr.io/stoa-platform/stoactlPlanned Q3 2026

Distribution channels will be available when the CLI exits private beta. Request access to participate.

Consequences

Positive

  • DevOps teams get familiar GitOps workflow
  • CI/CD integration is trivial
  • Resource definitions are self-documenting
  • Multi-environment management built-in

Negative

  • Two CLIs to maintain (stoa interactive + stoactl GitOps)
  • YAML fatigue for simple operations

References