environment

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 55 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BifroestUnixBinaryMountTarget    = `/usr/bin/bifroest`
	BifroestWindowsBinaryMountTarget = `C:\Program Files\Engity\Bifroest\bifroest.exe`

	DockerLabelPrefix            = "org.engity.bifroest/"
	DockerLabelFlow              = DockerLabelPrefix + "flow"
	DockerLabelSessionId         = DockerLabelPrefix + "session-id"
	DockerLabelCreatedRemoteUser = DockerLabelPrefix + "created-remote-user"
	DockerLabelCreatedRemoteHost = DockerLabelPrefix + "created-remote-host"

	DockerLabelShellCommand          = DockerLabelPrefix + "shellCommand"
	DockerLabelExecCommand           = DockerLabelPrefix + "execCommand"
	DockerLabelSftpCommand           = DockerLabelPrefix + "sftpCommand"
	DockerLabelUser                  = DockerLabelPrefix + "user"
	DockerLabelDirectory             = DockerLabelPrefix + "directory"
	DockerLabelPortForwardingAllowed = DockerLabelPrefix + "portForwardingAllowed"
)

Variables

View Source
var (
	ErrNoSuchEnvironment = errors.New("no such environment")
	ErrNotAcceptable     = errors.New("not acceptable")
)

Functions

This section is empty.

Types

type CleanupOpts added in v0.4.0

type CleanupOpts struct {
	// FlowOfNamePredicate returns true if in the context of Bifröst
	// there exists another flow with this name.
	FlowOfNamePredicate func(configuration.FlowName) (bool, error)

	// Logger will be used (if any log is required) instead of the standard logger.
	Logger log.Logger
}

CleanupOpts adds some more hints what should happen when Repository.Cleanup is executed.

func (*CleanupOpts) GetLogger added in v0.4.0

func (this *CleanupOpts) GetLogger(or func() log.Logger) log.Logger

func (*CleanupOpts) HasFlowOfName added in v0.4.0

func (this *CleanupOpts) HasFlowOfName(name configuration.FlowName) (bool, error)

type CloseableRepository

type CloseableRepository interface {
	Repository
	io.Closer
}

type Context added in v0.4.0

type Context interface {
	Connection() connection.Connection
	Context() glssh.Context
	Authorization() authorization.Authorization
}

type DockerRepository added in v0.4.0

type DockerRepository struct {
	Logger log.Logger
	// contains filtered or unexported fields
}

func NewDockerRepository added in v0.4.0

func (*DockerRepository) Cleanup added in v0.4.0

func (this *DockerRepository) Cleanup(ctx context.Context, opts *CleanupOpts) error

func (*DockerRepository) Close added in v0.4.0

func (this *DockerRepository) Close() error

func (*DockerRepository) DoesSupportPty added in v0.4.0

func (this *DockerRepository) DoesSupportPty(Context, glssh.Pty) (bool, error)

func (*DockerRepository) Ensure added in v0.4.0

func (this *DockerRepository) Ensure(req Request) (Environment, error)

func (*DockerRepository) FindBySession added in v0.4.0

func (this *DockerRepository) FindBySession(ctx context.Context, sess session.Session, opts *FindOpts) (Environment, error)

func (*DockerRepository) WillBeAccepted added in v0.4.0

func (this *DockerRepository) WillBeAccepted(ctx Context) (ok bool, err error)

type DummyRepository added in v0.4.0

type DummyRepository struct {
	// contains filtered or unexported fields
}

func (*DummyRepository) Cleanup added in v0.4.0

func (this *DummyRepository) Cleanup(context.Context, *CleanupOpts) error

func (*DummyRepository) Close added in v0.4.0

func (this *DummyRepository) Close() error

func (*DummyRepository) DoesSupportPty added in v0.4.0

func (this *DummyRepository) DoesSupportPty(_ Context, _ glssh.Pty) (bool, error)

func (*DummyRepository) Ensure added in v0.4.0

func (this *DummyRepository) Ensure(req Request) (Environment, error)

func (*DummyRepository) FindBySession added in v0.4.0

func (this *DummyRepository) FindBySession(_ context.Context, sess session.Session, _ *FindOpts) (Environment, error)

func (*DummyRepository) WillBeAccepted added in v0.4.0

func (this *DummyRepository) WillBeAccepted(_ Context) (bool, error)

type Environment

type Environment interface {
	Banner(Request) (io.ReadCloser, error)
	Run(Task) (int, error)

	IsPortForwardingAllowed(net.HostPort) (bool, error)
	NewDestinationConnection(context.Context, net.HostPort) (io.ReadWriteCloser, error)

	// Dispose will fully dispose this instance.
	// It does also implicitly call Close() to ensure everything happens
	// in the correct synchronized context.
	Dispose(context.Context) (bool, error)

	// Close can be safely called more than once.
	Close() error
}

type FindOpts

type FindOpts struct {
	// AutoCleanUpAllowed tells the repository to clean up everything
	// automatically while executing the search. The requester will never
	// see the requested result. This is false by default because it could
	// lead to quite performance impacts or other unwanted side effects.
	//
	// Therefore: Use with caution.
	AutoCleanUpAllowed *bool

	// Logger will be used (if any log is required) instead of the standard logger.
	Logger log.Logger
}

FindOpts adds some more hints what should happen when find methods of Repository are executed.

func (*FindOpts) GetLogger

func (this *FindOpts) GetLogger(or func() log.Logger) log.Logger

func (*FindOpts) IsAutoCleanUpAllowed

func (this *FindOpts) IsAutoCleanUpAllowed() bool

type LocalRepository

type LocalRepository struct {
	Logger log.Logger
	// contains filtered or unexported fields
}

func (*LocalRepository) Cleanup added in v0.4.0

func (this *LocalRepository) Cleanup(context.Context, *CleanupOpts) error

func (*LocalRepository) Close

func (this *LocalRepository) Close() error

func (*LocalRepository) DoesSupportPty added in v0.2.0

func (this *LocalRepository) DoesSupportPty(Context, glssh.Pty) (bool, error)

func (*LocalRepository) Ensure

func (this *LocalRepository) Ensure(req Request) (Environment, error)

func (*LocalRepository) FindBySession

func (this *LocalRepository) FindBySession(ctx context.Context, sess session.Session, opts *FindOpts) (Environment, error)

func (*LocalRepository) WillBeAccepted

func (this *LocalRepository) WillBeAccepted(ctx Context) (ok bool, err error)

type PreparationProgress added in v0.4.0

type PreparationProgress interface {
	Report(progress float32) error
	Done() error
	Error(error) error
}

type PreparationProgressAttributes added in v0.4.0

type PreparationProgressAttributes map[string]any

type Repository

type Repository interface {
	// WillBeAccepted returns true if it is possible to get an Environment for the
	// provided Request.
	WillBeAccepted(Context) (bool, error)

	// DoesSupportPty will return true if the resulting Environment will support
	// an PTY.
	DoesSupportPty(Context, glssh.Pty) (bool, error)

	// Ensure will create or return an environment that matches the given Request.
	// If it is not acceptable to do this action with the provided Request
	// ErrNotAcceptable is returned; you can call WillBeAccepted to prevent such
	// errors.
	Ensure(Request) (Environment, error)

	// FindBySession will find an existing environment for a given session.Session.
	// If there is no matching one ErrNoSuchEnvironment will be returned.
	FindBySession(context.Context, session.Session, *FindOpts) (Environment, error)

	// Cleanup can be called while housekeeping iteration. It will also forward
	// all otherFlows that are configured within Bifröst. This gives the Repository
	// to potentially cleanup orphan resources that where initially owned by another
	// flow.
	Cleanup(context.Context, *CleanupOpts) error
}

type RepositoryFacade

type RepositoryFacade struct {
	// contains filtered or unexported fields
}

func NewRepositoryFacade

func NewRepositoryFacade(ctx context.Context, flows *configuration.Flows, ap alternatives.Provider, i imp.Imp) (*RepositoryFacade, error)

func (*RepositoryFacade) Cleanup added in v0.4.0

func (this *RepositoryFacade) Cleanup(ctx context.Context, opts *CleanupOpts) error

func (*RepositoryFacade) Close

func (this *RepositoryFacade) Close() (rErr error)

func (*RepositoryFacade) DoesSupportPty added in v0.2.0

func (this *RepositoryFacade) DoesSupportPty(ctx Context, pty glssh.Pty) (bool, error)

func (*RepositoryFacade) Ensure

func (this *RepositoryFacade) Ensure(req Request) (Environment, error)

func (*RepositoryFacade) FindBySession

func (this *RepositoryFacade) FindBySession(ctx context.Context, sess session.Session, opts *FindOpts) (Environment, error)

func (*RepositoryFacade) WillBeAccepted

func (this *RepositoryFacade) WillBeAccepted(ctx Context) (bool, error)

type RepositoryFactory added in v0.2.0

func RegisterRepository added in v0.2.0

func RegisterRepository[C any, R CloseableRepository](factory RepositoryFactory[C, R]) RepositoryFactory[C, R]

type Request

type Request interface {
	Context

	StartPreparation(id, title string, attrs PreparationProgressAttributes) (PreparationProgress, error)
}

type Task

type Task interface {
	Context
	SshSession() glssh.Session
	TaskType() TaskType
}

type TaskType

type TaskType uint8
const (
	TaskTypeShell TaskType = iota
	TaskTypeSftp
)

func (TaskType) String

func (this TaskType) String() string

Jump to

Keyboard shortcuts

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