How rancher/ecm-distro-tools works
Main System Components
A. Source Code
1. Go Commands (cmd/*) – each subfolder under cmd (e.g., cmd/release, cmd/rke2_release, cmd/backport, etc.) is a standalone CLI tool that links against shared Go libraries.
2. Shell Scripts (bin/) – POSIX-compliant scripts and shell libraries that wrap or orchestrate other utilities.
3. Shared Libraries (pkg-style folders) – modules under http/, docker/, registry/, repository/, types/, exec/, mgmt/ provide reusable functionality (API clients, logging, reprository abstractions).
B. Build & Packaging
1. Makefile & cmd/*/Makefile – local build orchestration, multi-arch builds.
2. Dockerfile & .devcontainer – containerized build/test/development environment.
3. GitHub Actions workflows (.github/workflows/main.yml, release.yml) – CI/CD for building binaries, publishing container images, auto-releasing to GitHub.
4. action.yml – definition of the “Setup ecm-distro-tools” GitHub Action.
C. Installation & Distribution
1. install.sh – bootstrap script to fetch and install binaries + shell libs to /usr/local/bin/ecm-distro-tools.
2. GitHub Releases & Container Registry – artifacts published as GitHub release assets and Docker images (rancher/ecm-distro-tools).
D. QA & Infra
1. qa/aws-ec2-mgr & qa/infra – scripts and AMI definitions for spinning up EC2 instances for testing.
2. qa/workload-manifests – Kubernetes YAML to validate Rancher/K3s/RKE2 clusters.
E. Documentation & Reports
1. docs/ – markdown docs describing release processes, dependencies, testing.
2. reports/ – generated release notes and markdown summaries.
Relationships & Data Flows
• Developers commit code → GitHub triggers CI (main.yml):
• Build Go binaries (Makefile → go build)
• Build Docker image
• Run tests against http/, registry/, repository/ libraries
• On tagged release → release.yml:
• Publish binaries to GitHub Releases
• Push Docker image to container registry
• install.sh (end user) → Downloads from GitHub Releases → Installs binaries + shell libs (+ updates PATH)
• CLI tools & shell scripts → call into shared Go libs (for API calls to GitHub, Docker registry, Rancher APIs, Kubernetes clusters)
• QA scripts → provision EC2 instances → deploy workload-manifests → validate cluster using CLI tools
Architectural Patterns & Principles
• Modular CLI Architecture – each cmd/* folder is an independent command, minimizing cross-dependencies.
• Shared Library Layer – generic API clients and utilities centralized in http/, docker/, registry/, repository/, types/
• Polyglot Mono-repo – co-existence of Go binaries and POSIX shell scripts, with clearly separated directories.
• CI/CD as Code – GitHub Actions workflows define build & release pipelines.
• Infrastructure as Code – QA infra definitions (AMI JSON, Kubernetes YAML) for automated testing.
Relevant Technologies & Frameworks
• Go (modules, standard library)
• POSIX Shell + shellcheck for scripts
• Make & Docker for builds
• GitHub Actions for CI/CD
• GitHub API (via shared HTTP library)
• Docker Registry (via registry/ library)
• AWS EC2 (QA infra)
• Kubernetes manifests for cluster validation
Essential Elements
• Clear labels for each component (e.g., “cmd/release (Go CLI)”, “bin/libstd-ecm.sh (Shell library)”)
• code → CI/CD → artifacts → release channels → install
• runtime flows (CLI → shared libs → external APIs)
• QA provisioning and testing flows