supervisor

package
v6.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 16, 2016 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthHeader added in v0.6.4

func AuthHeader(r *http.Request) (string, string)

func Authenticate added in v0.6.4

func Authenticate(tokens map[string]string, next http.Handler) http.Handler

func JSON

func JSON(w http.ResponseWriter, thing interface{})

func JSONLiteral

func JSONLiteral(w http.ResponseWriter, thing string)

func Sentencify

func Sentencify(words []string) string

func ShouldOAuthRedirect added in v0.6.4

func ShouldOAuthRedirect(path string) bool

Types

type ArchiveAPI

type ArchiveAPI struct {
	Data       *db.DB
	ResyncChan chan int
	Tasks      chan *db.Task
}

func (ArchiveAPI) ServeHTTP

func (self ArchiveAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

type AuthConfig added in v0.6.4

type AuthConfig struct {
	Tokens map[string]string `yaml:"api_tokens"`
	Basic  BasicAuthConfig   `yaml:"basic"`
	OAuth  OAuthConfig       `yaml:"oauth"`
}

type AuthZConfig added in v0.6.4

type AuthZConfig struct {
	Orgs []string `yaml:"orgs"`
}

type Authenticator added in v0.6.4

type Authenticator interface {
	IsAuthenticated(*http.Request) bool
	RequireAuth(http.ResponseWriter, *http.Request)
}
var UserAuthenticator Authenticator

type BasicAuthConfig added in v0.6.4

type BasicAuthConfig struct {
	User     string `yaml:"user"`
	Password string `yaml:"password"`
}

type BasicAuthenticator added in v0.6.4

type BasicAuthenticator struct {
	Cfg BasicAuthConfig
}

func (BasicAuthenticator) IsAuthenticated added in v0.6.4

func (ba BasicAuthenticator) IsAuthenticated(r *http.Request) bool

func (BasicAuthenticator) RequireAuth added in v0.6.4

func (ba BasicAuthenticator) RequireAuth(w http.ResponseWriter, r *http.Request)

type ClientError added in v0.4.1

type ClientError struct {
	Error string `json:"error"`
}

func ClientErrorf added in v0.4.1

func ClientErrorf(format string, v ...interface{}) ClientError

func (ClientError) JSON added in v0.4.1

func (e ClientError) JSON() string

type Config

type Config struct {
	DatabaseType string `yaml:"database_type"`
	DatabaseDSN  string `yaml:"database_dsn"`

	Addr string `yaml:"listen_addr"`

	PrivateKeyFile string `yaml:"private_key"`
	WebRoot        string `yaml:"web_root"`

	Workers uint `yaml:"workers"`

	PurgeAgent string `yaml:"purge_agent"`

	MaxTimeout uint `yaml:"max_timeout"`

	SkipSSLVerify bool `yaml:"skip_ssl_verify"`

	Auth AuthConfig `yaml:"auth"`
}

type GithubVerifier added in v0.6.4

type GithubVerifier struct {
	Orgs []string
}

func (*GithubVerifier) Membership added in v0.6.4

func (gv *GithubVerifier) Membership(user goth.User, c *http.Client) (map[string]interface{}, error)

func (*GithubVerifier) Verify added in v0.6.4

func (gv *GithubVerifier) Verify(user string, membership map[string]interface{}) bool

type InvalidParametersError

type InvalidParametersError struct {
	Errors map[string]string
}

func InvalidParameters

func InvalidParameters(names ...string) InvalidParametersError

func (InvalidParametersError) Error

func (e InvalidParametersError) Error() string

func (*InvalidParametersError) IsValid

func (e *InvalidParametersError) IsValid() bool

func (InvalidParametersError) JSON

func (e InvalidParametersError) JSON() string

func (*InvalidParametersError) Validate

func (e *InvalidParametersError) Validate(name string, value interface{}, fn Validator)

type JSONError

type JSONError interface {
	JSON() string
}

type JWTCreator added in v0.6.4

type JWTCreator struct {
	SigningKey *rsa.PrivateKey
}

func (JWTCreator) GenToken added in v0.6.4

func (jc JWTCreator) GenToken(user interface{}, membership interface{}, maxAge int) (string, error)

func (JWTCreator) ServeHTTP added in v0.6.4

func (jc JWTCreator) ServeHTTP(w http.ResponseWriter, r *http.Request)

type JobAPI

type JobAPI struct {
	Data       *db.DB
	ResyncChan chan int
	Tasks      chan *db.Task
}

func (JobAPI) ServeHTTP

func (self JobAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

type MembershipChecker added in v0.6.4

type MembershipChecker interface {
	Membership(goth.User, *http.Client) (map[string]interface{}, error)
	Verify(string, map[string]interface{}) bool
}
var OAuthVerifier MembershipChecker

type MetaAPI

type MetaAPI struct {
	PrivateKeyFile string
}

func (MetaAPI) ServeHTTP

func (self MetaAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

NOTE: APIs HANDLED HERE DO NOT REQUIRE AUTHENTICATION/AUTHORIZATION!!!

USE EXTREME CAUTION WHEN ADDING NEW HANDLERS

type MissingParametersError

type MissingParametersError struct {
	Missing []string `json:"missing"`
}

func MissingParameters

func MissingParameters(names ...string) MissingParametersError

func (*MissingParametersError) Check

func (e *MissingParametersError) Check(name string, value string)

func (MissingParametersError) Error

func (e MissingParametersError) Error() string

func (MissingParametersError) IsValid

func (e MissingParametersError) IsValid() bool

func (MissingParametersError) JSON

func (e MissingParametersError) JSON() string

type OAuthConfig added in v0.6.4

type OAuthConfig struct {
	Provider      string         `yaml:"provider"`
	ProviderURL   string         `yaml:"provider_url"`
	Key           string         `yaml:"key"`
	Secret        string         `yaml:"secret"`
	BaseURL       string         `yaml:"base_url"`
	Authorization AuthZConfig    `yaml:"authorization"`
	Sessions      SessionsConfig `yaml:"sessions"`
	SigningKey    string         `yaml:"signing_key"`
	JWTPrivateKey *rsa.PrivateKey
	JWTPublicKey  *rsa.PublicKey
	Client        *http.Client
}

type OAuthenticator added in v0.6.4

type OAuthenticator struct {
	Cfg OAuthConfig
}

func (OAuthenticator) IsAuthenticated added in v0.6.4

func (oa OAuthenticator) IsAuthenticated(r *http.Request) bool

func (OAuthenticator) OAuthCallback added in v0.6.4

func (oa OAuthenticator) OAuthCallback() http.Handler

func (OAuthenticator) RequireAuth added in v0.6.4

func (oa OAuthenticator) RequireAuth(w http.ResponseWriter, r *http.Request)

type PingAPI

type PingAPI struct{}

func (PingAPI) ServeHTTP

func (p PingAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

type RetentionAPI

type RetentionAPI struct {
	Data       *db.DB
	ResyncChan chan int
}

func (RetentionAPI) ServeHTTP

func (self RetentionAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

type ScheduleAPI

type ScheduleAPI struct {
	Data       *db.DB
	ResyncChan chan int
}

func (ScheduleAPI) ServeHTTP

func (self ScheduleAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

type SessionsConfig added in v0.6.4

type SessionsConfig struct {
	Type   string `yaml:"type"`
	DSN    string `yaml:"dsn"`
	MaxAge int    `yaml:"max_age"`
}

type StatusAPI added in v0.4.1

type StatusAPI struct {
	Data  *db.DB
	Super *Supervisor
}

func (StatusAPI) ServeHTTP added in v0.4.1

func (p StatusAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

type StoreAPI

type StoreAPI struct {
	Data       *db.DB
	ResyncChan chan int
}

func (StoreAPI) ServeHTTP

func (self StoreAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Supervisor

type Supervisor struct {
	Database *db.DB

	PrivateKeyFile string /* path to the SSH private key for talking to remote agents */
	Workers        uint   /* how many workers to spin up */
	PurgeAgent     string /* What agent to use for purge jobs */

	Web *WebServer /* Webserver that gets spawned to handle http requests */

	Timeout time.Duration
	// contains filtered or unexported fields
}

func NewSupervisor

func NewSupervisor() *Supervisor

func (*Supervisor) CheckSchedule

func (s *Supervisor) CheckSchedule()

func (*Supervisor) FailUnfinishedTasks added in v0.6.4

func (s *Supervisor) FailUnfinishedTasks() error

func (*Supervisor) PurgeArchives

func (s *Supervisor) PurgeArchives()

func (*Supervisor) ReadConfig

func (s *Supervisor) ReadConfig(path string) error

func (*Supervisor) RemoveTaskFromRunq added in v0.6.4

func (s *Supervisor) RemoveTaskFromRunq(id uuid.UUID)

func (*Supervisor) ReschedulePendingTasks added in v0.6.4

func (s *Supervisor) ReschedulePendingTasks() error

func (*Supervisor) Resync

func (s *Supervisor) Resync() error

func (*Supervisor) Run

func (s *Supervisor) Run() error

func (*Supervisor) ScheduleAdhoc

func (s *Supervisor) ScheduleAdhoc(a *db.Task)

func (*Supervisor) ScheduleTask added in v0.4.1

func (s *Supervisor) ScheduleTask(t *db.Task)

func (*Supervisor) SpawnAPI

func (s *Supervisor) SpawnAPI()

func (*Supervisor) SpawnWorker

func (s *Supervisor) SpawnWorker()

func (*Supervisor) SpawnWorkers

func (s *Supervisor) SpawnWorkers()

type TargetAPI

type TargetAPI struct {
	Data       *db.DB
	ResyncChan chan int
}

func (TargetAPI) ServeHTTP

func (self TargetAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

type TaskAPI

type TaskAPI struct {
	Data *db.DB
}

func (TaskAPI) ServeHTTP

func (self TaskAPI) ServeHTTP(w http.ResponseWriter, req *http.Request)

type UAAVerifier added in v0.6.4

type UAAVerifier struct {
	Groups []string
	UAA    string
}

func (*UAAVerifier) Membership added in v0.6.4

func (uv *UAAVerifier) Membership(user goth.User, c *http.Client) (map[string]interface{}, error)

func (*UAAVerifier) Verify added in v0.6.4

func (uv *UAAVerifier) Verify(user string, membership map[string]interface{}) bool

type UpdateOp

type UpdateOp int
const (
	STOPPED UpdateOp = iota
	FAILED
	OUTPUT
	RESTORE_KEY
	PURGE_ARCHIVE
)

type Validator

type Validator func(name string, value interface{}) error

type WebServer added in v0.6.4

type WebServer struct {
	Database      *db.DB
	Addr          string
	WebRoot       string
	Auth          AuthConfig
	Authenticator http.Handler
	Supervisor    *Supervisor
}

func (*WebServer) ProtectedAPIs added in v0.6.4

func (ws *WebServer) ProtectedAPIs() (http.Handler, error)

func (*WebServer) Setup added in v0.6.4

func (ws *WebServer) Setup() error

func (*WebServer) Start added in v0.6.4

func (ws *WebServer) Start()

func (*WebServer) UnauthenticatedResources added in v0.6.4

func (ws *WebServer) UnauthenticatedResources(next http.Handler) http.Handler

type WorkerRequest

type WorkerRequest struct {
	Operation      string `json:"operation"`
	TargetPlugin   string `json:"target_plugin"`
	TargetEndpoint string `json:"target_endpoint"`
	StorePlugin    string `json:"store_plugin"`
	StoreEndpoint  string `json:"store_endpoint"`
	RestoreKey     string `json:"restore_key"`
}

type WorkerUpdate

type WorkerUpdate struct {
	Task        uuid.UUID
	Archive     uuid.UUID
	TaskSuccess bool
	Op          UpdateOp
	StoppedAt   time.Time
	Output      string
}

Jump to

Keyboard shortcuts

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