provisionersdk

package
v2.10.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagScope = "scope"
	TagOwner = "owner"

	ScopeUser         = "user"
	ScopeOrganization = "organization"
)
View Source
const (
	// ReadmeFile is the location we look for to extract documentation from template versions.
	ReadmeFile = "README.md"
)
View Source
const (
	// TemplateArchiveLimit represents the maximum size of a template in bytes.
	TemplateArchiveLimit = 1 << 20
)

Variables

This section is empty.

Functions

func AgentScriptEnv

func AgentScriptEnv() map[string]string

AgentScriptEnv returns a key-pair of scripts that are consumed by the Coder Terraform Provider. See: https://github.com/coder/terraform-provider-coder/blob/main/internal/provider/provider.go#L97

func ApplyErrorf added in v2.1.4

func ApplyErrorf(format string, args ...any) *proto.ApplyComplete

func CleanStaleSessions added in v2.2.0

func CleanStaleSessions(ctx context.Context, workDirectory string, fs afero.Fs, now time.Time, logger slog.Logger) error

CleanStaleSessions browses the work directory searching for stale session directories. Coder provisioner is supposed to remove them once after finishing the provisioning, but there is a risk of keeping them in case of a failure.

func DefaultDisplayApps added in v2.1.5

func DefaultDisplayApps() *proto.DisplayApps

DefaultDisplayApps returns the default display applications to enable if none are specified in a template.

func DirHasLockfile

func DirHasLockfile(dir string) (bool, error)

func MutateTags added in v2.5.0

func MutateTags(userID uuid.UUID, tags map[string]string) map[string]string

MutateTags adjusts the "owner" tag dependent on the "scope". If the scope is "user", the "owner" is changed to the user ID. This is for user-scoped provisioner daemons, where users should own their own operations. Otherwise, the "owner" tag is always an empty string. NOTE: "owner" must NEVER be nil. Otherwise it will end up being duplicated in the database, as idx_provisioner_daemons_name_owner_key is a partial unique index that includes a JSON field.

func ParseErrorf added in v2.1.4

func ParseErrorf(format string, args ...any) *proto.ParseComplete

func PlanErrorf added in v2.1.4

func PlanErrorf(format string, args ...any) *proto.PlanComplete

func ProvisionerJobLogsNotifyChannel

func ProvisionerJobLogsNotifyChannel(jobID uuid.UUID) string

ProvisionerJobLogsNotifyChannel is the PostgreSQL NOTIFY channel to publish updates to job logs on.

func Serve

func Serve(ctx context.Context, server Server, options *ServeOptions) error

Serve starts a dRPC connection for the provisioner and transport provided.

func SessionDir added in v2.2.0

func SessionDir(sessID string) string

SessionDir returns the directory name with mandatory prefix.

func Tar

func Tar(w io.Writer, logger slog.Logger, directory string, limit int64) error

Tar archives a Terraform directory.

func Untar

func Untar(directory string, r io.Reader) error

Untar extracts the archive to a provided directory.

Types

type ProvisionerJobLogsNotifyMessage

type ProvisionerJobLogsNotifyMessage struct {
	CreatedAfter int64 `json:"created_after"`
	EndOfLogs    bool  `json:"end_of_logs,omitempty"`
}

ProvisionerJobLogsNotifyMessage is the payload published on the provisioner job logs notify channel.

type ServeOptions

type ServeOptions struct {
	// Listener serves multiple connections. Cannot be combined with Conn.
	Listener net.Listener
	// Conn is a single connection to serve. Cannot be combined with Listener.
	Conn          drpc.Transport
	Logger        slog.Logger
	WorkDirectory string
}

ServeOptions are configurations to serve a provisioner.

type Server added in v2.1.4

type Server interface {
	Parse(s *Session, r *proto.ParseRequest, canceledOrComplete <-chan struct{}) *proto.ParseComplete
	Plan(s *Session, r *proto.PlanRequest, canceledOrComplete <-chan struct{}) *proto.PlanComplete
	Apply(s *Session, r *proto.ApplyRequest, canceledOrComplete <-chan struct{}) *proto.ApplyComplete
}

type Session added in v2.1.4

type Session struct {
	Logger        slog.Logger
	WorkDirectory string
	Config        *proto.Config
	// contains filtered or unexported fields
}

func (*Session) Context added in v2.1.4

func (s *Session) Context() context.Context

func (*Session) ProvisionLog added in v2.1.4

func (s *Session) ProvisionLog(level proto.LogLevel, output string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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