server

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FLAG_DIR_TEMPLATE                   = "%s/.k8shell/flags"
	SystemInfoCollectionIntervalSeconds = 30
)
View Source
const API_VERSION = "v1"

Variables

This section is empty.

Functions

This section is empty.

Types

type RESTService

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

func NewRESTService

func NewRESTService(unixSocketPath string, user *models.User, server *Server) (*RESTService, error)

NewRESTAPI creates a new REST API service

func (*RESTService) AttachShell

func (a *RESTService) AttachShell(w http.ResponseWriter, r *http.Request)

AttachShell hijacks the HTTP connection and bridges it directly to the PTY of the requested shell session (replaying scrollback first).

func (*RESTService) DetachShell

func (a *RESTService) DetachShell(w http.ResponseWriter, r *http.Request)

DetachShell signals the currently attached client of a session to detach. An optional JSON body { "ttl": "30m" } sets a per-session TTL override.

func (*RESTService) GetAppLogs

func (a *RESTService) GetAppLogs(w http.ResponseWriter, r *http.Request)

GetAppLogs returns (and can stream) the latest logs for a given app.

func (*RESTService) GetAppsStatus

func (a *RESTService) GetAppsStatus(w http.ResponseWriter, r *http.Request)

GetAppsStatus returns the status of all configured apps.

func (*RESTService) GetCredsHelper

func (a *RESTService) GetCredsHelper(w http.ResponseWriter, r *http.Request)

func (*RESTService) GetInitScripts

func (a *RESTService) GetInitScripts(w http.ResponseWriter, r *http.Request)

GetInitScripts returns a JSON snapshot of all init script states.

func (*RESTService) GetLogs

func (a *RESTService) GetLogs(w http.ResponseWriter, r *http.Request)

GetLogs serves k8shelld daemon logs (the same logs shown by `kbox logs`).

Query parameters:

  • component, level: optional filters
  • follow=true: keep the connection open and stream new entries as they arrive, seeded with the last 'limit' entries (or everything currently buffered if 'limit' is unset)
  • before=<id>: cursor-based pagination — returns up to 'limit' entries older than the given entry id, oldest-first, for "load more" style paging that stays correct even as the in-memory buffer evicts old entries underneath it. Omit (or 0) for the most recent page. The response carries an 'X-Log-Has-More' header (true/false) indicating whether an older page exists; the next 'before' cursor is simply the 'id' of the oldest entry in the response body.
  • limit (alias: lastN, kept for backward compatibility): page size for 'before' pagination, or entry count for the initial/follow backlog. Omitted with no 'before' returns everything currently buffered.

func (*RESTService) GetProfile added in v0.16.0

func (a *RESTService) GetProfile(w http.ResponseWriter, r *http.Request)

GetProfile returns the workspace user's profile. When the API server is configured, the profile is re-fetched live and the in-memory copy is refreshed (see models.User.UpdateProfile) so it stays current for subsequent requests; on fetch failure it falls back to the last known copy. Without an API server, it returns the profile loaded at startup from /etc/k8shell/profile.yaml.

func (*RESTService) GetSessions

func (a *RESTService) GetSessions(w http.ResponseWriter, r *http.Request)

func (*RESTService) GetSplash

func (a *RESTService) GetSplash(w http.ResponseWriter, r *http.Request)

func (*RESTService) GetStreams

func (a *RESTService) GetStreams(w http.ResponseWriter, r *http.Request)

func (*RESTService) GetSystemInfo

func (a *RESTService) GetSystemInfo(w http.ResponseWriter, r *http.Request)

func (*RESTService) InstallApp

func (a *RESTService) InstallApp(w http.ResponseWriter, r *http.Request)

InstallApp installs the specified app (asynchronously).

func (*RESTService) ListDetachedShells

func (a *RESTService) ListDetachedShells(w http.ResponseWriter, r *http.Request)

ListDetachedShells returns a JSON list of PTY shell sessions with no attached client.

func (*RESTService) ResizeShell

func (a *RESTService) ResizeShell(w http.ResponseWriter, r *http.Request)

ResizeShell resizes the PTY of a shell session (works whether attached or detached).

func (*RESTService) Serve

func (a *RESTService) Serve(ctx context.Context)

func (*RESTService) SetPassword added in v0.16.0

func (a *RESTService) SetPassword(w http.ResponseWriter, r *http.Request)

SetPassword sets the workspace user's password via the API server. CurrentPassword is required by the API server when the caller is a non-sudo change of the user's own password, and ignored otherwise.

func (*RESTService) Shutdown

func (a *RESTService) Shutdown(w http.ResponseWriter, r *http.Request)

func (*RESTService) StartApp

func (a *RESTService) StartApp(w http.ResponseWriter, r *http.Request)

StartApp starts supervising and running the specified app.

func (*RESTService) StopApp

func (a *RESTService) StopApp(w http.ResponseWriter, r *http.Request)

StopApp stops supervising and (if running) stops the specified app.

func (*RESTService) ValidateK8shelldFile

func (a *RESTService) ValidateK8shelldFile(w http.ResponseWriter, r *http.Request)

type Server

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

func NewServer

func NewServer(cfg *config.Config, restApiUnixSocketPath string, testMode bool) (*Server, error)

func (*Server) Serve

func (s *Server) Serve()

Jump to

Keyboard shortcuts

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