types

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2019 License: MPL-2.0-no-copyleft-exception Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTaskParse is what is wrapped when a parse error occurs.
	ErrTaskParse = errors.New("parse error")
	// ErrTaskValidation is what is wrapped when errors in TaskSettings.Validate() occur.
	ErrTaskValidation = errors.New("validation error")
)

Functions

func DecodeKey

func DecodeKey(key string) []byte

DecodeKey takes a hexadecimal key and turns it into a byte array where the bytes represent the by-two hexadecimal numerical values present in the original key.

func EncodeKey

func EncodeKey(key []byte) string

EncodeKey takes a byte stream and yields a hexadecimal set of values associated with it. See `xxd(1)`.

func EncryptToken

func EncryptToken(key []byte, tok *OAuthToken) ([]byte, error)

EncryptToken encrypts an oauth token with gcm+aes.

Types

type OAuthToken

type OAuthToken struct {
	Token    string   `json:"token"`
	Scopes   []string `json:"scopes"`
	Username string   `json:"username"`
}

OAuthToken contains a token and any metadata we want to assign to it.

func DecryptToken

func DecryptToken(key, tokenBytes []byte) (*OAuthToken, error)

DecryptToken decrypts a token message that was encrypted by EncryptToken.

func (*OAuthToken) Can

func (oat *OAuthToken) Can(scope string) bool

Can returns true if the scope is present in the scopes list.

type RepoConfig

type RepoConfig struct {
	WorkDir          string                 `yaml:"workdir"`
	Queue            string                 `yaml:"queue"`
	OverrideQueue    bool                   `yaml:"override_queue"`
	GlobalTimeout    time.Duration          `yaml:"global_timeout"` // run timeout. if unset, or 0, no timeout.
	OverrideTimeout  bool                   `yaml:"override_timeout"`
	IgnoreDirs       []string               `yaml:"ignore_directories"`
	Metadata         map[string]interface{} `yaml:"metadata"`
	OverrideMetadata bool                   `yaml:"override_metadata"`
	DefaultImage     string                 `yaml:"default_image"`
}

RepoConfig is the global configuration for the repository. It allows setting of global attributes as well as overrides and defaults for certain task-related items. It is typically named `tinyci.yml`.

func NewRepoConfig

func NewRepoConfig(buf []byte) (*RepoConfig, error)

NewRepoConfig creates a new repo config from a byte buffer.

func (*RepoConfig) Validate

func (r *RepoConfig) Validate() error

Validate returns any error if there are validation errors in the repo config.

type RunSettings

type RunSettings struct {
	Command  []string               `yaml:"command"`
	Image    string                 `yaml:"image"`
	Queue    string                 `yaml:"queue"`
	Metadata map[string]interface{} `yaml:"metadata"`
	Name     string                 `yaml:"-"`
	Timeout  time.Duration          `yaml:"timeout"`
}

RunSettings encompasses things that are a part of a run that are configurable by a user.

func NewRunSettingsFromProto

func NewRunSettingsFromProto(rs *types.RunSettings) *RunSettings

NewRunSettingsFromProto creates a runsettings from a proto representation.

func (*RunSettings) ToProto

func (rs *RunSettings) ToProto() *types.RunSettings

ToProto converts the run settings to the protobuf representation.

func (*RunSettings) Validate

func (rs *RunSettings) Validate() error

Validate validates the run settings, returning errors on any found.

type Submission

type Submission struct {
	Parent      string `json:"parent"`
	Fork        string `json:"fork"`
	HeadSHA     string `json:"head_sha"`
	BaseSHA     string `json:"base_sha"`
	TicketID    int64  `json:"ticket_id"`
	SubmittedBy string `json:"submitted_by"`
	All         bool   `json:"all"`

	Manual bool `json:"-"`
}

Submission is the encapsulation of a submission to the queuesvc.

func (*Submission) Validate

func (sub *Submission) Validate() error

Validate validates the submission, and returns an error if it encounters any.

type TaskSettings

type TaskSettings struct {
	Mountpoint     string                  `yaml:"mountpoint"`
	Env            []string                `yaml:"env"`
	Dependencies   []string                `yaml:"dependencies"`
	WorkDir        string                  `yaml:"workdir"`
	Runs           map[string]*RunSettings `yaml:"runs"`
	DefaultTimeout time.Duration           `yaml:"default_timeout"`
	DefaultQueue   string                  `yaml:"default_queue"`
	DefaultImage   string                  `yaml:"default_image"`
	Metadata       map[string]interface{}  `yaml:"metadata"`
	Config         *RepoConfig             `yaml:"-"`
}

TaskSettings encompasses things that are a part of a task that are configurable by a user.

func NewTaskSettings

func NewTaskSettings(buf []byte, requireRuns bool, rc *RepoConfig) (*TaskSettings, error)

NewTaskSettings creates a new task configuration from a byte buffer.

func NewTaskSettingsFromProto

func NewTaskSettingsFromProto(ts *types.TaskSettings) *TaskSettings

NewTaskSettingsFromProto creates a task settings object from a proto representation.

func (*TaskSettings) ToProto

func (t *TaskSettings) ToProto() *types.TaskSettings

ToProto makes a protobuf version of task settings.

func (*TaskSettings) Validate

func (t *TaskSettings) Validate(requireRuns bool) error

Validate validates the task settings.

Jump to

Keyboard shortcuts

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