model

package
v1.6.8 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Unknown info
	Unknown = "UNKNOWN"
	// VelaSystemNS is the namespace of vela-system, which is the namespace of vela-core and vela-cluster-gateway
	VelaSystemNS = "vela-system"
	// VelaCoreAppName is the app name of vela-core
	VelaCoreAppName = "app.kubernetes.io/name=vela-core"
	// ClusterGatewayAppName is the app name of vela-core
	ClusterGatewayAppName = "app.kubernetes.io/name=vela-core-cluster-gateway"
)
View Source
const (
	// AllNamespace represent all namespaces
	AllNamespace = "all"
	// AllClusterNamespace represent all cluster namespace
	AllClusterNamespace = "all"
	// AllCluster represent all cluster
	AllCluster = "all"
)
View Source
const (

	// StackPop is the "pop" notify type
	StackPop
)

Variables

View Source
var (
	// CtxKeyAppName request context key of application name
	CtxKeyAppName = "appName"
	// CtxKeyNamespace request context key of namespace name
	CtxKeyNamespace = "appNs"
	// CtxKeyCluster request context key of cluster name
	CtxKeyCluster = "cluster"
	// CtxKeyClusterNamespace request context key of cluster namespace name
	CtxKeyClusterNamespace = "cluster"
	// CtxKeyComponentName request context key of component name
	CtxKeyComponentName = "componentName"
	// CtxKeyGVR request context key of GVR
	CtxKeyGVR = "gvr"
	// CtxKeyPod request context key of pod
	CtxKeyPod = "pod"
	// CtxKeyContainer request context key of container
	CtxKeyContainer = "container"
)

Functions

func ApplicationResourceTopology

func ApplicationResourceTopology(c client.Client, name, ns string) ([]*types.AppliedResource, error)

ApplicationResourceTopology return the applied resource of the app in tree form

func ApplicationRunningNum

func ApplicationRunningNum(cfg *rest.Config) string

ApplicationRunningNum return the num of running application

func CLusterGatewayRatio

func CLusterGatewayRatio(cfg *rest.Config) (string, string, string, string)

CLusterGatewayRatio return the usage condition of vela-core cluster gateway pod

func GOLangVersion

func GOLangVersion() string

GOLangVersion return golang version info

func GetResourceObject

func GetResourceObject(c client.Client, gvr *GVR) (runtime.Object, error)

GetResourceObject get the resource object refer to the GVR data

func K8SVersion

func K8SVersion(cfg *rest.Config) string

K8SVersion return k8s version info

func LoadApplication

func LoadApplication(c client.Client, name, ns string) (*v1beta1.Application, error)

LoadApplication load the corresponding application according to name and namespace

func LoadNamespaceDetail

func LoadNamespaceDetail(ctx context.Context, c client.Client, namespace string) (*v1.Namespace, error)

LoadNamespaceDetail query detail info of a namespace by name

func PrintLogOfPod

func PrintLogOfPod(ctx context.Context, config *rest.Config, cluster, namespace, podName, containerName string) (chan string, error)

PrintLogOfPod print the log during 48h of aimed pod

func ToYaml

func ToYaml(o runtime.Object) (string, error)

ToYaml load the yaml text of object

func VelaCLIVersion

func VelaCLIVersion() string

VelaCLIVersion return vela cli version info

func VelaCoreRatio

func VelaCoreRatio(cfg *rest.Config) (string, string, string, string)

VelaCoreRatio return the usage condition of vela-core pod

func VelaCoreVersion

func VelaCoreVersion() string

VelaCoreVersion return vela core version info

Types

type Application

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

Application is the application resource object

type ApplicationList

type ApplicationList []Application

ApplicationList is application resource list

func ListApplications

func ListApplications(ctx context.Context, c client.Client) (ApplicationList, error)

ListApplications list all apps in all namespaces

func (ApplicationList) ToTableBody

func (l ApplicationList) ToTableBody() [][]string

ToTableBody generate body of table in application view

type Cluster

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

Cluster is cluster resource struct

type ClusterList

type ClusterList []Cluster

ClusterList is cluster resource list

func ListClusters

func ListClusters(ctx context.Context, c client.Client) (ClusterList, error)

ListClusters list clusters where application deploys resource

func (ClusterList) ToTableBody

func (l ClusterList) ToTableBody() [][]string

ToTableBody generate body of table in cluster view

type Container

type Container struct {
	CPU  string
	Mem  string
	CPUR string
	CPUL string
	MemR string
	MemL string
	// contains filtered or unexported fields
}

Container represent the container resource instance

type ContainerList

type ContainerList []Container

ContainerList is container list

func ListContainerOfPod

func ListContainerOfPod(ctx context.Context, client client.Client, cfg *rest.Config) (ContainerList, error)

ListContainerOfPod get the container data of aimed pod

func (ContainerList) ToTableBody

func (l ContainerList) ToTableBody() [][]string

ToTableBody generate body of table in pod view

type GVR

type GVR struct {
	GV string
	R  Resource
}

GVR is Group, Version, Resource

type Hinter

type Hinter interface {
	// Hint return key action menu hints of the component
	Hint() []MenuHint
}

Hinter is an abstract of components which can provide menu hints to menu component

type Info

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

Info is system info struct

func NewInfo

func NewInfo() *Info

NewInfo return a new info struct

func (*Info) ClusterNum

func (i *Info) ClusterNum() string

ClusterNum return cluster number

func (*Info) CurrentContext

func (i *Info) CurrentContext() string

CurrentContext return current context info

type Initer

type Initer interface {
	// Start the component
	Start()
	// Stop the component
	Stop()
	// Init the component
	Init()
}

Initer is an abstract of components whose need to init

type KeyAction

type KeyAction struct {
	Description string
	Action      func(*tcell.EventKey) *tcell.EventKey
	Visible     bool
	Shared      bool
}

KeyAction is key action struct

type KeyActions

type KeyActions map[tcell.Key]KeyAction

KeyActions is a map from key to action

func (KeyActions) Add

func (ka KeyActions) Add(actions KeyActions)

Add a key action to key action map

func (KeyActions) Clear

func (ka KeyActions) Clear()

Clear key action map clear up

func (KeyActions) Delete

func (ka KeyActions) Delete(kk []tcell.Key)

Delete aim key from key action map

func (KeyActions) Hint

func (ka KeyActions) Hint() []MenuHint

Hint convert key action map to menu hints

func (KeyActions) Set

func (ka KeyActions) Set(actions KeyActions)

Set a key action to key action map

type ManagedResource

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

ManagedResource is managed resource of application

func LoadResourceDetail

func LoadResourceDetail(resource query.Resource) ManagedResource

LoadResourceDetail return the aim resource detail info

type ManagedResourceList

type ManagedResourceList []ManagedResource

ManagedResourceList is managed resource list

func ListManagedResource

func ListManagedResource(ctx context.Context, c client.Client) (ManagedResourceList, error)

ListManagedResource return managed resources of application

func (*ManagedResourceList) FilterCluster

func (l *ManagedResourceList) FilterCluster(clusterName string)

FilterCluster filter out objects that belong to the target cluster

func (*ManagedResourceList) FilterClusterNamespace

func (l *ManagedResourceList) FilterClusterNamespace(clusterNS string)

FilterClusterNamespace filter out objects that belong to the target namespace

func (*ManagedResourceList) ToTableBody

func (l *ManagedResourceList) ToTableBody() [][]string

ToTableBody generate header of table in managed resource view

type MenuHint struct {
	Key         string
	Description string
}

MenuHint key action hints display by menu component

type Namespace

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

Namespace is namespace struct

type NamespaceList

type NamespaceList []Namespace

NamespaceList is namespace list

func ListClusterNamespaces

func ListClusterNamespaces(ctx context.Context, c client.Client) (NamespaceList, error)

ListClusterNamespaces return namespace of application's resource

func ListNamespaces

func ListNamespaces(ctx context.Context, c client.Client) (NamespaceList, error)

ListNamespaces return all namespaces

func (NamespaceList) ToTableBody

func (l NamespaceList) ToTableBody() [][]string

ToTableBody generate body of table in namespace view

type Pod

type Pod struct {
	Name      string
	Namespace string
	Cluster   string
	Ready     string
	Status    string
	CPU       string
	Mem       string
	CPUR      string
	CPUL      string
	MemR      string
	MemL      string
	IP        string
	NodeName  string
	Age       string
}

Pod represent the k8s pod resource instance

func LoadPodDetail

func LoadPodDetail(cfg *rest.Config, pod *v1.Pod) Pod

LoadPodDetail gather the pod detail info

type PodList

type PodList []Pod

PodList is pod list

func ListPods

func ListPods(ctx context.Context, cfg *rest.Config, c client.Client) (PodList, error)

ListPods return pod list of component

func (PodList) ToTableBody

func (l PodList) ToTableBody() [][]string

ToTableBody generate body of table in pod view

type Primitive

type Primitive interface {
	tview.Primitive
	// Name return name of the component
	Name() string
}

Primitive is an abstract of tview ui component

type Resource

type Resource struct {
	Kind      string
	Name      string
	Namespace string
	Cluster   string
}

Resource info used by GVR

type ResourceList

type ResourceList interface {
	// Header generate header of table in resource view
	Header() []string
	// Body generate body of table in resource view
	Body() [][]string
}

ResourceList an abstract kinds of resource list which can convert it to data of view in the form of table

type Stack

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

Stack is a stack to store components and notify listeners of main view of app

func NewStack

func NewStack() *Stack

NewStack return a new stack instance

func (*Stack) AddListener

func (s *Stack) AddListener(listener ViewListener)

AddListener add a new resource listener

func (*Stack) Clear

func (s *Stack) Clear()

Clear out the stack

func (*Stack) Empty

func (s *Stack) Empty() bool

Empty return whether stack is empty

func (*Stack) IsLastView

func (s *Stack) IsLastView() bool

IsLastView check whether stack only have one view now

func (*Stack) PopView

func (s *Stack) PopView()

PopView pop a view from stack

func (*Stack) PushView

func (s *Stack) PushView(component View)

PushView add a new view to stack

func (*Stack) RemoveListener

func (s *Stack) RemoveListener(listener ViewListener)

RemoveListener remove the aim resource listener

func (*Stack) TopView

func (s *Stack) TopView() View

TopView return top view of stack

type View

type View interface {
	Primitive
	Initer
	Hinter
}

View is an abstract of view of app

type ViewListener

type ViewListener interface {
	// StackPop pop old component and render component
	StackPop(old, new View)
	// StackPush push a new component
	StackPush(old, new View)
}

ViewListener listen notify from the main view of app and render itself again

Jump to

Keyboard shortcuts

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