server

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2019 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigurationAddPath = "/configuration"

ConfigurationAddPath is the URL path to add a new webhook [PUT]

View Source
const ConfigurationDeletePath = "/configuration/{webhook}"

ConfigurationDeletePath is the URL path to delete a certain webhook [DELETE]

View Source
const ConfigurationInfoPath = "/configuration/{webhook}"

ConfigurationInfoPath is the URL path to get detailed information about a certain webhook [GET]

View Source
const ConfigurationListPath = "/configuration"

ConfigurationListPath is the URL path to list all webhook for a certain user [GET]

View Source
const ConfigurationPath = "/configuration"

ConfigurationPath is the basic URL path for configuring the qaas server

View Source
const WebhookPath = "/webhook"

WebhookPath is the basic part of the webhook payload URL

View Source
const WebhookPostPath = "/webhook/{webhook}"

WebhookPostPath is the first part of the webhook payload URL [POST]

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
	QaasInternalPort          string // Port for internal use
	QaasExternalPort          string // Port for the outside world
	PrivateKeyFilename        string
	PublicKeyFilename         string
}

API is used to store the database pointer

func (*API) ConfigurationAddHandler

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

ConfigurationAddHandler handles a HTTP PUT request to register a certain webhook with hash, groupname, and username in its body

func (*API) ConfigurationDeleteHandler

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

ConfigurationDeleteHandler handles a HTTP DELETE request to delete a certain webhook for a certain user

func (*API) ConfigurationInfoHandler

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

ConfigurationInfoHandler handles a HTTP GET request to obtain detailed information about a specific webhook

func (*API) ConfigurationListHandler

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

ConfigurationListHandler handles a HTTP GET request to obtain all webhooks for a certain user

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 ConfigurationDeleteResponse

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

ConfigurationDeleteResponse contains the webhook that has been deleted

type ConfigurationInfoResponse

type ConfigurationInfoResponse struct {
	Webhook Item `json:"webhook"`
}

ConfigurationInfoResponse contains the detailed information about a specific webhook

type ConfigurationListResponse

type ConfigurationListResponse struct {
	Webhooks []Item `json:"webhooks"`
}

ConfigurationListResponse contains the list of regstered webhooks for a certain user

type ConfigurationRequest

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

ConfigurationRequest stores one row of webhook information

type ConfigurationResponse

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

ConfigurationResponse contains the complete 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 Item

type Item struct {
	ID          int    `json:"-"` // Do not output this one
	Hash        string `json:"hash"`
	Groupname   string `json:"groupname"`
	Username    string `json:"username"`
	Description string `json:"description"`
	Created     string `json:"created"`
	URL         string `json:"url"`
}

Item corresponds to a row in the qaas database

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