common

package
v0.0.0-...-edc38d9 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2020 License: BSD-3-Clause Imports: 9 Imported by: 5

Documentation

Overview

*

  • Copyright 2020 Whiteblock Inc. All rights reserved.
  • Use of this source code is governed by a BSD-style
  • license that can be found in the LICENSE file.

*

  • Copyright 2020 Whiteblock Inc. All rights reserved.
  • Use of this source code is governed by a BSD-style
  • license that can be found in the LICENSE file.

*

  • Copyright 2020 Whiteblock Inc. All rights reserved.
  • Use of this source code is governed by a BSD-style
  • license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

View Source
var AccessDenied = errors.New("access denied")
View Source
var AlreadyExists = errors.New("already exists")
View Source
var EmptyDBResult = errors.New("not found")
View Source
var NotAMember = errors.New("not a member of this org")
View Source
var ValidationError = errors.New("validation error")

Functions

func IsFatalError

func IsFatalError(err error) bool

IsFatalError checks whether or not the error is a fatal error

Types

type CallToAction

type CallToAction struct {
	Icon string `json:"icon,omitempty"`
	Text string `json:"text,omitempty"`
	Link string `json:"link,omitempty"`
}

type Error

type Error struct {
	Type    ErrorType              `json:"type"`
	Message string                 `json:"message"`
	Meta    map[string]interface{} `json:"meta"`
}

Error is an improve error type for the inclusion of more information

func NewError

func NewError(msg interface{}) Error

NewError creates a new error of the default type

func NewFatalError

func NewFatalError(msg interface{}) Error

NewFatalError creates an error that does not warrant a retry

func (Error) Error

func (err Error) Error() string

Error gives the error message as a string

func (Error) InjectMeta

func (err Error) InjectMeta(meta map[string]interface{}) Error

InjectMeta allows the insertion of meta into the error

func (Error) MarshalText

func (err Error) MarshalText() (text []byte, _ error)

func (Error) WithStack

func (err Error) WithStack() Error

type ErrorType

type ErrorType int

ErrorType represents the types of errors

const (
	// Default is the generic error type
	Default ErrorType = iota

	// Fatal is the type for errors which are not recoverable
	Fatal
)

type Exec

type Exec struct {
	Test        string   `json:"test"`       //testid
	Target      string   `json:"target"`     //the entity to attach to
	Command     []string `json:"command"`    //the command to run
	Privileged  bool     `json:"privileged"` //should extra privileges be granted
	Interactive bool     `json:"interactive"`
	TTY         bool     `json:"tty"`
	Detach      bool     `json:"detach"`
}

type ExecAttach

type ExecAttach struct {
	ExecInfo
	TTY         bool `json:"tty"`
	Detach      bool `json:"detach"`
	Interactive bool `json:"interactive"`
}

type ExecInfo

type ExecInfo struct {
	Test string `json:"test"`
	ID   string `json:"id"`
	Host string `json:"host"`
}

type ForkResponse

type ForkResponse struct {
	DefinitionID string   `json:"definitionID"`
	TestIDs      []string `json:"testIDs"`
	Domains      []string `json:"domains"`
}

type Instance

type Instance struct {
	Provider  string         `json:"provider" db:"provider"`
	Project   string         `json:"project" db:"project"`
	Zone      string         `json:"zone" db:"zone"`
	Name      string         `json:"name" db:"name"`
	BiomeID   string         `json:"biomeId" db:"biome_id"`
	IP        string         `json:"ip" db:"ip"`
	HumanName sql.NullString `json:"humanName,omitempty" db:"human_name"`
	Index     sql.NullInt32  `json:"index,omitempty" db:"index"`
}

Instance represents a virtual machine in the cloud

type Metadata

type Metadata struct {
	ID           string    `json:"id"`
	DefinitionID string    `json:"definitionID"`
	UserID       string    `json:"userID"`
	Header       string    `json:"header"`
	Data         []byte    `json:"-"`
	Path         string    `json:"path,omitempty"`
	Filename     string    `json:"filename"`
	SizeBytes    int64     `json:"sizeBytes"`
	MD5          string    `json:"hash"`
	CreatedAt    time.Time `json:"createdAt"`
}

Metadata holds a bag of data representing information about an uploaded file

func (*Metadata) FilenameWithPath

func (m *Metadata) FilenameWithPath() string

FilenameWithPath preserves any path filename that was uploaded with the file in multipath upload, we set the path as the file upload formfile, ie: -F key/path/blah=@file.ext

type OrganizationProfile

type OrganizationProfile struct {
	MainCTA   CallToAction   `json:"mainCTA,omitempty"`
	Body      string         `json:"body,omitempty"`
	RightCTAs []CallToAction `json:"rightCTAs,omitempty"`
}

type Resize

type Resize struct {
	Height uint   `json:"height"`
	Width  uint   `json:"width"`
	Host   string `json:"host"`
	TestID string `json:"testID"`
	ExecID string `json:"execID"`
}

type RunningInstance

type RunningInstance struct {
	Domain string `json:"domain"`
	Ports  []int  `json:"ports"`
}

type Status

type Status struct {
	Test      string `json:"test" db:"test_id"`
	Org       string `json:"org" db:"organization_id"`
	Def       string `json:"def" db:"definition_id"`
	Phase     string `json:"phase" db:"phase"`
	StepsLeft int    `json:"stepsLeft" db:"steps_left"`
	Message   string `json:"message,omitempty" db:"message"`
	Finished  bool   `json:"finished" db:"finished"`
}

type Test

type Test struct {
	ID             string    `json:"id" db:"id"`
	DefinitionID   string    `json:"definitionID" db:"definition_id"`
	OrganizationID string    `json:"organizationID" db:"organization_id"`
	CreatedAt      time.Time `json:"createdAt" db:"created_at"`
	Status         string    `json:"status" db:"status"`
	DestroyedAt    time.Time `json:"destroyedAt" db:"destroyed_at"`
	Name           string    `json:"name" db:"name"`
	StripeID       string    `json:"-" db:"stripe_id"`
	BurnRate       int64     `json:"burnRate" db:"burn_rate"`
}

Test represents a whiteblock test

type TestDefinition

type TestDefinition struct {
	ID         string    `json:"id" db:"id"`
	KeycloakID string    `json:"userID" db:"keycloak_id"`
	OrgID      string    `json:"orgID" db:"organization_id"`
	CreatedAt  time.Time `json:"createdAt" db:"created_at"`
	Name       string    `json:"name" db:"name"`
}

type TestDefinitionSQL

type TestDefinitionSQL struct {
	ID         string         `json:"id" db:"id"`
	KeycloakID string         `json:"userID" db:"keycloak_id"`
	OrgID      string         `json:"orgID" db:"organization_id"`
	CreatedAt  time.Time      `json:"createdAt" db:"created_at"`
	Name       sql.NullString `json:"name" db:"name"`
}

func (TestDefinitionSQL) MarshalJSON

func (ts TestDefinitionSQL) MarshalJSON() ([]byte, error)

func (TestDefinitionSQL) TestDefinition

func (td TestDefinitionSQL) TestDefinition() TestDefinition

type TestInfo

type TestInfo struct {
	Name string `json:"name"`

	Instances []RunningInstance `json:"instances"`
	Domains   []string          `json:"domains"` //domain names

	// Ports contains the exposed ports,
	// len(Ports) == len(Domains), and Domains[n] should have all of the
	// ports in Ports[n] exposed. (Note: may not be always up, but will be up atleast once)
	Ports [][]int `json:"ports"` //exposed ports,

	// Files contains file name -> url to fetch it
	Files       map[string]string `json:"files"`
	Environment map[string]string `json:"environment"`

	DefinitionID   string    `json:"definitionID" db:"definition_id"`
	OrganizationID string    `json:"organizationID" db:"organization_id"`
	CreatedAt      time.Time `json:"createdAt" db:"created_at"`
	DestroyedAt    time.Time `json:"destroyedAt" db:"destroyed_at"`
	SpecFile       string    `json:"specFile"` //the definition spec
}

type TestLimits

type TestLimits struct {
	Duration    time.Duration `json:"duration"`
	Concurrency int           `json:"concurrency"`
	Runs        int           `json:"runs"`
	Size        int           `json:"size"`
}

type TestMeta

type TestMeta struct {
	DebugMode      bool   `json:"debugMode"`
	DockerUsername string `json:"dockerUsername,omitempty"`
	DockerPassword string `json:"dockerPassword,omitempty"`
	DockerToken    string `json:"dockerToken,omitempty"`
}

type TestSQL

type TestSQL struct {
	ID             string         `json:"id" db:"id"`
	DefinitionID   string         `json:"definitionID" db:"definition_id"`
	OrganizationID string         `json:"organizationID" db:"organization_id"`
	CreatedAt      sql.NullTime   `json:"createdAt" db:"created_at"`
	Status         sql.NullString `json:"status" db:"status"`
	DestroyedAt    sql.NullTime   `json:"destroyedAt" db:"destroyed_at"`
	Name           sql.NullString `json:"name" db:"name"`
	StripeID       sql.NullString `json:"-" db:"stripe_id"`
	BurnRate       sql.NullInt64  `json:"burnRate" db:"burn_rate"`
}

TestSQL is the SQL representation of a Test, this structure should only be used when working with Tests in the Database, when Marshalled into JSON, this structure decays into Test

func (TestSQL) MarshalJSON

func (ts TestSQL) MarshalJSON() ([]byte, error)

func (TestSQL) Test

func (ts TestSQL) Test() Test

type User

type User struct {
	ID         string    `json:"id" db:"id"`
	KeycloakID string    `json:"keycloak_id" db:"keycloak_id"`
	Username   string    `json:"username" db:"username"`
	Email      string    `json:"email" db:"email"`
	CreatedAt  time.Time `json:"created_at,omitonempty" db:"created_at"`
	UpdatedAt  time.Time `json:"updated_at,omitonempty" db:"updated_at"`
}

Jump to

Keyboard shortcuts

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