Documentation
¶
Overview ¶
Package application implements `olares-cli cluster application ...`.
"Application" here refers to the Olares ApplicationSpace abstraction over K8s Namespaces — the same surface the ControlHub SPA exposes under "Application Spaces" (see apps/packages/app/src/apps/controlHub/pages/ApplicationSpaces). Each visible application space is a Namespace; the SPA groups them by KubeSphere workspace to surface the user-vs-system distinction the cluster's RBAC enforces.
Boundary note: this tree is the runtime-state view. App-store lifecycle (install / uninstall / start / stop / upgrade) belongs to `olares-cli market`, which goes through the market service and has its own typed client (cmd/ctl/market). The two trees are complementary — `cluster application list` shows what's actually running on the cluster you can see, `market list` shows what's installable / installed from the user's app perspective.
Phase 1d (initial slice) ships only `list`. Later phases bring `get` (per-application detail) and `workloads` / `pods` (drill- down into a specific application's K8s objects).
Index ¶
- func NewApplicationCommand(f *cmdutil.Factory) *cobra.Command
- func NewGetCommand(f *cmdutil.Factory) *cobra.Command
- func NewListCommand(f *cmdutil.Factory) *cobra.Command
- func NewPodsCommand(f *cmdutil.Factory) *cobra.Command
- func NewStatusCommand(f *cmdutil.Factory) *cobra.Command
- func NewWorkloadsCommand(f *cmdutil.Factory) *cobra.Command
- type Namespace
- type NamespaceDetail
- type NamespaceGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewApplicationCommand ¶
NewApplicationCommand assembles `olares-cli cluster application`.
func NewGetCommand ¶
NewGetCommand: `olares-cli cluster application get <namespace> [-o table|json]`.
Hits `/api/v1/namespaces/<ns>` (the same K8s native namespace detail SPA's getNamespacesDetail uses, see apps/packages/app/src/apps/controlPanelCommon/network/index.ts:283).
In `-o table` mode we print a vertical key/value summary (workspace via labels, status, age, label list); in `-o json` the response is forwarded verbatim. Pivot from here to `cluster application workloads <ns>` / `cluster application pods <ns>` for the contents.
func NewListCommand ¶
NewListCommand: `olares-cli cluster application list [-o table|json] [--label SELECTOR] [--no-headers] [--quiet]`
Calls SPA's getNamespacesGroup (apps/packages/app/src/apps/controlPanelCommon/network/index.ts:264): `/capi/namespaces/group`. The endpoint returns a non-enveloped array of {title, data:Namespace} entries — unlike the KubeSphere /kapis/* paths there is no {items, totalItems} wrapper, so we decode straight into []NamespaceGroup.
SPA passes labelSelector="kubesphere.io/workspace!= kubesphere.io/devopsproject" by default to hide internal devops projects; we forward --label verbatim so users can choose their own filter. Empty (unset) means "no filter, return what the server considers visible".
func NewPodsCommand ¶
NewPodsCommand: `olares-cli cluster application pods <namespace> [-l ...] [--field-selector ...] [--limit ...] [--page ...] [--all] [-o ...]`.
Convenience alias for `cluster pod list -n <namespace> ...`, symmetric with `cluster application workloads`. Same server-side scoping rules apply, same pagination semantics (--limit / --page / --all all forwarded verbatim).
func NewStatusCommand ¶
NewStatusCommand: `olares-cli cluster application status <namespace> [--watch] [--interval D] [--events N] [-o table|json]`.
CLI-original aggregation — the ControlHub SPA does NOT have a single per-namespace health dashboard. Instead it spreads the same information across separate Pods / Workloads tabs. This verb fans out the underlying GETs (workloads × 3 kinds + pods + events) in parallel and renders one consolidated view, so a script answer "is application X healthy?" without crossing five terminal screens.
The fan-out goes through the same endpoints `cluster workload list`, `cluster pod list`, and `cluster pod events` use — server-side scoping is therefore identical (no client-side filtering / role gating; the security model stays "server decides").
--watch repaints (table) or emits one JSONL object (json) on each tick. Errors on any single fan-out lane don't abort the snapshot: we surface a "(failed: ...)" placeholder so users still see what IS available even when one of the three fetches fails.
func NewWorkloadsCommand ¶
NewWorkloadsCommand: `olares-cli cluster application workloads <namespace> [--kind ...] [-l ...] [--limit ...] [--page ...] [--all] [-o ...]`.
Convenience alias for `cluster workload list -n <namespace> ...`. Most user workflows arrive here from `cluster application list` then "show me what's running in this space"; offering it as a dedicated verb keeps that pivot a one-shot command rather than requiring two flag flips.
All filtering happens server-side via workload.RunList — there is no client-side namespace inference or scope expansion here (the security model is server-decides; see olares-cluster SKILL.md). Pagination (--limit / --page / --all) is forwarded verbatim and applies per-kind in --kind all mode.
Types ¶
type Namespace ¶
type Namespace struct {
Metadata struct {
Name string `json:"name"`
CreationTimestamp string `json:"creationTimestamp,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
} `json:"metadata"`
}
Namespace is the minimal corev1.Namespace view used to render list rows. Only metadata fields are exercised today; spec / status stay out until a verb actually needs them.
type NamespaceDetail ¶
type NamespaceDetail struct {
Kind string `json:"kind,omitempty"`
APIVersion string `json:"apiVersion,omitempty"`
Metadata struct {
Name string `json:"name"`
UID string `json:"uid,omitempty"`
CreationTimestamp string `json:"creationTimestamp,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
} `json:"metadata"`
Status struct {
Phase string `json:"phase,omitempty"`
} `json:"status,omitempty"`
}
NamespaceDetail is the K8s native Namespace shape (subset of corev1.Namespace) we render in `cluster application get`. status.phase covers the Active / Terminating distinction; labels carry KubeSphere's workspace + workload-type metadata.
type NamespaceGroup ¶
NamespaceGroup is one entry in the /capi/namespaces/group response. `title` is the workspace name; `data` is the list of Namespaces scoped to that workspace.