daemon

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MPL-2.0 Imports: 43 Imported by: 0

Documentation

Overview

Package daemon configures and starts the otfd daemon and its subsystems.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSecretLength = errors.New("secret must be 16 bytes in size")

Functions

func ApplyDefaults

func ApplyDefaults(cfg *Config)

Types

type Config

type Config struct {
	RunnerConfig                 *runner.Config
	CacheConfig                  *inmem.CacheConfig
	GithubHostname               string
	GithubClientID               string
	GithubClientSecret           string
	GitlabHostname               string
	GitlabClientID               string
	GitlabClientSecret           string
	OIDC                         authenticator.OIDCConfig
	Secret                       []byte // 16-byte secret for signing URLs and encrypting payloads
	SiteToken                    string
	Host                         string
	WebhookHost                  string
	Address                      string
	Database                     string
	MaxConfigSize                int64
	SSL                          bool
	CertFile, KeyFile            string
	EnableRequestLogging         bool
	DevMode                      bool
	DisableScheduler             bool
	RestrictOrganizationCreation bool
	SiteAdmins                   []string
	SkipTLSVerification          bool
	// skip checks for latest terraform version
	DisableLatestChecker         *bool
	PlanningTimeout              time.Duration
	ApplyingTimeout              time.Duration
	OverrideTimeoutCheckInterval time.Duration

	tokens.GoogleIAPConfig
}

Config configures the otfd daemon. Descriptions of each field can be found in the flag definitions in ./cmd/otfd

func (*Config) Valid

func (cfg *Config) Valid() error

type Daemon

type Daemon struct {
	Config
	logr.Logger

	*sql.DB

	Organizations *organization.Service
	Runs          *run.Service
	Workspaces    *workspace.Service
	Variables     *variable.Service
	Notifications *notifications.Service
	Logs          *logs.Service
	State         *state.Service
	Configs       *configversion.Service
	Modules       *module.Service
	VCSProviders  *vcsprovider.Service
	Tokens        *tokens.Service
	Teams         *team.Service
	Users         *user.Service
	GithubApp     *github.Service
	RepoHooks     *repohooks.Service
	Runners       *runner.Service
	Connections   *connections.Service
	System        *internal.HostnameService
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, logger logr.Logger, cfg Config) (*Daemon, error)

New builds a new daemon and establishes a connection to the database and migrates it to the latest schema. Close() should be called to close this connection.

func (*Daemon) Start

func (d *Daemon) Start(ctx context.Context, started chan struct{}) error

Start the otfd daemon and block until ctx is cancelled or an error is returned. The started channel is closed once the daemon has started.

type Startable

type Startable interface {
	Start(ctx context.Context) error
}

Startable is a blocking process that is started at least once, and upon error, may need re-starting.

type Subsystem

type Subsystem struct {
	// Name of subsystem
	Name string
	// System is the underlying system to be invoked and supervised.
	System Startable
	// Exclusive: permit only one instance of this subsystem on an OTF
	// cluster
	Exclusive bool
	// DB for obtaining cluster-wide lock. Must be non-nil if Exclusive is
	// true.
	DB subsystemDB
	// Cluster-unique lock ID. Must be non-nil if Exclusive is true.
	LockID *int64
	logr.Logger
}

Subsystem is an automonous system subordinate to the main daemon (otfd).

func (*Subsystem) Start

func (s *Subsystem) Start(ctx context.Context, g *errgroup.Group) error

Jump to

Keyboard shortcuts

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