server

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrLabelRead       = "read"
	ErrLabelUnmarshall = "unmarshal"
	ErrLabelStart      = "start"
	SigLabelOk         = "ok"
	SigLabelFail       = "fail"
)

Variables

View Source
var (
	CmdRunDesc = map[CmdRunReason]string{
		CmdRunNoLabelMatch: "No match for alert labels",
		CmdRunNoMax:        "No maximum simultaneous command limit defined",
		CmdRunNoFinger:     "No fingerprint found for command",
		CmdRunFingerUnder:  "Command count for fingerprint is under limit",
		CmdRunFingerOver:   "Command count for fingerprint is over limit",
	}

	// These labels are meant to be applied to prometheus metrics
	CmdRunLabel = map[CmdRunReason]string{
		CmdRunNoLabelMatch: "nomatch",
		CmdRunNoMax:        "nomax",
		CmdRunNoFinger:     "nofinger",
		CmdRunFingerUnder:  "fingerunder",
		CmdRunFingerOver:   "fingerover",
	}
)

Functions

func StopServer added in v0.1.3

func StopServer(srv *http.Server) error

Types

type CmdRunReason

type CmdRunReason int
const (
	// Enum for reasons for why a command could or couldn't run
	CmdRunNoLabelMatch CmdRunReason = iota
	CmdRunNoMax
	CmdRunNoFinger
	CmdRunFingerUnder
	CmdRunFingerOver
)

func (CmdRunReason) Label

func (r CmdRunReason) Label() string

Label returns a prometheus-compatible label for a reason why a command could or couldn't run

func (CmdRunReason) String

func (r CmdRunReason) String() string

String returns a string representation of the reason why a command could or couldn't run

type CommandDetails

type CommandDetails struct {
	Cmd                 string
	Args                []string
	TerraformScheduling string
}

func DefaultCommandDetails added in v0.1.3

func DefaultCommandDetails(cmd string, args []string, terraformScheduling string) CommandDetails

Give default to CommandDetails

type Server

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

func NewServer

func NewServer(initConfig *config.InitConfig, config *config.Config) *Server

NewServer returns a new server instance

func (*Server) CanRun

func (s *Server) CanRun(cmd *command.Command, alert *template.Alert) (bool, CmdRunReason)

CanRun returns true if the Command is allowed to run based on its fingerprint and settings

func (*Server) Start

func (s *Server) Start() (*http.Server, chan error)

Start runs a golang http server with the given routes. Returns * a reference to the HTTP server (so that we can gracefully shut it down) a channel that will contain the error result of the ListenAndServe call

Jump to

Keyboard shortcuts

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