mirror of
https://github.com/beclab/Olares
synced 2026-04-21 13:37:46 +00:00
* cli, daemon: add `olares-cli status` backed by olaresd /system/status
Adds a new top-level `olares-cli status` command that calls the local
olaresd daemon's `/system/status` HTTP endpoint and prints either a
grouped, annotated human-readable report or raw JSON.
To avoid duplicating the response schema, the daemon's `state` struct
and related enums are extracted into a new shared package
`cli/pkg/daemon/state`. The daemon now type-aliases those types so all
existing daemon call sites keep compiling unchanged.
Made-with: Cursor
* cli: drop unused state.APIResponse envelope type
The HTTP client in cli/pkg/daemon/api/client.go intentionally uses an
inline anonymous envelope with json.RawMessage for the data field so
that --json mode can passthrough the bytes verbatim, so the public
APIResponse{Data State} type defined here had zero references. Remove
it; if a strongly-typed consumer ever shows up, re-add then.
Addresses Cursor Bugbot feedback on PR #2917.
Made-with: Cursor
|
||
|---|---|---|
| .. | ||
| apis/kubekey/v1alpha2 | ||
| cmd | ||
| pkg | ||
| version | ||
| .goreleaser.yaml | ||
| generate_vfs.go | ||
| go.mod | ||
| go.sum | ||
| README.md | ||
Olares CLI
This directory contains the code for olares-cli, the official command-line interface for administering an Olares cluster. It provides a modular, pipeline-based architecture for orchestrating complex system operations. See the full Olares CLI Documentation for command reference and tutorials.
Key responsibilities include:
- Cluster management: Installing, upgrading, restarting, and maintaining an Olares cluster.
- Node management: Adding to or removing nodes from an Olares cluster.
Execution Model
For most of the commands, olares-cli is executed through a four-tier hierarchy:
Pipeline ➜ Module ➜ Task ➜ Action
Example: install-olares Pipeline
Pipeline: Install Olares
├── ...other modules
└── Module: Bootstrap OS
├── ...other tasks
├── Task: Check Prerequisites
│ └── Action: run-precheck.sh
└── Task: Configure System
└── Action: apply-sysctl
Repository layout
cli/
├── cmd/ # Cobra command definitions
│ ├── main.go # CLI entry point
│ └── ctl/
│ ├── root.go
│ ├── os/ # OS-level maintenance commands
│ ├── node/ # Cluster node operations
│ └── gpu/ # GPU management
└── pkg/
├── core/
│ ├── action/ # Re-usable action primitives
│ ├── module/ # Module abstractions
│ ├── pipeline/ # Pipeline abstractions
│ └── task/ # Task abstractions
└── pipelines/ # Pre-built pipelines
│ ├── ... # actual modules and tasks for various commands and components
Build from source
Prerequisites
- Go 1.24+
- GoReleaser (optional, for cross-compiling and packaging)
Sample commands
# Clone the repo and enter the CLI folder
cd cli
# 1) Build for the host OS/ARCH
go build -o olares-cli ./cmd/main.go
# 2) Cross-compile for Linux amd64 (from macOS, for example)
GOOS=linux GOARCH=amd64 go build -o olares-cli ./cmd/main.go
# 3) Produce multi-platform artifacts (tar.gz, checksums, etc.)
goreleaser release --snapshot --clean
Development workflow
Add a new command
- Create the command file in
cmd/ctl/<category>/. - Define a pipeline in
pkg/pipelines/. - Implement modules & tasks inside the relevant
pkg/sub-packages.
Test your build
- Upload the self-built
olares-clibinary to a machine that's running Olares. - Replace the existing
olares-clibinary on the machine usingsudo cp -f olares-cli /usr/local/bin. - Execute arbitrary commands using
olares-cli