knuu

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: Apache-2.0 Imports: 10 Imported by: 8

Documentation

Overview

Package knuu provides the core functionality of knuu.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Identifier added in v0.4.0

func Identifier() string

Identifier returns the identifier of the current knuu instance

func Initialize

func Initialize() error

Initialize initializes knuu Deprecated: Use InitializeWithIdentifier instead

func InitializeWithIdentifier added in v0.4.0

func InitializeWithIdentifier(uniqueIdentifier string) error

InitializeWithIdentifier initializes knuu with a unique identifier

Types

type Executor

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

func NewExecutor

func NewExecutor() (*Executor, error)

func (*Executor) Destroy

func (e *Executor) Destroy() error

func (*Executor) ExecuteCommand

func (e *Executor) ExecuteCommand(command ...string) (string, error)

type Instance

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

Instance represents a instance

func NewInstance

func NewInstance(name string) (*Instance, error)

NewInstance creates a new instance of the Instance struct

func (*Instance) AddFile

func (i *Instance) AddFile(src string, dest string, chown string) error

AddFile adds a file to the instance This function can only be called in the state 'Preparing'

func (*Instance) AddFileBytes

func (i *Instance) AddFileBytes(bytes []byte, dest string, chown string) error

AddFileBytes adds a file with the given content to the instance This function can only be called in the state 'Preparing'

func (*Instance) AddPortTCP

func (i *Instance) AddPortTCP(port int) error

AddPortTCP adds a TCP port to the instance This function can be called in the states 'Preparing' and 'Committed'

func (*Instance) AddPortUDP

func (i *Instance) AddPortUDP(port int) error

AddPortUDP adds a UDP port to the instance This function can be called in the states 'Preparing' and 'Committed'

func (*Instance) AddVolume

func (i *Instance) AddVolume(name string, size string) error

AddVolume adds a volume to the instance This function can only be called in the states 'Preparing' and 'Committed'

func (*Instance) Clone added in v0.3.0

func (i *Instance) Clone() (*Instance, error)

func (*Instance) Commit

func (i *Instance) Commit() error

Commit commits the instance This function can only be called in the state 'Preparing'

func (*Instance) CreatePool

func (i *Instance) CreatePool(amount int) (*InstancePool, error)

CreatePool creates a pool of instances This function can only be called in the state 'Committed'

func (*Instance) Destroy

func (i *Instance) Destroy() error

Destroy destroys the instance This function can only be called in the state 'Started' or 'Destroyed'

func (*Instance) ExecuteCommand

func (i *Instance) ExecuteCommand(command ...string) (string, error)

ExecuteCommand executes the given command in the instance This function can only be called in the states 'Preparing' and 'Started'

func (*Instance) GetFileBytes

func (i *Instance) GetFileBytes(file string) ([]byte, error)

GetFileBytes returns the content of the given file This function can only be called in the states 'Preparing' and 'Committed'

func (*Instance) GetIP

func (i *Instance) GetIP() (string, error)

GetIP returns the IP of the instance This function can only be called in the states 'Preparing' and 'Started'

func (*Instance) IsInState

func (i *Instance) IsInState(states ...InstanceState) bool

IsInState checks if the instance is in one of the provided states

func (*Instance) SetArgs

func (i *Instance) SetArgs(args ...string) error

SetArgs sets the arguments passed to the instance This function can only be called in the states 'Preparing' or 'Committed'

func (*Instance) SetCPU added in v0.4.0

func (i *Instance) SetCPU(request string) error

SetCPU sets the CPU of the instance This function can only be called in the states 'Preparing' and 'Committed'

func (*Instance) SetCommand

func (i *Instance) SetCommand(command []string) error

SetCommand sets the command to run in the instance This function can only be called when the instance is in state 'Preparing' or 'Committed'

func (*Instance) SetEnvironmentVariable

func (i *Instance) SetEnvironmentVariable(key string, value string) error

SetEnvironmentVariable sets the given environment variable in the instance This function can only be called in the states 'Preparing' and 'Committed'

func (*Instance) SetImage

func (i *Instance) SetImage(image string) error

SetImage sets the image of the instance. It is only allowed in the 'None' and 'Started' states.

func (*Instance) SetMemory added in v0.4.0

func (i *Instance) SetMemory(request string, limit string) error

SetMemory sets the memory of the instance This function can only be called in the states 'Preparing' and 'Committed'

func (*Instance) Start

func (i *Instance) Start() error

Start starts the instance This function can only be called in the state 'Committed'

func (*Instance) WaitInstanceIsRunning

func (i *Instance) WaitInstanceIsRunning() error

WaitInstanceIsRunning waits until the instance is running This function can only be called in the state 'Started'

type InstancePool

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

InstancePool is a struct that represents a pool of instances

func (*InstancePool) Destroy

func (i *InstancePool) Destroy() error

Destroy destroys all instances in the instance pool

func (*InstancePool) Instances

func (i *InstancePool) Instances() []*Instance

Instances returns the instances in the instance pool

func (*InstancePool) Start

func (i *InstancePool) Start() error

Start starts all instances in the instance pool

func (*InstancePool) WaitInstancePoolIsRunning

func (i *InstancePool) WaitInstancePoolIsRunning() error

WaitInstancePoolIsRunning waits until all instances in the instance pool are running

type InstanceState added in v0.3.0

type InstanceState int

InstanceState represents the state of the instance

const (
	None InstanceState = iota
	Preparing
	Committed
	Started
	Destroyed
)

Possible states of the instance

func (InstanceState) String added in v0.3.0

func (s InstanceState) String() string

String returns the string representation of the state

Jump to

Keyboard shortcuts

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