config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SimpleStreams          LXDRemoteProtocol = "simplestreams"
	LXDImageVirtualMachine LXDImageType      = "virtual-machine"
	LXDImageContainer      LXDImageType      = "container"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIServer

type APIServer struct {
	Bind        string    `toml:"bind" json:"bind"`
	Port        int       `toml:"port" json:"port"`
	UseTLS      bool      `toml:"use_tls" json:"use-tls"`
	TLSConfig   TLSConfig `toml:"tls" json:"tls"`
	CORSOrigins []string  `toml:"cors_origins" json:"cors-origins"`
}

APIServer holds configuration for the API server worker

func (*APIServer) BindAddress

func (a *APIServer) BindAddress() string

BindAddress returns a host:port string.

func (*APIServer) Validate

func (a *APIServer) Validate() error

Validate validates the API server config

type Config

type Config struct {
	Default   Default    `toml:"default" json:"default"`
	APIServer APIServer  `toml:"apiserver,omitempty" json:"apiserver,omitempty"`
	Metrics   Metrics    `toml:"metrics,omitempty" json:"metrics,omitempty"`
	Database  Database   `toml:"database,omitempty" json:"database,omitempty"`
	Providers []Provider `toml:"provider,omitempty" json:"provider,omitempty"`
	Github    []Github   `toml:"github,omitempty"`
	JWTAuth   JWTAuth    `toml:"jwt_auth" json:"jwt-auth"`
}

func NewConfig

func NewConfig(cfgFile string) (*Config, error)

NewConfig returns a new Config

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the config

type DBBackendType

type DBBackendType string
const (
	// MySQLBackend represents the MySQL DB backend
	MySQLBackend DBBackendType = "mysql"
	// SQLiteBackend represents the SQLite3 DB backend
	SQLiteBackend DBBackendType = "sqlite3"
)

type Database

type Database struct {
	Debug     bool          `toml:"debug" json:"debug"`
	DbBackend DBBackendType `toml:"backend" json:"backend"`
	MySQL     MySQL         `toml:"mysql" json:"mysql"`
	SQLite    SQLite        `toml:"sqlite3" json:"sqlite3"`
	// Passphrase is used to encrypt any sensitive info before
	// inserting it into the database. This is just temporary until
	// we move to something like vault or barbican for secrets storage.
	// Don't lose or change this. It will invalidate all encrypted data
	// in the DB. This field must be set and must be exactly 32 characters.
	Passphrase string `toml:"passphrase"`
}

Database is the database config entry

func (*Database) GormParams

func (d *Database) GormParams() (dbType DBBackendType, uri string, err error)

GormParams returns the database type and connection URI

func (*Database) Validate

func (d *Database) Validate() error

Validate validates the database config entry

type Default

type Default struct {
	// ConfigDir is the folder where the runner may save any aditional files
	// or configurations it may need. Things like auto-generated SSH keys that
	// may be used to access the runner instances.
	ConfigDir string `toml:"config_dir,omitempty" json:"config-dir,omitempty"`
	// CallbackURL is the URL where the instances can send back status reports.
	CallbackURL string `toml:"callback_url" json:"callback-url"`
	// MetadataURL is the URL where instances can fetch information they may need
	// to set themselves up.
	MetadataURL string `toml:"metadata_url" json:"metadata-url"`
	// LogFile is the location of the log file.
	LogFile           string `toml:"log_file,omitempty" json:"log-file"`
	EnableLogStreamer bool   `toml:"enable_log_streamer"`
}

func (*Default) Validate

func (d *Default) Validate() error

type External

type External struct {
	// ConfigFile is the path on disk to a file which will be passed to
	// the external binary as an environment variable: GARM_PROVIDER_CONFIG
	// You can use this file for any configuration you need to do for the
	// cloud your calling into, to create the compute resources.
	ConfigFile string `toml:"config_file" json:"config-file"`
	// ProviderDir is the path on disk to a folder containing an executable
	// called "garm-external-provider".
	ProviderDir string `toml:"provider_dir" json:"provider-dir"`
	// ProviderExecutable is the full path to the executable that implements
	// the provider. If specified, it will take precedence over the "garm-external-provider"
	// executable in the ProviderDir.
	ProviderExecutable string `toml:"provider_executable" json:"provider-executable"`
}

External represents the config for an external provider. The external provider is a provider that delegates all operations to an external binary. This way, you can write your own logic in whatever programming language you wish, while still remaining compatible with garm.

func (*External) ExecutablePath

func (e *External) ExecutablePath() (string, error)

func (*External) Validate

func (e *External) Validate() error

type Github

type Github struct {
	Name          string `toml:"name" json:"name"`
	Description   string `toml:"description" json:"description"`
	OAuth2Token   string `toml:"oauth2_token" json:"oauth2-token"`
	APIBaseURL    string `toml:"api_base_url" json:"api-base-url"`
	UploadBaseURL string `toml:"upload_base_url" json:"upload-base-url"`
	BaseURL       string `toml:"base_url" json:"base-url"`
	// CACertBundlePath is the path on disk to a CA certificate bundle that
	// can validate the endpoints defined above. Leave empty if not using a
	// self signed certificate.
	CACertBundlePath string `toml:"ca_cert_bundle" json:"ca-cert-bundle"`
}

Github hold configuration options specific to interacting with github. Currently that is just a OAuth2 personal token.

func (*Github) APIEndpoint

func (g *Github) APIEndpoint() string

func (*Github) BaseEndpoint

func (g *Github) BaseEndpoint() string

func (*Github) CACertBundle

func (g *Github) CACertBundle() ([]byte, error)

func (*Github) UploadEndpoint

func (g *Github) UploadEndpoint() string

func (*Github) Validate

func (g *Github) Validate() error

type JWTAuth

type JWTAuth struct {
	Secret     string     `toml:"secret" json:"secret"`
	TimeToLive timeToLive `toml:"time_to_live" json:"time-to-live"`
}

JWTAuth holds settings used to generate JWT tokens

func (*JWTAuth) Validate

func (j *JWTAuth) Validate() error

Validate validates the JWTAuth config

type LXD

type LXD struct {
	// UnixSocket is the path on disk to the LXD unix socket. If defined,
	// this is prefered over connecting via HTTPs.
	UnixSocket string `toml:"unix_socket_path" json:"unix-socket-path"`

	// Project name is the name of the project in which this runner will create
	// instances. If this option is not set, the default project will be used.
	// The project used here, must have all required profiles created by you
	// beforehand. For LXD, the "flavor" used in the runner definition for a pool
	// equates to a profile in the desired project.
	ProjectName string `toml:"project_name" json:"project-name"`

	// IncludeDefaultProfile specifies whether or not this provider will always add
	// the "default" profile to any newly created instance.
	IncludeDefaultProfile bool `toml:"include_default_profile" json:"include-default-profile"`

	// URL holds the URL of the remote LXD server.
	// example: https://10.10.10.1:8443/
	URL string `toml:"url" json:"url"`
	// ClientCertificate is the x509 client certificate path used for authentication.
	ClientCertificate string `toml:"client_certificate" json:"client_certificate"`
	// ClientKey is the key used for client certificate authentication.
	ClientKey string `toml:"client_key" json:"client-key"`
	// TLS certificate of the remote server. If not specified, the system CA is used.
	TLSServerCert string `toml:"tls_server_certificate" json:"tls-server-certificate"`
	// TLSCA is the TLS CA certificate when running LXD in PKI mode.
	TLSCA string `toml:"tls_ca" json:"tls-ca"`

	// ImageRemotes is a map to a set of remote image repositories we can use to
	// download images.
	ImageRemotes map[string]LXDImageRemote `toml:"image_remotes" json:"image-remotes"`

	// SecureBoot enables secure boot for VMs spun up using this provider.
	SecureBoot bool `toml:"secure_boot" json:"secure-boot"`

	// InstanceType allows you to choose between a virtual machine and a container
	InstanceType LXDImageType `toml:"instance_type" json:"instance-type"`
}

LXD holds connection information for an LXD cluster.

func (*LXD) GetInstanceType

func (l *LXD) GetInstanceType() LXDImageType

func (*LXD) Validate

func (l *LXD) Validate() error

type LXDImageRemote

type LXDImageRemote struct {
	Address            string            `toml:"addr" json:"addr"`
	Public             bool              `toml:"public" json:"public"`
	Protocol           LXDRemoteProtocol `toml:"protocol" json:"protocol"`
	InsecureSkipVerify bool              `toml:"skip_verify" json:"skip-verify"`
}

LXDImageRemote holds information about a remote server from which LXD can fetch OS images. Typically this will be a simplestreams server.

func (*LXDImageRemote) Validate

func (l *LXDImageRemote) Validate() error

type LXDImageType

type LXDImageType string

func (LXDImageType) String

func (l LXDImageType) String() string

type LXDRemoteProtocol

type LXDRemoteProtocol string

type Metrics

type Metrics struct {
	DisableAuth bool `toml:"disable_auth" json:"disable-auth"`
	Enable      bool `toml:"enable" json:"enable"`
}

type MySQL

type MySQL struct {
	Username     string `toml:"username" json:"username"`
	Password     string `toml:"password" json:"password"`
	Hostname     string `toml:"hostname" json:"hostname"`
	DatabaseName string `toml:"database" json:"database"`
}

MySQL is the config entry for the mysql section

func (*MySQL) ConnectionString

func (m *MySQL) ConnectionString() (string, error)

ConnectionString returns a gorm compatible connection string

func (*MySQL) Validate

func (m *MySQL) Validate() error

Validate validates a Database config entry

type Provider

type Provider struct {
	Name         string              `toml:"name" json:"name"`
	ProviderType params.ProviderType `toml:"provider_type" json:"provider-type"`
	Description  string              `toml:"description" json:"description"`
	LXD          LXD                 `toml:"lxd" json:"lxd"`
	External     External            `toml:"external" json:"external"`
}

Provider holds access information for a particular provider. A provider offers compute resources on which we spin up self hosted runners.

func (*Provider) Validate

func (p *Provider) Validate() error

type SQLite

type SQLite struct {
	DBFile string `toml:"db_file" json:"db-file"`
}

SQLite is the config entry for the sqlite3 section

func (*SQLite) ConnectionString

func (s *SQLite) ConnectionString() (string, error)

func (*SQLite) Validate

func (s *SQLite) Validate() error

type TLSConfig

type TLSConfig struct {
	CRT string `toml:"certificate" json:"certificate"`
	Key string `toml:"key" json:"key"`
}

TLSConfig is the API server TLS config

func (*TLSConfig) Validate

func (t *TLSConfig) Validate() error

Validate validates the TLS config

Jump to

Keyboard shortcuts

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