target

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTargetHostSetTableName = "target_host_set"
)
View Source
const (
	DefaultTcpTableName = "target_tcp"
)
View Source
const (
	TcpTargetPrefix = "ttcp"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cloneable

type Cloneable interface {
	Clone() interface{}
}

Clonable provides a cloning interface

type Option

type Option func(*options)

Option - how Options are passed as arguments

func WithDefaultPort

func WithDefaultPort(p uint32) Option

WithDefaultPort provides an option to specify the default target port.

func WithDescription

func WithDescription(desc string) Option

WithDescription provides an optional description

func WithHostSets

func WithHostSets(hs []string) Option

WithHostSets provides an option for providing a list of host set ids

func WithLimit

func WithLimit(limit int) Option

WithLimit provides an option to provide a limit. Intentionally allowing negative integers. If WithLimit < 0, then unlimited results are returned. If WithLimit == 0, then default limits are used for results.

func WithName

func WithName(name string) Option

WithName provides an option to search by a friendly name

func WithPublicId

func WithPublicId(id string) Option

WithPublicId provides an optional public id

func WithScopeId

func WithScopeId(scopeId string) Option

WithScopeId provides an option to search by a scope id

func WithScopeIds added in v0.1.5

func WithScopeIds(scopeIds []string) Option

WithScopeId provides an option to search by multiple scope id

func WithScopeName added in v0.1.1

func WithScopeName(scopeName string) Option

WithScopeId provides an option to search by a scope name

func WithSessionConnectionLimit

func WithSessionConnectionLimit(limit int32) Option

func WithSessionMaxSeconds

func WithSessionMaxSeconds(dur uint32) Option

func WithTargetType

func WithTargetType(t TargetType) Option

WithTargetType provides an option to search by a target type

func WithUserId

func WithUserId(userId string) Option

WithUserId provides an option to search by a user public id

func WithWorkerFilter added in v0.1.5

func WithWorkerFilter(filter string) Option

WithWorkerFilter provides an optional worker filter

type Repository

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

Repository is the target database repository

func NewRepository

func NewRepository(r db.Reader, w db.Writer, kms *kms.Kms, opt ...Option) (*Repository, error)

NewRepository creates a new target Repository. Supports the options: WithLimit which sets a default limit on results returned by repo operations.

func (*Repository) AddTargetHostSets

func (r *Repository) AddTargetHostSets(ctx context.Context, targetId string, targetVersion uint32, hostSetIds []string, _ ...Option) (Target, []*TargetSet, error)

AddTargetHostSets provides the ability to add host sets (hostSetIds) to a target (targetId). The target's current db version must match the targetVersion or an error will be returned. The target and a list of current host set ids will be returned on success. Zero is not a valid value for the WithVersion option and will return an error.

func (*Repository) CreateTcpTarget

func (r *Repository) CreateTcpTarget(ctx context.Context, target *TcpTarget, opt ...Option) (Target, []*TargetSet, error)

CreateTcpTarget inserts into the repository and returns the new Target with its list of host sets. WithHostSets is currently the only supported option.

func (*Repository) DeleteTargeHostSets

func (r *Repository) DeleteTargeHostSets(ctx context.Context, targetId string, targetVersion uint32, hostSetIds []string, _ ...Option) (int, error)

DeleteTargeHostSets deletes host sets from a target (targetId). The target's current db version must match the targetVersion or an error will be returned. Zero is not a valid value for the WithVersion option and will return an error.

func (*Repository) DeleteTarget

func (r *Repository) DeleteTarget(ctx context.Context, publicId string, _ ...Option) (int, error)

DeleteTarget will delete a target from the repository.

func (*Repository) ListTargets

func (r *Repository) ListTargets(ctx context.Context, opt ...Option) ([]Target, error)

ListTargets in targets in a scope. Supports the WithScopeId, WithLimit, WithTargetType options.

func (*Repository) LookupTarget

func (r *Repository) LookupTarget(ctx context.Context, publicIdOrName string, opt ...Option) (Target, []*TargetSet, error)

LookupTarget will look up a target in the repository and return the target with its host set ids. If the target is not found, it will return nil, nil, nil. No options are currently supported.

func (*Repository) SetTargetHostSets

func (r *Repository) SetTargetHostSets(ctx context.Context, targetId string, targetVersion uint32, hostSetIds []string, _ ...Option) ([]*TargetSet, int, error)

SetTargetHostSets will set the target's host sets. Set add and/or delete target host sets as need to reconcile the existing sets with the sets requested. If hostSetIds is empty, the target host sets will be cleared. Zero is not a valid value for the WithVersion option and will return an error.

func (*Repository) UpdateTcpTarget

func (r *Repository) UpdateTcpTarget(ctx context.Context, target *TcpTarget, version uint32, fieldMaskPaths []string, _ ...Option) (Target, []*TargetSet, int, error)

UpdateTcpTarget will update a target in the repository and return the written target. fieldMaskPaths provides field_mask.proto paths for fields that should be updated. Fields will be set to NULL if the field is a zero value and included in fieldMask. Name, Description, and WorkerFilter are the only updatable fields. If no updatable fields are included in the fieldMaskPaths, then an error is returned.

type SubType

type SubType int
const (
	UnknownSubtype SubType = iota
	TcpSubType
)

func SubtypeFromId

func SubtypeFromId(id string) SubType

SubtypeFromId takes any public id in the target subsystem and uses the prefix to determine what subtype the id is for. Returns UnknownSubtype if no SubType with this id's prefix is found.

func SubtypeFromType

func SubtypeFromType(t string) SubType

SubtypeFromType converts a string to a SubType. returns UnknownSubtype if no SubType with that name is found.

func (SubType) String

func (t SubType) String() string

type Target

type Target interface {
	GetPublicId() string
	GetScopeId() string
	GetDefaultPort() uint32
	GetName() string
	GetDescription() string
	GetVersion() uint32
	GetType() string
	GetCreateTime() *timestamp.Timestamp
	GetUpdateTime() *timestamp.Timestamp
	GetSessionMaxSeconds() uint32
	GetSessionConnectionLimit() int32
	GetWorkerFilter() string
	// contains filtered or unexported methods
}

Target is a commmon interface for all target subtypes

type TargetHostSet

type TargetHostSet struct {
	*store.TargetHostSet
	// contains filtered or unexported fields
}

func NewTargetHostSet

func NewTargetHostSet(targetId, hostSetId string, _ ...Option) (*TargetHostSet, error)

TargetHostSet creates a new in memory target host set. No options are currently supported.

func (*TargetHostSet) Clone

func (t *TargetHostSet) Clone() interface{}

Clone creates a clone of the target host set

func (*TargetHostSet) SetTableName

func (t *TargetHostSet) SetTableName(n string)

SetTableName sets the tablename and satisfies the ReplayableMessage interface. If the caller attempts to set the name to "" the name will be reset to the default name.

func (*TargetHostSet) TableName

func (t *TargetHostSet) TableName() string

TableName returns the tablename to override the default gorm table name

func (*TargetHostSet) VetForWrite

func (t *TargetHostSet) VetForWrite(_ context.Context, _ db.Reader, opType db.OpType, _ ...db.Option) error

VetForWrite implements db.VetForWrite() interface and validates the target host set before it's written.

type TargetSet

type TargetSet struct {
	*hostStore.Set
}

TargetSet is returned from most repo operations as the target's host set.

func (*TargetSet) TableName

func (ts *TargetSet) TableName() string

TableName returns the tablename to override the default gorm table name

type TargetType

type TargetType uint32

TargetType defines the possible types for targets.

const (
	UnknownTargetType TargetType = 0
	TcpTargetType     TargetType = 1
)

func (TargetType) String

func (t TargetType) String() string

String returns a string representation of the target type.

type TcpTarget

type TcpTarget struct {
	*store.TcpTarget
	// contains filtered or unexported fields
}

func NewTcpTarget

func NewTcpTarget(scopeId string, opt ...Option) (*TcpTarget, error)

NewTcpTarget creates a new in memory tcp target. WithName, WithDescription and WithDefaultPort options are supported

func TestTcpTarget

func TestTcpTarget(t *testing.T, conn *gorm.DB, scopeId, name string, opt ...Option) *TcpTarget

func (*TcpTarget) Clone

func (t *TcpTarget) Clone() interface{}

Clone creates a clone of the TcpTarget

func (TcpTarget) GetType

func (t TcpTarget) GetType() string

func (*TcpTarget) SetTableName

func (t *TcpTarget) SetTableName(n string)

SetTableName sets the tablename and satisfies the ReplayableMessage interface. If the caller attempts to set the name to "" the name will be reset to the default name.

func (*TcpTarget) TableName

func (t *TcpTarget) TableName() string

TableName returns the tablename to override the default gorm table name

func (*TcpTarget) VetForWrite

func (t *TcpTarget) VetForWrite(_ context.Context, _ db.Reader, opType db.OpType, _ ...db.Option) error

VetForWrite implements db.VetForWrite() interface and validates the tcp target before it's written.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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