server

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2019 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigurationPath = "/configuration"

ConfigurationPath is the URL path to add a new webhook

View Source
const WebhookPath = "/webhook/"

WebhookPath is the first part of the webhook payload URL

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(src string, dst string) error

CopyFile copies a source file to a destination file. Any existing file will be overwritten and will not copy file attributes.

func ExecuteScript

func ExecuteScript(c Connector, conf executeConfiguration) error

ExecuteScript triggers a qsub command on the HPC cluster

func InitDB

func InitDB(dataSourceName string) (*sql.DB, error)

InitDB initializes the database

func RunsWithinContainer

func RunsWithinContainer() bool

RunsWithinContainer checks if the program runs in a Docker container or not

Types

type API

type API struct {
	DB                        *sql.DB
	Connector                 Connector
	DataDir                   string
	HomeDir                   string
	RelayNode                 string
	RelayNodeTestUser         string
	RelayNodeTestUserPassword string
	QaasHost                  string
	QaasPort                  string
	PrivateKeyFilename        string
	PublicKeyFilename         string
}

API is used to store the database pointer

func (*API) ConfigurationHandler

func (a *API) ConfigurationHandler(w http.ResponseWriter, req *http.Request)

ConfigurationHandler handles a webhook registration HTTP PUT request with the hash and username in its body

func (*API) WebhookHandler

func (a *API) WebhookHandler(w http.ResponseWriter, req *http.Request)

WebhookHandler handles a HTTP POST request containing the webhook payload in its body

type ConfigurationRequest

type ConfigurationRequest struct {
	Hash      string `json:"hash"`
	Groupname string `json:"groupname"`
	Username  string `json:"username"`
}

ConfigurationRequest stores one row of webhook information

type ConfigurationResponse

type ConfigurationResponse struct {
	Webhook string `json:"webhook"`
}

ConfigurationResponse contains the complet webhook payload URL

type Connector

type Connector interface {
	NewClient(remoteServer string, clientConfig *ssh.ClientConfig) (*ssh.Client, error)
	NewSession(client *ssh.Client) (*ssh.Session, error)
	Run(session *ssh.Session, command string) error
	CombinedOutput(session *ssh.Session, command string) ([]byte, error)
	CloseSession(session *ssh.Session) error
}

Connector is an interface to be able to mock SSH connections

type SSHConnector

type SSHConnector struct {
	Description string
}

SSHConnector is used tp replace the standard SSH library functions

func (SSHConnector) CloseSession

func (c SSHConnector) CloseSession(session *ssh.Session) error

CloseSession makes it possible to mock the closing of a session

func (SSHConnector) CombinedOutput

func (c SSHConnector) CombinedOutput(session *ssh.Session, command string) ([]byte, error)

CombinedOutput makes it possible to mock a local CombinedOutput

func (SSHConnector) NewClient

func (c SSHConnector) NewClient(remoteServer string, clientConfig *ssh.ClientConfig) (*ssh.Client, error)

NewClient makes it possible to mock SSH dial

func (SSHConnector) NewSession

func (c SSHConnector) NewSession(client *ssh.Client) (*ssh.Session, error)

NewSession makes it possible to mock a SSH session

func (SSHConnector) Run

func (c SSHConnector) Run(session *ssh.Session, command string) error

Run makes it possible to mock a remote Run command

type Webhook

type Webhook struct {
	WebhookID string
	ID        string
	Event     string
	Signature string
	Payload   []byte
}

Webhook is an inbound github webhook

Jump to

Keyboard shortcuts

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