server

package
v0.0.0-...-53bbe6e Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// kubecfg as a library does not show the tagged build version, instead it
	// shows as "(dev build)". For now, this can be updated manually on occasional
	// bumps.
	KubecfgVersion  = "v0.34.3"
	VersionResponse = []byte(fmt.Sprintf("jsonnet: %s kubecfg: %s", jsonnet.Version(), KubecfgVersion))
)

Functions

func DisableFileImports

func DisableFileImports(srv *PlaygroundServer, next http.Handler) http.HandlerFunc

Middleware to stop Jsonnet snippets which contain file:///, typically paired with an import, being used and becoming shareable. These are rejected before running through the Jsonnet VM and a generic error is displayed.

func HandleAssets

func HandleAssets(pattern string, fsHandler http.Handler) http.Handler

HandleAssets wires up the static asset handling for the server.

Types

type PlaygroundServer

type PlaygroundServer struct {
	Server http.Server
	State  *state.State
}

The playground server

func New

func New(state *state.State) *PlaygroundServer

func (*PlaygroundServer) HandleCreateShare

func (srv *PlaygroundServer) HandleCreateShare() http.HandlerFunc

HandleCreateShare is used to create shared snippets. This is handled through creating a hash of the input and adding it to the state store - this storage mechanism is ephemeral.

At a later date, this will include a persistence layer.

func (*PlaygroundServer) HandleFormat

func (srv *PlaygroundServer) HandleFormat() http.HandlerFunc

Format the input Jsonnet according to the standard jsonnetfmt rules.

func (*PlaygroundServer) HandleGetShare

func (srv *PlaygroundServer) HandleGetShare() http.HandlerFunc

HandleGetShare attempts to retrieve a shared snippet hash from the internal store. If this does not exist, an error is displayed.

func (*PlaygroundServer) HandleRun

func (srv *PlaygroundServer) HandleRun() http.HandlerFunc

HandleRun receives Jsonnet input via text and evaluates it.

func (*PlaygroundServer) HandleShare

func (srv *PlaygroundServer) HandleShare() http.HandlerFunc

HandleShare is the rendering of the shared snippet view.

func (*PlaygroundServer) HandleVersions

func (srv *PlaygroundServer) HandleVersions() http.HandlerFunc

Retrieve the current version of Jsonnet/Kubecfg in use for the running application. This is purely informational for the frontend.

func (*PlaygroundServer) Health

func (srv *PlaygroundServer) Health() http.HandlerFunc

Health indicates whether the server is running.

func (*PlaygroundServer) Routes

func (srv *PlaygroundServer) Routes() error

Load the available routes for the server

func (*PlaygroundServer) Serve

func (srv *PlaygroundServer) Serve() error

Serve will listen on the provided address, running the server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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