server

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 58 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package server is the flightbay-desk HTTP server: the JSON API behind the web UI, the embedded UI itself, the fake kube-apiserver mounted at /k8s/ and a real terminal over a websocket.

Index

Constants

View Source
const CookieName = "flightbay_token"

CookieName prefixes the cookie that holds the per-process session token in the browser. Browsers scope cookies by host, not port, so the listening port is appended: two desks open on 127.0.0.1 at once keep separate sessions.

Variables

This section is empty.

Functions

func IsGitURL

func IsGitURL(s string) bool

IsGitURL reports whether a Repo source should be cloned.

func KeysDir

func KeysDir() string

KeysDir is where keys created in the UI are kept: ~/.flightbay/keys.

func KubeContexts

func KubeContexts(kubeconfig string) (ctxs []kubeContext, current string, files []string, err error)

KubeContexts lists the contexts in a kubeconfig ("" = $KUBECONFIG or ~/.kube/config), the files read and the current context.

Types

type LiveAccess

type LiveAccess struct {
	ClusterScoped    bool   `json:"clusterScoped"`
	ClusterScopedWhy string `json:"clusterScopedWhy,omitempty"`
	Diagnostics      bool   `json:"diagnostics"`
	DiagnosticsWhy   string `json:"diagnosticsWhy,omitempty"`
}

LiveAccess is what the context's credentials allow of the live options. A reason is set when the option is not allowed.

type LiveRequest

type LiveRequest struct {
	Kubeconfig        string `json:"kubeconfig,omitempty"`
	Context           string `json:"context"`
	Namespaces        string `json:"namespaces,omitempty"`        // comma separated, globs allowed; empty = all
	ExcludeNamespaces string `json:"excludeNamespaces,omitempty"` // comma separated, globs allowed
	ClusterScoped     bool   `json:"clusterScoped,omitempty"`     // --cluster-scoped
	Diagnostics       bool   `json:"diagnostics,omitempty"`       // --diagnostics
}

LiveRequest is the Live card's form.

type Rel

type Rel struct {
	Relation  string `json:"relation"`
	Cluster   string `json:"cluster"`
	Group     string `json:"group"`
	Resource  string `json:"resource"`
	Kind      string `json:"kind"`
	Namespace string `json:"namespace"`
	Name      string `json:"name"`
}

Rel is a relationship shown in the object inspector.

type ReviewSession

type ReviewSession struct {
	Source  string         // the original bundle file
	Out     string         // where the export goes
	Options review.Options // identities, signer, recipients, trusted keys, tool
	Plan    review.Plan    // starting plan (reviewer name)
	Landing bool           // open the UI on the Review and send page (--review)
	// SignerPath is the key file exports are signed with, when known.
	SignerPath string
	// Frozen is set for a live mirror: when it was frozen into Source.
	Frozen time.Time
	// contains filtered or unexported fields
}

ReviewSession is review mode (flightbay review): the customer decides what to share and exports a trimmed, signed bundle.

type ScanRequest

type ScanRequest struct {
	Source    string   `json:"source"` // a local directory or a Git URL
	Values    []string `json:"values,omitempty"`
	Set       []string `json:"set,omitempty"`
	Overlay   string   `json:"overlay,omitempty"`
	Env       string   `json:"env,omitempty"`
	Namespace string   `json:"namespace,omitempty"`
	Release   string   `json:"release,omitempty"`
}

ScanRequest is the Repo card's form.

type Server

type Server struct {
	WS         *store.Workspace
	Token      string
	WorkDir    string
	BaseURL    string // e.g. http://127.0.0.1:8484, used in the kubeconfig
	Terminal   bool
	Shell      string
	DeskBinary string       // path to flightbay-desk, used by the fbq/fbfind helpers
	Reload     func() error // re-reads the bundle to load deferred categories; nil if unsupported
	// KubeURL and KubeCA point kubeconfigs at the TLS listener serving the
	// snapshot API. kubectl only sends kubeconfig tokens over TLS.
	KubeURL string
	KubeCA  []byte
	// LoadBaseline starts loading an earlier bundle for the Compare view in
	// the background and calls SetBaseline (or BaselineFailed) when done. It
	// returns an error only if loading cannot start. nil disables loading
	// baselines from the UI.
	LoadBaseline func(path string) error
	// BundlePath is the bundle file the workspace was opened from ("" for a
	// stream). Its directory is searched for baseline candidates.
	BundlePath string
	// BaselineDirs are extra directories to search for baseline candidates.
	BaselineDirs []string
	// Identities decrypt bundle headers when listing baseline candidates.
	Identities []age.Identity
	// Review is set in review mode (flightbay review).
	Review *ReviewSession
	// RefreshDiagnostics re-runs diagnostics for one pod of a live
	// workspace and returns how many files were captured; nil when the
	// workspace is not live or diagnostics were not allowed.
	RefreshDiagnostics func(ctx context.Context, namespace, pod string) (int, error)
	// SaveBundle writes the live mirror as a bundle and returns its path;
	// nil when the workspace is not live.
	SaveBundle func() (string, error)
	// FreezeBundle writes the live mirror as a bundle into dir and returns
	// its path; Review and send exports from that frozen copy. nil when the
	// workspace is not live.
	FreezeBundle func(dir string) (string, error)
	// ExportDir is where reviewed bundles of a live mirror are written.
	ExportDir string
	// Signer signs reviewed exports of a live mirror (--sign); the Review
	// and send page can choose or create another.
	Signer *sign.PrivateKey
	// contains filtered or unexported fields
}

Server serves one workspace.

func (*Server) BaselineFailed

func (s *Server) BaselineFailed(path string, err error)

BaselineFailed records that loading path as the baseline failed.

func (*Server) BaselineLoading

func (s *Server) BaselineLoading(path string)

BaselineLoading records that path is being loaded as the baseline.

func (*Server) Close

func (s *Server) Close()

Close stops the terminal session.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the root handler.

func (*Server) KubeHandler

func (s *Server) KubeHandler() http.Handler

KubeHandler serves the snapshot API at the root, for the TLS listener.

func (*Server) KubeconfigPath

func (s *Server) KubeconfigPath() string

KubeconfigPath is where Prepare writes the kubeconfig.

func (*Server) Prepare

func (s *Server) Prepare() error

Prepare writes the kubeconfig and the shell helpers into the work directory.

func (*Server) RCFile

func (s *Server) RCFile() string

RCFile is the rc file Prepare writes for workspace shells.

func (*Server) SetBaseline

func (s *Server) SetBaseline(ws *store.Workspace, path string)

SetBaseline attaches an earlier bundle to compare the workspace against. A result for a path that is no longer the one being loaded is dropped, so picking a second bundle while the first loads keeps the second.

func (*Server) ShellEnv

func (s *Server) ShellEnv() []string

ShellEnv is the environment for shells that talk to this workspace.

type StartAction

type StartAction struct {
	Kind     string       `json:"kind"`               // "open", "review" or "live"
	Path     string       `json:"path,omitempty"`     // the bundle, for open and review
	Identity string       `json:"identity,omitempty"` // an age identity file for an encrypted bundle
	Live     *LiveRequest `json:"live,omitempty"`
	// Scanned is set when Path is a bundle the start page just scanned.
	Scanned bool `json:"scanned,omitempty"`
}

StartAction is what the start page hands over to.

type StartServer

type StartServer struct {
	Token   string
	WorkDir string // uploads, clones and scanned bundles go here; the next desk uses it as its workspace
	// Dirs are searched for recent bundles (default: the working directory
	// and ~/Downloads). WorkDir/uploads is always searched.
	Dirs []string
	// Identities open encrypted bundles given with -i when the start page
	// was launched.
	Identities []age.Identity
	// MaxUpload caps an uploaded bundle, in bytes (default 8 GiB).
	MaxUpload int64
	// Version goes into the header of scanned bundles.
	Version string
	// LivePlan returns the dry-run plan and RBAC for a live request,
	// as flightbay-desk live --dry-run --json prints it.
	LivePlan func(ctx context.Context, req LiveRequest) (json.RawMessage, error)
	// LiveAccess asks the cluster whether the context's credentials can read
	// cluster-scoped objects and port-forward, so the start page can turn
	// those options on by default and off, with the reason, when they cannot.
	LiveAccess func(ctx context.Context, req LiveRequest) (LiveAccess, error)
	// Launch hands over to the desk for an action. It is called after the
	// response has been sent and does not return on success.
	Launch func(a StartAction) error
	// contains filtered or unexported fields
}

StartServer serves the start page: what flightbay ui shows when it is given nothing to open. There is no workspace yet, so none of the workspace APIs exist here. When the user picks something, Launch replaces this process with the desk for it, on the same address and with the same token.

func (*StartServer) Handler

func (s *StartServer) Handler() http.Handler

Handler serves the start page, its static files, /docs and /api/start/.

type TimelineItem

type TimelineItem struct {
	Time      time.Time `json:"time"`
	Cluster   string    `json:"cluster"`
	Namespace string    `json:"namespace,omitempty"`
	Kind      string    `json:"kind"` // event, termination, rollout, error-spike
	Severity  string    `json:"severity"`
	Title     string    `json:"title"`
	Detail    string    `json:"detail,omitempty"`
	Object    *Rel      `json:"object,omitempty"`
	LogQuery  string    `json:"logQuery,omitempty"`
	From      time.Time `json:"from,omitempty"`
	To        time.Time `json:"to,omitempty"`
}

TimelineItem is one entry on the incident timeline.

Jump to

Keyboard shortcuts

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