sdk

package
v0.0.0-...-fb044b6 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Added   = Change(1)
	Removed = Change(2)
	Changed = Change(3)
)
View Source
const LOCK_FILE = ".lock"

Variables

This section is empty.

Functions

func ConfigureDelegateLogging

func ConfigureDelegateLogging(verbosity int)

func CreateUserSystemdFile

func CreateUserSystemdFile(name string, log commonlog.Logger) (*os.File, error)

func EnableUserSystemd

func EnableUserSystemd(name string, log commonlog.Logger) error

func GRPCAborted

func GRPCAborted(err error) error

func GRPCAbortedf

func GRPCAbortedf(format string, args ...any) error

func Interact

func Interact(server GRPCInteractor, interact map[string]InteractFunc) error

func InteractRelay

func InteractRelay(server GRPCInteractor, client GRPCInteractor, start *api.Interaction_Start, log commonlog.Logger) error

func InteractionErrorDetails

func InteractionErrorDetails(err error) *api.InteractionErrorDetails

func NewCommand

func NewCommand(start *api.Interaction_Start, log commonlog.Logger) *exec.Command

func ScheduleHost

func ScheduleHost(capability ard.Value, host string) bool

func ScheduleIPPort

func ScheduleIPPort(relationship ard.Value, ip string, port int64) bool

func StartCommand

func StartCommand(command *exec.Command, server GRPCInteractor, log commonlog.Logger) error

func UnpackGRPCError

func UnpackGRPCError(err error) error

Types

type Capability

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

func (*Capability) Find

func (self *Capability) Find(clout *cloutpkg.Clout) (*cloutpkg.Vertex, ard.Value, error)

type Change

type Change int

func (Change) String

func (self Change) String() string

fmt.Stringer interface

type Connection

type Connection struct {
	Relationship

	Name   string
	IP     string
	Port   int64
	Source *OCIContainer
	Target *OCIContainer
}

func GetCloutConnections

func GetCloutConnections(clout *cloutpkg.Clout) ([]*Connection, error)

func GetConnection

func GetConnection(vertex *cloutpkg.Vertex, edgesOutIndex int, edge *cloutpkg.Edge) (*Connection, error)

func GetVertexConnections

func GetVertexConnections(vertex *cloutpkg.Vertex) ([]*Connection, error)

type Dir

type Dir []string

func NewDir

func NewDir(path string) Dir

func (Dir) Equals

func (self Dir) Equals(dir Dir) bool

func (Dir) Identifier

func (self Dir) Identifier() ([]string, bool)

func (Dir) String

func (self Dir) String() string

fmt.Stringer interface

type GRPCInteractor

type GRPCInteractor interface {
	Send(*api.Interaction) error
	Recv() (*api.Interaction, error)
}

Both api.Agent_InteractServer and api.Agent_InteractClient

type Host

type Host struct {
	Address string `yaml:"address"`
}

type InteractFunc

type InteractFunc func(start *api.Interaction_Start) error

type LockedReadCloser

type LockedReadCloser struct {
	ReadCloser io.ReadCloser
	Lock       fslock.Handle
}

func (*LockedReadCloser) Close

func (self *LockedReadCloser) Close() error

io.Closer interface

func (*LockedReadCloser) Read

func (self *LockedReadCloser) Read(p []byte) (n int, err error)

io.Reader interface

type LockedWriteCloser

type LockedWriteCloser struct {
	WriteCloser io.WriteCloser
	Lock        fslock.Handle
}

func (*LockedWriteCloser) Close

func (self *LockedWriteCloser) Close() error

io.Closer interface

func (*LockedWriteCloser) Write

func (self *LockedWriteCloser) Write(p []byte) (n int, err error)

io.Writer interface

type OCIContainer

type OCIContainer struct {
	Capability

	Host            string
	Name            string
	Reference       string
	CreateArguments []string
	Ports           []OCIMappedPort
}

func GetCloutOCIContainers

func GetCloutOCIContainers(clout *cloutpkg.Clout) ([]*OCIContainer, error)

func GetOCIContainer

func GetOCIContainer(vertex *cloutpkg.Vertex, capability ard.Value, instanceName string, capabilityName string) (*OCIContainer, error)

func GetVertexOCIContainers

func GetVertexOCIContainers(vertex *cloutpkg.Vertex) ([]*OCIContainer, error)

type OCIImageReference

type OCIImageReference struct {
	Artifact string `ard:"artifact"`

	Reference string `ard:"reference"`

	Host  string `ard:"host"`
	Image string `ard:"image"`
	Tag   string `ard:"tag"`

	Port            int64  `ard:"port"`
	Repository      string `ard:"repository"`
	DigestAlgorithm string `ard:"digest-algorithm"`
	DigestHex       string `ard:"digest-hex"`
}

func (OCIImageReference) String

func (self OCIImageReference) String() string

fmt.Stringer interface

func (OCIImageReference) Validate

func (self OCIImageReference) Validate() error

type OCIMappedPort

type OCIMappedPort struct {
	Address  string
	External int64
	Internal int64
	Protocol string
}

func GetOCIContainerMappedPorts

func GetOCIContainerMappedPorts(capability ard.Value) ([]OCIMappedPort, error)

type OnChangedFunc

type OnChangedFunc func(change Change, identifier []string)

type PackageFile

type PackageFile struct {
	Path       string
	Executable bool
}

type PackageIdentifier

type PackageIdentifier struct {
	Namespace string `json:"namespace" yaml:"namespace"`
	Type      string `json:"type" yaml:"type"`
	Name      string `json:"name" yaml:"name"`
}

type PackageIdentifiers

type PackageIdentifiers []PackageIdentifier

func (PackageIdentifiers) Len

func (self PackageIdentifiers) Len() int

sort.Interface interface

func (PackageIdentifiers) Less

func (self PackageIdentifiers) Less(i, j int) bool

sort.Interface interface

func (PackageIdentifiers) Swap

func (self PackageIdentifiers) Swap(i, j int)

sort.Interface interface

type Process

type Process struct {
	Capability

	Host      string
	Name      string
	Command   string
	Arguments []string
}

func GetCloutProcesses

func GetCloutProcesses(clout *cloutpkg.Clout) ([]*Process, error)

func GetProcesses

func GetProcesses(vertex *cloutpkg.Vertex, capabilityName string, capability ard.Value) ([]*Process, error)

func GetVertexProcesses

func GetVertexProcesses(vertex *cloutpkg.Vertex) ([]*Process, error)

type Relationship

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

func (*Relationship) Find

func (self *Relationship) Find(clout *cloutpkg.Clout) (*cloutpkg.Edge, error)

type State

type State struct {
	RootDir string
}

func NewState

func NewState(rootDir string) *State

func (*State) CreatePackageFile

func (self *State) CreatePackageFile(namespace string, type_ string, name string, path string) (io.WriteCloser, error)

func (*State) DeletePackage

func (self *State) DeletePackage(namespace string, type_ string, name string) error

func (*State) GetHost

func (self *State) GetHost(name string) (*Host, error)

func (*State) GetNamespaceDir

func (self *State) GetNamespaceDir(namespace string) string

func (*State) GetPackageDir

func (self *State) GetPackageDir(namespace string, type_ string, name string) string

func (*State) GetPackageMainFile

func (self *State) GetPackageMainFile(namespace string, type_ string, name string) string

func (*State) GetPackageTypeDir

func (self *State) GetPackageTypeDir(namespace string, type_ string) string

func (*State) ListNamespaces

func (self *State) ListNamespaces() ([]string, error)

func (*State) ListNamespacesFor

func (self *State) ListNamespacesFor(namespace string) ([]string, error)

func (*State) ListPackageFiles

func (self *State) ListPackageFiles(namespace string, type_ string, name string) ([]PackageFile, error)

func (*State) ListPackages

func (self *State) ListPackages(namespace string, type_ string) (PackageIdentifiers, error)

func (*State) LockAndCreatePackageFile

func (self *State) LockAndCreatePackageFile(namespace string, type_ string, name string, path string) (*LockedWriteCloser, error)

func (*State) LockAndOpenPackageFile

func (self *State) LockAndOpenPackageFile(namespace string, type_ string, name string, path string) (*LockedReadCloser, error)

func (*State) LockPackage

func (self *State) LockPackage(namespace string, type_ string, name string, create bool) (fslock.Handle, error)

func (*State) OpenPackageFile

func (self *State) OpenPackageFile(namespace string, type_ string, name string, path string) (io.ReadCloser, error)

func (*State) OpenServiceClout

func (self *State) OpenServiceClout(context contextpkg.Context, namespace string, serviceName string, urlContext *exturl.Context) (fslock.Handle, *cloutpkg.Clout, error)

func (*State) SaveServiceClout

func (self *State) SaveServiceClout(serviceNamespace string, serviceName string, clout *cloutpkg.Clout) error

func (*State) SetHost

func (self *State) SetHost(name string, host *Host) error

type Watcher

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

func NewWatcher

func NewWatcher(state *State, onChanged OnChangedFunc) (*Watcher, error)

func (*Watcher) Start

func (self *Watcher) Start()

func (*Watcher) Stop

func (self *Watcher) Stop() error

Jump to

Keyboard shortcuts

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