local

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package local provides an in-process kukeonv1.Client backed by a controller.Exec. Used by the CLI in --no-daemon mode (init, uninstall, purge *, get *, plus log/refresh/start/stop/doctor-cgroups via the `--run-path` promotion — workload commands routed through here pre-#566 were moved off to shared.DaemonClientFromCmd in phase 3), by the `kuke image *` subcommands as the always-in-process path (#226), and by the daemon itself when servicing RPC calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an in-process kukeonv1.Client.

func New

func New(ctx context.Context, logger *slog.Logger, opts controller.Options) *Client

New returns a Client that owns its controller.Exec. Close releases it.

func NewFromExec

func NewFromExec(ctrl *controller.Exec) *Client

NewFromExec wraps an already-constructed controller.Exec. The caller retains ownership of ctrl; Close is a no-op in this mode.

func (*Client) ApplyDocuments

func (c *Client) ApplyDocuments(ctx context.Context, rawYAML []byte) (kukeonv1.ApplyDocumentsResult, error)

func (*Client) ApplyDocumentsForTeam added in v0.6.0

func (c *Client) ApplyDocumentsForTeam(
	ctx context.Context, rawYAML []byte, team string,
) (kukeonv1.ApplyDocumentsResult, error)

ApplyDocumentsForTeam runs the in-process equivalent of the wire RPC per-team prune-apply path (issue #1027). Empty team rejected at the boundary so a caller cannot accidentally degrade into the historical no-prune apply by passing "".

func (*Client) AttachContainer added in v0.2.0

AttachContainer enforces the Attachable gate, the server-side task- liveness gate, and resolves the host-side sbsh control-socket path. Bytes never traverse this RPC — the caller (`kuke attach`) opens HostSocketPath directly and runs the sbsh client loop against it.

Returns the SUN_PATH-safe symlink path (fs.ContainerSocketSymlinkPath) rather than the deep socket inode path so `connect(2)` never sees a sun_path longer than 107 bytes regardless of how deep the resolved metadata layout is (issue #521). The runner stages the symlink at provision time so a re-derived path on a freshly-spawned `kuke attach` is always pre-materialised.

Task-liveness gate (#852): the in-CLI cmd/kuke/shared.GuardCellTaskLiveness catches the common case, but any consumer that bypasses the CLI (raw RPC clients, scripts, in-process callers in alternative branches) would otherwise receive a socket path backed by nothing whenever the target container's task is not Running. Refuse with ErrAttachTaskNotRunning instead, mirroring the client-side guard's predicate at the server boundary so every caller — CLI or not — gets the same typed refusal.

func (*Client) Close

func (c *Client) Close() error

Close releases the underlying controller if this Client owns it.

func (*Client) CreateCell

CreateCell normalizes the external doc, delegates to the controller, and reshapes the result back into external v1beta1 types. Starts the cell's containers after creation; see MaterializeCell for the don't-start variant.

func (*Client) CreateConfig added in v0.6.0

func (*Client) CreateRealm

CreateRealm normalizes the external doc, delegates to the controller, and reshapes the result back into external v1beta1 types.

func (*Client) CreateSecret added in v0.6.0

func (c *Client) CreateSecret(
	_ context.Context, doc v1beta1.SecretDoc,
) (kukeonv1.CreateSecretResult, error)

func (*Client) CreateSpace

CreateSpace normalizes the external doc, delegates to the controller, and reshapes the result back into external v1beta1 types.

func (*Client) CreateStack

CreateStack normalizes the external doc, delegates to the controller, and reshapes the result back into external v1beta1 types.

func (*Client) DeleteBlueprint added in v0.6.0

func (*Client) DeleteCell

func (*Client) DeleteConfig added in v0.6.0

func (*Client) DeleteDocuments added in v0.6.0

func (c *Client) DeleteDocuments(
	_ context.Context,
	rawYAML []byte,
	cascade, force bool,
) (kukeonv1.DeleteDocumentsResult, error)

func (*Client) DeleteImage added in v0.3.0

func (c *Client) DeleteImage(_ context.Context, realm, ref string) (kukeonv1.DeleteImageResult, error)

DeleteImage removes the named image ref from the realm's containerd namespace. errdefs.ErrImageNotFound is propagated unchanged so the wire layer can emit the matching APIError Kind.

func (*Client) DeleteRealm

func (c *Client) DeleteRealm(
	_ context.Context,
	doc v1beta1.RealmDoc,
	force, cascade bool,
) (kukeonv1.DeleteRealmResult, error)

func (*Client) DeleteSecret added in v0.6.0

func (*Client) DeleteSpace

func (c *Client) DeleteSpace(
	_ context.Context,
	doc v1beta1.SpaceDoc,
	force, cascade bool,
) (kukeonv1.DeleteSpaceResult, error)

func (*Client) DeleteStack

func (c *Client) DeleteStack(
	_ context.Context,
	doc v1beta1.StackDoc,
	force, cascade bool,
) (kukeonv1.DeleteStackResult, error)

func (*Client) GetBlueprint added in v0.6.0

func (*Client) GetCell

func (*Client) GetConfig added in v0.6.0

func (*Client) GetContainer

func (*Client) GetImage added in v0.3.0

func (c *Client) GetImage(_ context.Context, realm, ref string) (kukeonv1.GetImageResult, error)

GetImage returns metadata for the named image ref in the realm. errdefs.ErrImageNotFound is propagated unchanged so the wire layer can emit the matching APIError Kind.

func (*Client) GetRealm

func (*Client) GetSecret added in v0.6.0

func (*Client) GetSpace

func (*Client) GetStack

func (*Client) KillCell

func (*Client) ListBlueprints added in v0.6.0

func (c *Client) ListBlueprints(
	_ context.Context,
	realmName, spaceName, stackName string,
) ([]v1beta1.CellBlueprintDoc, error)

func (*Client) ListCells

func (c *Client) ListCells(_ context.Context, realmName, spaceName, stackName string) ([]v1beta1.CellDoc, error)

func (*Client) ListConfigs added in v0.6.0

func (c *Client) ListConfigs(
	_ context.Context,
	realmName, spaceName, stackName string,
) ([]v1beta1.CellConfigDoc, error)

func (*Client) ListContainers

func (c *Client) ListContainers(
	_ context.Context,
	realmName, spaceName, stackName, cellName string,
) ([]v1beta1.ContainerSpec, error)

func (*Client) ListImages added in v0.3.0

func (c *Client) ListImages(_ context.Context, realm string) (kukeonv1.ListImagesResult, error)

ListImages enumerates images in the realm's containerd namespace. The realm is validated by the controller layer; this wrapper only re-encodes the controller's ImageInfo onto the wire type so callers never import the controller package.

func (*Client) ListRealms

func (c *Client) ListRealms(_ context.Context) ([]v1beta1.RealmDoc, error)

func (*Client) ListSecrets added in v0.6.0

func (c *Client) ListSecrets(
	_ context.Context,
	realmName, spaceName, stackName, cellName string,
) ([]v1beta1.SecretDoc, error)

func (*Client) ListSpaces

func (c *Client) ListSpaces(_ context.Context, realmName string) ([]v1beta1.SpaceDoc, error)

func (*Client) ListStacks

func (c *Client) ListStacks(_ context.Context, realmName, spaceName string) ([]v1beta1.StackDoc, error)

func (*Client) LoadImage added in v0.3.0

func (c *Client) LoadImage(_ context.Context, realm string, tarball []byte) (kukeonv1.LoadImageResult, error)

LoadImage imports an OCI/docker image tarball into the realm's containerd namespace. The byte slice is wrapped in a bytes.Reader so the controller can stream it through to containerd's Import API.

func (*Client) LogContainer added in v0.3.0

LogContainer resolves the host-side path of the per-container output stream and returns it via LogContainerResult. The path varies by IO model:

  • Attachable containers are sbsh-wrapped, so stdout/stderr land in the sbsh capture file at HostCapturePath (current behavior).
  • Non-Attachable containers (including kukeond) have the runtime shim write stdout/stderr to HostLogPath via cio.LogFile. The file is shim-owned; kuke just hands the path back so `kuke log` can read it.

Bytes never traverse this RPC — the caller opens the returned path.

func (*Client) MaterializeCell added in v0.6.0

func (c *Client) MaterializeCell(_ context.Context, doc v1beta1.CellDoc) (kukeonv1.CreateCellResult, error)

MaterializeCell normalizes the external doc, delegates to the controller's MaterializeCell (which skips the StartCell step), and reshapes the result back into external v1beta1 types. See kukeonv1.Client.MaterializeCell for the contract.

func (*Client) Ping

func (c *Client) Ping(_ context.Context) error

Ping is a no-op in the in-process client: the controller is alive if this method can run. Implemented so *local.Client satisfies kukeonv1.Client.

func (*Client) PingVersion added in v0.6.0

func (c *Client) PingVersion(_ context.Context) (string, error)

PingVersion returns the empty string for the in-process branch: there is no separate daemon to interrogate, and pulling the running binary's version here would force this package to import cmd/config, reintroducing the autocomplete cycle (cmd/config → internal/client/local). `kuke status` only calls PingVersion on the daemon-RPC client; the in-process branch implements it just to satisfy the interface.

func (*Client) PruneImages added in v0.6.0

func (c *Client) PruneImages(_ context.Context, realm string) (kukeonv1.PruneImagesResult, error)

PruneImages reclaims dangling image layers and the orphaned leases pinning them in the realm's containerd namespace. The realm is validated by the controller layer; this wrapper only re-encodes the controller result onto the wire type.

func (*Client) PurgeCell

func (c *Client) PurgeCell(
	_ context.Context,
	doc v1beta1.CellDoc,
	force, cascade bool,
) (kukeonv1.PurgeCellResult, error)

func (*Client) PurgeRealm

func (c *Client) PurgeRealm(
	_ context.Context,
	doc v1beta1.RealmDoc,
	force, cascade bool,
) (kukeonv1.PurgeRealmResult, error)

func (*Client) PurgeSpace

func (c *Client) PurgeSpace(
	_ context.Context,
	doc v1beta1.SpaceDoc,
	force, cascade bool,
) (kukeonv1.PurgeSpaceResult, error)

func (*Client) PurgeStack

func (c *Client) PurgeStack(
	_ context.Context,
	doc v1beta1.StackDoc,
	force, cascade bool,
) (kukeonv1.PurgeStackResult, error)

func (*Client) ReconcileCells added in v0.4.0

func (c *Client) ReconcileCells() (controller.ReconcileResult, error)

ReconcileCells runs one pass of the daemon-side cell reconciliation loop. Daemon-internal: not surfaced over the kukeonv1 wire — `kuke refresh` is the on-demand, all-resources counterpart that clients use.

func (*Client) RefreshAll

func (c *Client) RefreshAll(_ context.Context) (kukeonv1.RefreshAllResult, error)

func (*Client) StartCell

func (*Client) StopCell

Jump to

Keyboard shortcuts

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