utils

package
v0.0.0-...-cb03ccd Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildMockSplunkServer

func BuildMockSplunkServer(splunkResult float64) *httptest.Server

Build a mock splunk server returning default responses when getting get and post requests

func ConfigureLogger

func ConfigureLogger(eventID, keptnContext string, logLevel string)

func ConnectToSplunk

func ConnectToSplunk(splunkCreds SplunkCredentials, skipSSL bool) *splunk.SplunkClient

Creates an authenticated splunk client

func MultitpleMockRequest

func MultitpleMockRequest(getResponses []string, postResponses []string, paths []string, sslVerificationActivated bool) *httptest.Server

func RetrieveQueryTimeRange

func RetrieveQueryTimeRange(earliestTime string, latestTime string, searchQuery string) (string, string, string)

get the earliest, latest time from the splunk search and also update the search query

Types

type EnvConfig

type EnvConfig struct {
	// Port on which to listen for cloudevents
	Port int `envconfig:"RCV_PORT" default:"8080"`
	// Path to which cloudevents are sent
	Path string `envconfig:"RCV_PATH" default:"/"`
	// Whether we are running locally (e.g., for testing) or on production
	Env string `envconfig:"ENV" default:"local"`

	ConfigurationServiceUrl string `envconfig:"CONFIGURATION_SERVICE" default:""`

	SplunkApiToken   string `envconfig:"SP_API_TOKEN" default:""`
	SplunkHost       string `envconfig:"SP_HOST" default:""`
	SplunkPort       string `envconfig:"SP_PORT" default:"8089"`
	SplunkUsername   string `envconfig:"SP_USERNAME" default:""`
	SplunkPassword   string `envconfig:"SP_PASSWORD" default:""`
	SplunkSessionKey string `envconfig:"SP_SESSION_KEY" default:""`

	AlertSuppressPeriod  string `envconfig:"ALERT_SUPPRESS_PERIOD" default:"3m"`
	CronSchedule         string `envconfig:"CRON_SCHEDULE" default:"3m"`
	DispatchEarliestTime string `envconfig:"DISPATCH_EARLIEST_TIME" default:"*/1 * * * *"`
	DispatchLatestTime   string `envconfig:"DISPATCH_LATEST_TIME" default:"now"`
	Actions              string `envconfig:"ACTIONS" default:""`
	WebhookUrl           string `envconfig:"WEBHOOK_URL" default:""`
}

type Formatter

type Formatter struct {
	Fields           logger.Fields
	BuiltinFormatter logger.Formatter
}

func (*Formatter) Format

func (f *Formatter) Format(entry *logger.Entry) ([]byte, error)

type SplunkCredentials

type SplunkCredentials struct {
	Host       string `json:"host" yaml:"spHost"`
	Port       string `json:"port" yaml:"spPort"`
	Username   string `json:"username" yaml:"spUsername"`
	Password   string `json:"password" yaml:"spPassword"`
	Token      string `json:"token" yaml:"spApiToken"`
	SessionKey string `json:"sessionKey" yaml:"spSessionKey"`
}

func GetSplunkCredentials

func GetSplunkCredentials(env EnvConfig) (*SplunkCredentials, error)

getSplunkCredentials get the splunk host, port and api token from the environment variables set from secret

Jump to

Keyboard shortcuts

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