util

package
v1.0.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperationSuccess      = "Success"
	OperationFailed       = "Failed"
	KBAgentEventFieldPath = "spec.containers{kb-agent}"
)
View Source
const (
	JSONContentTypeHeader = "application/json"
	Version               = "v1.0"
	Path                  = "/action"
)

for http server

Variables

View Source
var EventSendMaxAttempts = 30
View Source
var EventSendPeriod = 10 * time.Second

Functions

func CreateEvent

func CreateEvent(reason string, msg ActionMessage) (*corev1.Event, error)

func ExecCommand

func ExecCommand(ctx context.Context, command []string, envs []string) (string, error)

func GetAllEnvs

func GetAllEnvs(args map[string]any) []string

func GetClientSet

func GetClientSet() (*kubernetes.Clientset, error)

GetClientSet returns a kubernetes clientSet.

func SendEvent

func SendEvent(ctx context.Context, event *corev1.Event) error

func SentEventForProbe

func SentEventForProbe(ctx context.Context, msg ActionMessage) error

Types

type ActionMessage

type ActionMessage interface {
	GetAction() string
}

type CronJob

type CronJob struct {
	PeriodSeconds    int `json:"periodSeconds,omitempty"`
	SuccessThreshold int `json:"successThreshold,omitempty"`
	FailureThreshold int `json:"failureThreshold,omitempty"`
	ReportFrequency  int `json:"reportFrequency,omitempty"`
}

type Executor

type Executor interface {
	ExecCommand(ctx context.Context, command []string, envs []string) (string, error)
}

type ExecutorImpl

type ExecutorImpl struct{}

func (*ExecutorImpl) ExecCommand

func (e *ExecutorImpl) ExecCommand(ctx context.Context, command []string, envs []string) (string, error)

type HandlerSpec

type HandlerSpec struct {
	TimeoutSeconds int               `json:"timeoutSeconds,omitempty"`
	Command        []string          `json:"command,omitempty"`
	GPRC           map[string]string `json:"grpc,omitempty"`
	CronJob        *CronJob          `json:"cronJob,omitempty"`
}

type MessageBase

type MessageBase struct {
	Event   string `json:"event,omitempty"`
	Message string `json:"message,omitempty"`
	Action  string `json:"action,omitempty"`
}

func (MessageBase) GetAction

func (m MessageBase) GetAction() string

type RoleProbeMessage

type RoleProbeMessage struct {
	MessageBase
	Role string `json:"role,omitempty"`
}

Jump to

Keyboard shortcuts

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