cli

module
v0.0.0-...-23f3ea7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2026 License: AGPL-3.0

README

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
  1. Create the command file in cmd/ctl/<category>/.
  2. Define a pipeline in pkg/pipelines/.
  3. Implement modules & tasks inside the relevant pkg/ sub-packages.
Test your build
  1. Upload the self-built olares-cli binary to a machine that's running Olares.
  2. Replace the existing olares-cli binary on the machine using sudo cp -f olares-cli /usr/local/bin.
  3. Execute arbitrary commands using olares-cli

Directories

Path Synopsis
apis
kubekey/v1alpha2
Package v1alpha2 contains API Schema definitions for the kubekey v1alpha2 API group +kubebuilder:object:generate=true +groupName=kubekey.kubesphere.io
Package v1alpha2 contains API Schema definitions for the kubekey v1alpha2 API group +kubebuilder:object:generate=true +groupName=kubekey.kubesphere.io
cmd
ctl
ctl/cluster
Package cluster implements the `olares-cli cluster` umbrella command tree.
Package cluster implements the `olares-cli cluster` umbrella command tree.
ctl/cluster/application
Package application implements `olares-cli cluster application ...`.
Package application implements `olares-cli cluster application ...`.
ctl/cluster/container
Package container implements `olares-cli cluster container ...` — per-container drill-down inside a Pod.
Package container implements `olares-cli cluster container ...` — per-container drill-down inside a Pod.
ctl/cluster/cronjob
Package cronjob implements `olares-cli cluster cronjob ...` — CronJob inspection plus suspend/resume mutations.
Package cronjob implements `olares-cli cluster cronjob ...` — CronJob inspection plus suspend/resume mutations.
ctl/cluster/internal/clusteropts
Package clusteropts hosts the shared option bag used by every `cluster ...` verb (top-level + subpackages).
Package clusteropts hosts the shared option bag used by every `cluster ...` verb (top-level + subpackages).
ctl/cluster/job
Package job implements `olares-cli cluster job ...` — read- and write-side Job inspection (and the KubeSphere-flavored "rerun" action) for the active user's profile.
Package job implements `olares-cli cluster job ...` — read- and write-side Job inspection (and the KubeSphere-flavored "rerun" action) for the active user's profile.
ctl/cluster/middleware
Package middleware implements `olares-cli cluster middleware ...`.
Package middleware implements `olares-cli cluster middleware ...`.
ctl/cluster/middleware/password
Package password implements `olares-cli cluster middleware password ...`.
Package password implements `olares-cli cluster middleware password ...`.
ctl/cluster/namespace
Package namespace implements `olares-cli cluster namespace ...` — raw K8s Namespace inspection visible to the active profile.
Package namespace implements `olares-cli cluster namespace ...` — raw K8s Namespace inspection visible to the active profile.
ctl/cluster/node
Package node implements `olares-cli cluster node ...` — cluster node inspection visible to the active profile.
Package node implements `olares-cli cluster node ...` — cluster node inspection visible to the active profile.
ctl/cluster/pod
Package pod implements `olares-cli cluster pod ...` — read-side pod inspection for the active user's profile.
Package pod implements `olares-cli cluster pod ...` — read-side pod inspection for the active user's profile.
ctl/cluster/workload
Package workload implements `olares-cli cluster workload ...` — read-side workload (Deployment / StatefulSet / DaemonSet) inspection for the active user's profile.
Package workload implements `olares-cli cluster workload ...` — read-side workload (Deployment / StatefulSet / DaemonSet) inspection for the active user's profile.
ctl/dashboard
Package dashboard implements the `olares-cli dashboard` subtree — the AI-agent-oriented mirror of the dashboard SPA's overview / applications pages.
Package dashboard implements the `olares-cli dashboard` subtree — the AI-agent-oriented mirror of the dashboard SPA's overview / applications pages.
ctl/dashboard/applications
Package applications hosts the cobra wiring for `olares-cli dashboard applications`; business logic lives in cli/pkg/dashboard/applications/.
Package applications hosts the cobra wiring for `olares-cli dashboard applications`; business logic lives in cli/pkg/dashboard/applications/.
ctl/dashboard/overview
Package overview hosts the cobra subtree for `olares-cli dashboard overview`.
Package overview hosts the cobra subtree for `olares-cli dashboard overview`.
ctl/dashboard/overview/disk
Package disk hosts the cobra wiring for `olares-cli dashboard overview disk` (root + main + partitions).
Package disk hosts the cobra wiring for `olares-cli dashboard overview disk` (root + main + partitions).
ctl/dashboard/overview/fan
Package fan hosts the cobra wiring for `olares-cli dashboard overview fan` (root + live + curve).
Package fan hosts the cobra wiring for `olares-cli dashboard overview fan` (root + live + curve).
ctl/dashboard/overview/gpu
Package gpu hosts the cobra wiring for `olares-cli dashboard overview gpu` (root + list + tasks + get + task + detail + task-detail).
Package gpu hosts the cobra wiring for `olares-cli dashboard overview gpu` (root + list + tasks + get + task + detail + task-detail).
ctl/dashboard/schema
Package schema hosts the `olares-cli dashboard schema` introspection command.
Package schema hosts the `olares-cli dashboard schema` introspection command.
ctl/files
Package files implements the `olares-cli files ...` command tree, which talks to the per-user files-backend (the upstream `files` repo) over its /api/resources REST surface.
Package files implements the `olares-cli files ...` command tree, which talks to the per-user files-backend (the upstream `files` repo) over its /api/resources REST surface.
ctl/profile
Package profile implements the `olares-cli profile` command tree.
Package profile implements the `olares-cli profile` command tree.
ctl/settings
Package settings implements the `olares-cli settings` umbrella command tree.
Package settings implements the `olares-cli settings` umbrella command tree.
ctl/settings/advanced
Package advanced hosts `olares-cli settings advanced` (the SPA's Developer/ folder, surfaced as "Advanced" in the docs).
Package advanced hosts `olares-cli settings advanced` (the SPA's Developer/ folder, surfaced as "Advanced" in the docs).
ctl/settings/appearance
Package appearance hosts `olares-cli settings appearance`.
Package appearance hosts `olares-cli settings appearance`.
ctl/settings/apps
Package apps hosts the `olares-cli settings apps ...` subtree.
Package apps hosts the `olares-cli settings apps ...` subtree.
ctl/settings/backup
Package backup hosts `olares-cli settings backup`.
Package backup hosts `olares-cli settings backup`.
ctl/settings/gpu
Package gpu hosts `olares-cli settings gpu`.
Package gpu hosts `olares-cli settings gpu`.
ctl/settings/integration
Package integration hosts `olares-cli settings integration`.
Package integration hosts `olares-cli settings integration`.
ctl/settings/internal/preflight
Package preflight is the soft role-gate adapter shared by every `olares-cli settings` area.
Package preflight is the soft role-gate adapter shared by every `olares-cli settings` area.
ctl/settings/me
Package me hosts the `olares-cli settings me ...` self-service subtree.
Package me hosts the `olares-cli settings me ...` self-service subtree.
ctl/settings/network
Package network hosts `olares-cli settings network`.
Package network hosts `olares-cli settings network`.
ctl/settings/restore
Package restore hosts `olares-cli settings restore`.
Package restore hosts `olares-cli settings restore`.
ctl/settings/search
Package search hosts `olares-cli settings search`.
Package search hosts `olares-cli settings search`.
ctl/settings/users
Package users hosts the `olares-cli settings users ...` subtree.
Package users hosts the `olares-cli settings users ...` subtree.
ctl/settings/video
Package video hosts `olares-cli settings video`.
Package video hosts `olares-cli settings video`.
ctl/settings/vpn
Package vpn hosts `olares-cli settings vpn`.
Package vpn hosts `olares-cli settings vpn`.
internal
files/cp
Package cp implements the wire side of `olares-cli files cp` and `olares-cli files mv`.
Package cp implements the wire side of `olares-cli files cp` and `olares-cli files mv`.
files/download
Package download implements the per-file and recursive directory download path for `olares-cli files download` and `files cat`.
Package download implements the per-file and recursive directory download path for `olares-cli files download` and `files cat`.
files/encodepath
Package encodepath implements percent-encoding for Olares files-backend wire paths so the CLI matches the LarePass web client (apps/packages/app/src/utils/encode.ts: encodeUrl / encodeURIComponent).
Package encodepath implements percent-encoding for Olares files-backend wire paths so the CLI matches the LarePass web client (apps/packages/app/src/utils/encode.ts: encodeUrl / encodeURIComponent).
files/mkdir
Package mkdir implements the wire side of `olares-cli files mkdir`, hitting the per-user files-backend's "create directory" endpoint:
Package mkdir implements the wire side of `olares-cli files mkdir`, hitting the per-user files-backend's "create directory" endpoint:
files/rename
Package rename implements the wire side of `olares-cli files rename`, hitting the per-user files-backend's in-place rename endpoint:
Package rename implements the wire side of `olares-cli files rename`, hitting the per-user files-backend's in-place rename endpoint:
files/repos
Package repos implements the wire side of `olares-cli files repos`, the listing of Sync (Seafile / Seahub) repositories under the user's account.
Package repos implements the wire side of `olares-cli files repos`, the listing of Sync (Seafile / Seahub) repositories under the user's account.
files/rm
Package rm implements the wire side of `olares-cli files rm`.
Package rm implements the wire side of `olares-cli files rm`.
files/share
Package share implements the wire side of `olares-cli files share`, covering the three folder-sharing surfaces the LarePass web app exposes: Internal (in-Olares cross-user shares), Public (external links with optional password / expiration / upload-only), and SMB (Samba network shares).
Package share implements the wire side of `olares-cli files share`, covering the three folder-sharing surfaces the LarePass web app exposes: Internal (in-Olares cross-user shares), Public (external links with optional password / expiration / upload-only), and SMB (Samba network shares).
files/upload
api.go: thin HTTP client for the per-user files-backend's Drive v2 upload-related endpoints.
api.go: thin HTTP client for the per-user files-backend's Drive v2 upload-related endpoints.
keychain
Package keychain provides cross-platform secure storage for olares-cli secrets (currently used for the per-olaresId access/refresh token grants written by the `profile login` and `profile import` commands).
Package keychain provides cross-platform secure storage for olares-cli secrets (currently used for the per-olaresId access/refresh token grants written by the `profile login` and `profile import` commands).
keychain/keychainfake
Package keychainfake provides a process-local KeychainAccess implementation for tests.
Package keychainfake provides a process-local KeychainAccess implementation for tests.
lockfile
Package lockfile is a tiny wrapper over github.com/gofrs/flock that adds context-cancelable acquisition and a single deterministic lock-directory layout under cliconfig.Home().
Package lockfile is a tiny wrapper over github.com/gofrs/flock that adds context-cancelable acquisition and a single deterministic lock-directory layout under cliconfig.Home().
pkg
auth
Package auth provides olares-cli's authentication primitives: JWT expiry extraction, password-based login (/api/firstfactor + /api/secondfactor/totp), refresh-token bootstrap (/api/refresh), and the on-disk token store.
Package auth provides olares-cli's authentication primitives: JWT expiry extraction, password-based login (/api/firstfactor + /api/secondfactor/totp), refresh-token bootstrap (/api/refresh), and the on-disk token store.
cliconfig
Package cliconfig owns the on-disk profile configuration of olares-cli (~/.olares-cli/config.json).
Package cliconfig owns the on-disk profile configuration of olares-cli (~/.olares-cli/config.json).
cliutil
Package cliutil hosts CLI-tree-agnostic helpers shared across the cmd/ctl/* subtrees (settings, cluster, files, dashboard, market).
Package cliutil hosts CLI-tree-agnostic helpers shared across the cmd/ctl/* subtrees (settings, cluster, files, dashboard, market).
clusterclient
Package clusterclient is the HTTP wrapper olares-cli's `cluster` command tree uses to talk to the per-user ControlHub BFF (`<rp.ControlHubURL>`).
Package clusterclient is the HTTP wrapper olares-cli's `cluster` command tree uses to talk to the per-user ControlHub BFF (`<rp.ControlHubURL>`).
clusterctx
Package clusterctx centralizes the "who am I against this Olares cluster?" round-trip used by `olares-cli cluster context` and by any future verb that wants to render the active profile's identity / role / accessible workspaces from the ControlHub side.
Package clusterctx centralizes the "who am I against this Olares cluster?" round-trip used by `olares-cli cluster context` and by any future verb that wants to render the active profile's identity / role / accessible workspaces from the ControlHub side.
cmdutil
Package cmdutil holds the shared "Factory" that command implementations reach into instead of constructing their own clients / loading their own config / etc.
Package cmdutil holds the shared "Factory" that command implementations reach into instead of constructing their own clients / loading their own config / etc.
credential
Package credential is the orchestration layer that turns a cliconfig.ProfileConfig + a stored token into a fully-resolved view that command code can consume without touching disk directly.
Package credential is the orchestration layer that turns a cliconfig.ProfileConfig + a stored token into a fully-resolved view that command code can consume without touching disk directly.
daemon/api
Package api is a thin HTTP client for the local olaresd daemon.
Package api is a thin HTTP client for the local olaresd daemon.
daemon/state
Package state defines the data types exposed by the local olaresd daemon's GET /system/status endpoint.
Package state defines the data types exposed by the local olaresd daemon's GET /system/status endpoint.
dashboard
Package dashboard hosts the data + transport layer for the `olares-cli dashboard` CLI subtree.
Package dashboard hosts the data + transport layer for the `olares-cli dashboard` CLI subtree.
dashboard/applications
Package applications hosts the business logic for the `olares-cli dashboard applications` cobra leaf — a workload-grain table mirroring the SPA's Applications page.
Package applications hosts the business logic for the `olares-cli dashboard applications` cobra leaf — a workload-grain table mirroring the SPA's Applications page.
dashboard/format
Package format is a 1:1 Go port of the dashboard SPA's number / unit formatting helpers.
Package format is a 1:1 Go port of the dashboard SPA's number / unit formatting helpers.
dashboard/overview
Package overview hosts the business logic for the `olares-cli dashboard overview` cobra subtree — physical / user / ranking / cpu / memory / pods / network leaves plus the default fan-out aggregator.
Package overview hosts the business logic for the `olares-cli dashboard overview` cobra subtree — physical / user / ranking / cpu / memory / pods / network leaves plus the default fan-out aggregator.
dashboard/overview/disk
Package disk hosts the business logic for the `olares-cli dashboard overview disk` subtree (root + main + partitions).
Package disk hosts the business logic for the `olares-cli dashboard overview disk` subtree (root + main + partitions).
dashboard/overview/fan
Package fan hosts the business logic for the `olares-cli dashboard overview fan` subtree (root + live + curve).
Package fan hosts the business logic for the `olares-cli dashboard overview fan` subtree (root + live + curve).
dashboard/overview/gpu
Package gpu hosts the business logic for the `olares-cli dashboard overview gpu` subtree (root + list + tasks + get + task + detail + task-detail).
Package gpu hosts the business logic for the `olares-cli dashboard overview gpu` subtree (root + list + tasks + get + task + detail + task-detail).
gpu
k3s
olares
Package olares contains primitives shared across olares-cli that don't fit into a more specific subpackage.
Package olares contains primitives shared across olares-cli that don't fit into a more specific subpackage.
web5/crypto
Package crypto provides the following functionality: * Key Generation: secp256k1, ed25519 * Signing: secp256k1, ed25519 * Verification: secp256k1, ed25519 * A KeyManager abstraction that can be leveraged to manage/use keys (create, sign etc) as desired per the given use case
Package crypto provides the following functionality: * Key Generation: secp256k1, ed25519 * Signing: secp256k1, ed25519 * Verification: secp256k1, ed25519 * A KeyManager abstraction that can be leveraged to manage/use keys (create, sign etc) as desired per the given use case
web5/crypto/dsa/eddsa
Package eddsa implements the EdDSA signature schemes as per RFC 8032 https://tools.ietf.org/html/rfc8032.
Package eddsa implements the EdDSA signature schemes as per RFC 8032 https://tools.ietf.org/html/rfc8032.
web5/jwk
Package jwk implements a subset of the JSON Web Key spec (https://tools.ietf.org/html/rfc7517)
Package jwk implements a subset of the JSON Web Key spec (https://tools.ietf.org/html/rfc7517)
whoami
Package whoami centralizes the "who am I on this Olares?" round-trip.
Package whoami centralizes the "who am I on this Olares?" round-trip.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL