server

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Config file defaults (yml)
	DefaultAuthPathPrefix         = "/k8ctl-server/auth"
	DefaultHostname               = "localhost"
	DefaultPort                   = 8080
	DefaultQueueVisibilityTimeout = 20
	DefaultQueueWaitTimeInSeconds = 10
	DefaultReadTimeout            = 10
	DefaultShutdownWait           = 20
	DefaultWorkerPollInt          = 10
	DefaultWriteTimeout           = 10

	HttpRouteDefaultHealth = "/health" // Healthcheck. This is customizable so to obuscate the path. No header or auth is needed.

	// Misc
	JobTypeDelete   = 1 // iota didnt work as an int
	JobTypeDeploy   = 2
	JobTypeRestart  = 3
	JobTypeRollback = 4

	GuideTemplate = `` /* 1087-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func NewSlackWorker added in v1.0.8

func NewSlackWorker(sv *Server) (*slackWorker, error)

NewWorker is a factory function that returns a worker object.

func NewWorker

func NewWorker(done chan bool, logr *logger.Logger, options *Options, sqsc *sqs.SQS, ssmc *ssm.SSM, wtgrp *sync.WaitGroup) *worker

NewWorker is a factory function that returns a worker object.

func Version

func Version() string

Version prints the version of the server.

Types

type DeployRequest

type DeployRequest struct {
	Memo       string `json:"memo"`       // Optional text to display in slack etc.
	Name       string `json:"name"`       // The application/chart name to deploy.
	Namespace  string `json:"namespace"`  // The namespace to deploy.
	VersionTag string `json:"versionTag"` // The docker version tag.
}

Represents the payload of a request to deploy a chart.

type GuideData

type GuideData struct {
	ValidAppsQuery  *[]string `json:"validAppsQuery"`  // List of valid apps for servicing
	ValidAppsDeploy *[]string `json:"validAppsDeploy"` // List of valid apps for deploy
	Namespaces      *[]string `json:"namespaces"`      //  List of valid namespaces for servicing

}

Structure for guide data as a source to rendering a template.

type JenkinsPayload

type JenkinsPayload struct {
	Metadata struct {
		App       string `json:"app"`
		Namespace string `json:"namespace"`
	} `json:"metadata"`
	Payload struct {
		Pushdata struct {
			Tag string `json:"tag"`
		} `json:"push_data"`
		Repository struct {
			RepoName string `json:"repo_name"`
		} `json:"repository"`
		CallbackUrl string `json:"callback_url"`
	} `json:"payload"`
}

Multilayered request to Jenkins.

type Options

type Options struct {
	AuthPathPrefix         string        `json:"authPathPrefix"`         // Path in ssm to locate user key for authentication. /<prefix>/:user/token/
	ConfigPrefix           string        `json:"configPrefix"`           // Prefix of the config file name of the server.
	Debug                  bool          `json:"debugEnabled"`           // Is debugging enabled for the server?
	HealthRoute            string        `json:"healthRoute"`            // Obuscated route to the heathcheck of the server.
	Hostname               string        `json:"hostName"`               // Hostname of the server.
	ImageTagPrefix         string        `json:"imageTagPrefix"`         // Mandatory prefix of a docker image tag.
	JenkinsUrl             string        `json:"jenkinsUrl"`             // Endpoint to jenkins ingest webhook. This is within K8s.
	JenkinsTokenPath       string        `json:"jenkinsTokenPath"`       // Path in ssm to retrieve the token to make API calls to Jenkins server.
	Namespaces             []string      `json:"namespaces"`             // Namespaces this server manages.
	Port                   int           `json:"port"`                   // HTTP api port of the server.
	ProfPort               int           `json:"profPort"`               // The profiler port of the server.
	QueueUrl               string        `json:"queueUrl"`               // URL to the queue server.
	QueueVisibilityTimeout int           `json:"queueTimeout"`           // How long the message should be hidden after receive.
	QueueWaitTimeInSeconds int           `json:"queueWait"`              // How long to wait for a message to be available.
	ReadTimeout            time.Duration `json:"readTimeout"`            // Server read request timeout.
	ShutdownWait           time.Duration `json:"shutdownWait"`           // Shutdown wait time in seconds.
	SlackAPITokenPath      string        `json:"slackAPITokenPath"`      // Path in parameter store for the token for the bot.
	SlackChannelIDs        []string      `json:"slackChannelIDs"`        // Channel ID's that the bot responds to.
	SlackSigningSecretPath string        `json:"slackSigningSecretPath"` // Path in parameter store for the signing secret.
	SlackUrl               string        `json:"slackUrl"`               // Url of the webhook to slack channel for reporting results.
	ValidAppsQueryPath     string        `json:"validAppsQueryPath"`     // Path in ssm to validate applications that can be queries by the server.
	ValidAppsDeployPath    string        `json:"validAppsDeployPath"`    // Path in ssm to validate applications that can be deployed by the server.
	WorkerPollInt          int           `json:"workerPoll"`             // Worker poll wait interval.
	WriteTimeout           time.Duration `json:"writeTimeout"`           // Server write request timeout.
}

Options represents parameters that are passed to the application for launching the server.

func NewOptions

func NewOptions(debug bool) *Options

Factory function to create Option objects.

func (*Options) FillConfig

func (o *Options) FillConfig()

Fill in the options from a viper configuration.

func (*Options) String

func (o *Options) String() string

String is an implentation of the Stringer interface so the structure is returned as a string to fmt.Print() etc.

type RestartRequest

type RestartRequest struct {
	Namespace string `json:"namespace"` // The namespace to restart.
}

Represents the payload of a request to restart a deployment.

type RollbackRequest

type RollbackRequest struct {
	Revision string `json:"revision"` // The revision to roll back to (optional)
}

Represents the payload of a request to rollack a chart.

type Server

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

Server - wrapper around the API server.

func NewServer

func NewServer(options *Options, logr *logger.Logger) (*Server, error)

NewServer is a factory function that returns a new client instance.

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown waits for jobs to be complete and closes out all resources.

func (*Server) Start

func (s *Server) Start() error

Start spins up the server to accept incoming requests.

func (*Server) StartProfiler

func (s *Server) StartProfiler()

StartProfiler is called to enable dynamic profiling.

type SlackDeployErrResponse added in v1.0.8

type SlackDeployErrResponse struct {
	ResponseAction string `json:"response_action"`
	Errors         struct {
		NamespaceSelected string `json:"namespaceSelected,omitempty"`
		RepoSelected      string `json:"repoSelected,omitempty"`
		ImageTag          string `json:"imageTag,omitempty"`
	} `json:"errors"`
}

Jump to

Keyboard shortcuts

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