environment

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type CloseableRepository

type CloseableRepository interface {
	Repository
	io.Closer
}

type Environment

type Environment interface {
	Session() session.Session

	Banner(Request) (io.ReadCloser, error)
	Run(Task) (int, error)

	IsPortForwardingAllowed(host string, port uint32) (bool, error)
	NewDestinationConnection(ctx context.Context, host string, port uint32) (io.ReadWriteCloser, error)

	Dispose(context.Context) (bool, 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) Close

func (this *LocalRepository) Close() error

func (*LocalRepository) DoesSupportPty added in v0.2.0

func (this *LocalRepository) DoesSupportPty(Request, ssh.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(req Request) (ok bool, err error)

type Repository

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

	// DoesSupportPty will return true if the resulting Environment will support
	// an PTY.
	DoesSupportPty(Request, ssh.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)
}

type RepositoryFacade

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

func NewRepositoryFacade

func NewRepositoryFacade(ctx context.Context, flows *configuration.Flows) (*RepositoryFacade, error)

func (*RepositoryFacade) Close

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

func (*RepositoryFacade) DoesSupportPty added in v0.2.0

func (this *RepositoryFacade) DoesSupportPty(req Request, pty ssh.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(req Request) (bool, error)

type RepositoryFactory added in v0.2.0

type RepositoryFactory[C any, R CloseableRepository] func(ctx context.Context, flow configuration.FlowName, conf C) (R, error)

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 {
	Remote() common.Remote
	Context() ssh.Context
	Logger() log.Logger
	Authorization() authorization.Authorization
}

type Task

type Task interface {
	Request
	SshSession() ssh.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