structs

package
v0.0.0-...-4f4f4d1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIfError

func CheckIfError(err error)

func HandleError

func HandleError(w http.ResponseWriter, err error)

func Info

func Info(format string, args ...interface{})

func RespondFilter

func RespondFilter(r *http.Request, w http.ResponseWriter, status int, list *unstructured.UnstructuredList) error

func RespondFormat

func RespondFormat[T any](r *http.Request, w http.ResponseWriter, status int, payload T) error

func RespondGraph

func RespondGraph(r *http.Request, w http.ResponseWriter, status int, list *unstructured.UnstructuredList, url *RequestUrl) error

func RespondJSON

func RespondJSON[T any](w http.ResponseWriter, status int, payload T) error

func RespondOK

func RespondOK(w http.ResponseWriter, response string) error

func RespondText

func RespondText(w http.ResponseWriter, status int, payload string) error

func RespondYAML

func RespondYAML[T any](w http.ResponseWriter, status int, payload T) error

func Warning

func Warning(format string, args ...interface{})

Types

type ApiClient

type ApiClient struct {
	*App
	H func(a *App, c *Client, w http.ResponseWriter, r *http.Request) error
}

func (ApiClient) ServeHTTP

func (ac ApiClient) ServeHTTP(w http.ResponseWriter, r *http.Request)

type App

type App struct {
	Addr           *string
	Router         *http.ServeMux
	KubeConfigPath *string
	ApiServerHost  *string
	ProxyUrl       *string
	InCluster      *bool
	FileServer     *bool
	FileServerPath *string
	Client         *Client
	AuthManager    AuthManager
	// config
	PodLogTailLines      *int64
	DefaultConfigName    *string
	TokenExpirationHours *int64
}

func (*App) LoadConfig

func (app *App) LoadConfig()

Use configmap

func (*App) LoadKubeContext

func (app *App) LoadKubeContext(context string) error

func (*App) NewApiClient

func (app *App) NewApiClient(token string) (*Client, error)

func (*App) NewKubeClient

func (app *App) NewKubeClient(token string) (*Client, error)

type AuthManager

type AuthManager interface {
	Authorize(r *http.Request) (bool, string, error)
	Secret() string
}

func NewAuthManager

func NewAuthManager(k8s *kubernetes.Clientset) AuthManager

type Authorization

type Authorization struct {
	*App
	H func(a *App, w http.ResponseWriter, r *http.Request) error
}

func (Authorization) ServeHTTP

func (auth Authorization) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Client

type Client struct {
	Clientset *kubernetes.Clientset
	ApiClient *clientset.Clientset
	Config    *rest.Config
	Dynamic   *dynamic.DynamicClient
	Discovery *discovery.DiscoveryClient
}

func (*Client) ExecCommand

func (c *Client) ExecCommand(url RequestUrl, container string, cmd []string) (*bytes.Buffer, error)

func (*Client) GetAPIResource

func (c *Client) GetAPIResource(obj *unstructured.Unstructured) (*metav1.APIResource, error)

func (*Client) GetContainer

func (c *Client) GetContainer(url RequestUrl) (string, error)

type Edge

type Edge struct {
	Id     string `json:"id,omitempty"`
	Source string `json:"source,omitempty"`
	Target string `json:"target,omitempty"`
}

type Error

type Error interface {
	error
	Status() int
}

type Graph

type Graph struct {
	Nodes []Node `json:"nodes"`
	Edges []Edge `json:"edges"`
}

func (*Graph) AddEdge

func (g *Graph) AddEdge(source Node, target Node)

func (*Graph) AddNode

func (g *Graph) AddNode(kind string, id string, name string, args NodeOptions) Node

func (*Graph) Includes

func (g *Graph) Includes(name string) bool

type JwtCustomClaims

type JwtCustomClaims struct {
	Username string `json:"username"`
	Token    string `json:"token"`
	jwt.RegisteredClaims
}

type KubeClient

type KubeClient struct {
	*App
	H func(a *App, c *Client, w http.ResponseWriter, r *http.Request) error
}

func (KubeClient) ServeHTTP

func (kc KubeClient) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Node

type Node struct {
	Id   string `json:"id,omitempty"`
	Data struct {
		Label      string   `json:"label,omitempty"`
		Group      bool     `json:"group,omitempty"`
		Kind       string   `json:"kind,omitempty"`
		Namespace  string   `json:"namespace,omitempty"`
		Containers []string `json:"containers,omitempty"`
		Status     string   `json:"status,omitempty"`
		Age        string   `json:"age,omitempty"`
		Ready      string   `json:"ready,omitempty"`
		Restarts   string   `json:"restarts,omitempty"`
	} `json:"data,omitempty"`
	// optional
	Position string `json:"position,omitempty"`
	Style    struct {
		Width  int `json:"width,omitempty"`
		Height int `json:"height,omitempty"`
	} `json:"style,omitempty"`
	Type        string `json:"type,omitempty"`
	ParentNode  string `json:"parentNode,omitempty"`
	Extent      string `json:"extent,omitempty"`
	Draggable   bool   `json:"draggable"`
	Connectable bool   `json:"connectable"`
}

type NodeOptions

type NodeOptions struct {
	Type        string
	Draggable   bool
	Connectable bool
	ParentNode  Node
	Extent      string
	Namespace   string
	Group       bool
	Containers  []string
	Status      string
	Age         string
	Ready       string
	Restarts    string
}

type ObjectList

type ObjectList struct {
	UID               types.UID   `json:"uid"`
	Name              string      `json:"name"`
	Namespace         string      `json:"namespace"`
	Group             string      `json:"group"`
	Version           string      `json:"version"`
	CreationTimestamp metav1.Time `json:"creationTimestamp"`
}

type Public

type Public struct {
	*App
	H func(e *App, w http.ResponseWriter, r *http.Request) error
}

func (Public) ServeHTTP

func (p Public) ServeHTTP(w http.ResponseWriter, r *http.Request)

type RequestUrl

type RequestUrl struct {
	Scope       string
	Resource    string
	Subresource string
	Path        string
}

func GetRequestParams

func GetRequestParams(r *http.Request, path string) RequestUrl

type StatusError

type StatusError struct {
	Code int
	Err  error
	Msg  string
}

func RespondError

func RespondError(args ...interface{}) StatusError

func (StatusError) Error

func (se StatusError) Error() string

func (StatusError) Message

func (se StatusError) Message() string

func (StatusError) Status

func (se StatusError) Status() int

Jump to

Keyboard shortcuts

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