util

package
v3.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2018 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrMsgTemplate = "\033[31m>>> %s\033[0m"
)

Variables

View Source
var (
	ErrAuthFailed        = errors.New("authorize failed")
	ErrAuthNotSupported  = errors.New("entry only works on lain-sso authorization")
	ErrContainerNotfound = errors.New("get data successfully but not found the container")
)

Functions

func AuthAPI

func AuthAPI(accessToken string, g *global.Global) (*sso.User, error)

AuthAPI authorizes whether the client with this token has right to access the API

func AuthContainer

func AuthContainer(token, appName string, g *global.Global) (*sso.User, error)

AuthContainer authorizes whether the client with the token has the right to access the application's container

func GetMarshalers

func GetMarshalers(r *http.Request) (Marshaler, Unmarshaler)

func GetSourceIP

func GetSourceIP(r *http.Request) string

func GetValidUT8Length

func GetValidUT8Length(data []byte) int

func GetWidthAndHeight

func GetWidthAndHeight(data []byte) (int, int)

func SendCloseMessage

func SendCloseMessage(conn *websocket.Conn, content []byte, msgMarshaller Marshaler, writeLock *sync.Mutex)

func SendMail

func SendMail(msg []byte, g *global.Global) error

SendMail send mail

func TermComplement

func TermComplement(src []byte) []byte

TermComplement handle the response of tab completion

func TermEscape

func TermEscape(src []byte) []rune

TermEscape handle special characters such as SOH, ENQ and DEL in ASCII

Types

type AppInfo

type AppInfo struct {
	PodInfos []PodInfo `json:"PodInfos"`
}

type ConsoleAuthConf

type ConsoleAuthConf struct {
	Type string `json:"type"`
	URL  string `json:"url"`
}

type ConsoleAuthResponse

type ConsoleAuthResponse struct {
	Message string      `json:"msg"`
	URL     string      `json:"url"`
	Role    ConsoleRole `json:"role"`
}

type ConsoleRole

type ConsoleRole struct {
	Role string `json:"role"`
}

type Container

type Container struct {
	ContainerID string `json:"ContainerId"`
	NodeIP      string `json:"NodeIp"`
}

func GetContainer

func GetContainer(appName, procName, instanceNo string, g *global.Global) (*Container, error)

GetContainer get container according to appName, procName and instanceNo

type CoreInfo

type CoreInfo map[string]AppInfo

type Marshaler

type Marshaler func(interface{}) ([]byte, error)

type PodInfo

type PodInfo struct {
	InstanceNo int         `json:"InstanceNo"`
	Containers []Container `json:"ContainerInfos"`
}

type Unmarshaler

type Unmarshaler func([]byte, interface{}) error

type ViaMethod

type ViaMethod int

Jump to

Keyboard shortcuts

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