execute

package
v0.13.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// WrongClusterCmdMsg incomplete command response message
	WrongClusterCmdMsg = "Sorry, the admin hasn't configured me to do that for the cluster '%s'."
)

Variables

View Source
var (

	// ErrNotificationsNotConfigured describes an error when user wants to toggle on/off the notifications for not configured channel.
	ErrNotificationsNotConfigured = errors.New("notifications not configured for this channel")
)

Functions

func DefaultCommandRunnerFunc

func DefaultCommandRunnerFunc(command string, args []string) (string, error)

DefaultCommandRunnerFunc is a wrapper for exec.Command

Types

type AnalyticsReporter added in v0.13.0

type AnalyticsReporter interface {
	// ReportCommand reports a new executed command. The command should be anonymized before using this method.
	ReportCommand(platform config.CommPlatformIntegration, command string) error
}

AnalyticsReporter defines a reporter that collects analytics data.

type CommandFlags added in v0.5.0

type CommandFlags string

CommandFlags creates custom type for flags in botkube

const (
	ClusterFlag    CommandFlags = "--cluster-name"
	FollowFlag     CommandFlags = "--follow"
	AbbrFollowFlag CommandFlags = "-f"
	WatchFlag      CommandFlags = "--watch"
	AbbrWatchFlag  CommandFlags = "-w"
)

Defines botkube flags

func (CommandFlags) String added in v0.5.0

func (flag CommandFlags) String() string

type CommandRunnerFunc

type CommandRunnerFunc func(command string, args []string) (string, error)

CommandRunnerFunc is a function which runs arbitrary commands

type DefaultExecutor

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

DefaultExecutor is a default implementations of Executor

func (*DefaultExecutor) Execute

func (e *DefaultExecutor) Execute() string

Execute executes commands and returns output

type DefaultExecutorFactory added in v0.13.0

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

DefaultExecutorFactory facilitates creation of the Executor instances.

func NewExecutorFactory added in v0.13.0

func NewExecutorFactory(log logrus.FieldLogger, runCmdFn CommandRunnerFunc, cfg config.Config, filterEngine filterengine.FilterEngine, kcChecker *kubectl.Checker, merger *kubectl.Merger, analyticsReporter AnalyticsReporter) *DefaultExecutorFactory

NewExecutorFactory creates new DefaultExecutorFactory.

func (*DefaultExecutorFactory) NewDefault added in v0.13.0

func (f *DefaultExecutorFactory) NewDefault(platform config.CommPlatformIntegration, notifierHandler NotifierHandler, isAuthChannel bool, conversationID string, bindings []string, message string) Executor

NewDefault creates new Default Executor.

type Executor

type Executor interface {
	Execute() string
}

Executor is an interface for processes to execute commands

type FiltersAction added in v0.8.0

type FiltersAction string

FiltersAction for options in filter commands

const (
	FilterList    FiltersAction = "list"
	FilterEnable  FiltersAction = "enable"
	FilterDisable FiltersAction = "disable"
)

Filter command options

func (FiltersAction) String added in v0.8.0

func (action FiltersAction) String() string

type Kubectl added in v0.13.0

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

Kubectl executes kubectl commands using local binary.

func NewKubectl added in v0.13.0

func NewKubectl(log logrus.FieldLogger, cfg config.Config, merger *kubectl.Merger, kcChecker *kubectl.Checker, fn CommandRunnerFunc) *Kubectl

NewKubectl creates a new instance of Kubectl.

func (*Kubectl) CanHandle added in v0.13.0

func (e *Kubectl) CanHandle(bindings []string, args []string) bool

CanHandle returns true if it's allowed kubectl command that can be handled by this executor.

TODO: we should just introduce a command name explicitly. In this case `@BotKube kubectl get po` instead of `@BotKube get po` As a result, we are able to detect kubectl command but say that you're simply not authorized to use it instead of "Command not supported. (..)"

func (*Kubectl) Execute added in v0.13.0

func (e *Kubectl) Execute(bindings []string, command string, isAuthChannel bool) (string, error)

Execute executes kubectl command based on a given args.

This method should be called ONLY if: - we are a target cluster, - and Kubectl.CanHandle returned true.

type NotifierAction added in v0.5.0

type NotifierAction string

NotifierAction creates custom type for notifier actions

const (
	Start      NotifierAction = "start"
	Stop       NotifierAction = "stop"
	Status     NotifierAction = "status"
	ShowConfig NotifierAction = "showconfig"
)

Defines constants for notifier actions

func (NotifierAction) String added in v0.5.0

func (action NotifierAction) String() string

type NotifierExecutor added in v0.13.0

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

NotifierExecutor executes all commands that are related to notifications.

func NewNotifierExecutor added in v0.13.0

func NewNotifierExecutor(log logrus.FieldLogger, cfg config.Config, analyticsReporter AnalyticsReporter) *NotifierExecutor

NewNotifierExecutor creates a new instance of NotifierExecutor.

func (*NotifierExecutor) CanHandle added in v0.13.0

func (e *NotifierExecutor) CanHandle(args []string) bool

CanHandle returns true if the arguments can be handled by this executor.

func (*NotifierExecutor) Do added in v0.13.0

func (e *NotifierExecutor) Do(args []string, platform config.CommPlatformIntegration, conversationID string, clusterName string, handler NotifierHandler) (string, error)

Do executes a given Notifier command based on args.

type NotifierHandler added in v0.13.0

type NotifierHandler interface {
	// NotificationsEnabled returns current notification status for a given conversation ID.
	NotificationsEnabled(conversationID string) bool

	// SetNotificationsEnabled sets a new notification status for a given conversation ID.
	SetNotificationsEnabled(conversationID string, enabled bool) error
}

NotifierHandler handles disabling and enabling notifications for a given communication platform.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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