drivers

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package drivers implements interface for each driver (resource provider)

Index

Constants

View Source
const (
	StatusNone      = "NONE"
	StatusAllocated = "ALLOCATED"
)

Status of the driver returned by Status()

Variables

FactoryList is a list of available drivers factories

Functions

This section is empty.

Types

type Image added in v0.7.0

type Image struct {
	URL string `json:"url"` // Address of the remote image to download it
	Sum string `json:"sum"` // Optional checksum of the image in format "<algo>:<checksum>"

	Name    string `json:"name"`    // Optional name of the image, if not set will use a part of the Url file name prior to last minus ("-") or ext
	Version string `json:"version"` // Optional version of the image, if not set will use a part of the Url file name after the last minus ("-") to ext

	Tag string `json:"tag"` // Optional identifier used by drivers to make sure the images will be processed properly
}

Image definition

func (*Image) DownloadUnpack added in v0.7.0

func (i *Image) DownloadUnpack(outDir, user, password string) error

DownloadUnpack is a stream function to download and unpack image archive without using a storage file to make it as quick as possible. -> out_dir - is the directory where the image will be placed. It will be unpacked to out_dir/Name-Version/ -> user, password - credentials for HTTP Basic auth

func (*Image) Validate added in v0.7.0

func (i *Image) Validate() error

Validate makes sure the image spec is good enough

type ResourceDriver

type ResourceDriver interface {
	// Name of the driver
	Name() string

	// If the driver uses local node resources or a cloud or remote resources
	// it is used to calculate the slots available for the local drivers
	IsRemote() bool

	// Give driver configs and check if it's ok
	// -> config - driver configuration in json format
	Prepare(config []byte) error

	// Make sure the allocate definition is appropriate for the driver
	// -> def - describes the driver options to allocate the required resource
	ValidateDefinition(def types.LabelDefinition) error

	// Check if the described definition can be running on the current node
	// -> node_usage - how much of node resources was used by all the drivers. Usually should not be used by the cloud drivers
	// -> req - definition describes requirements for the resource
	// <- capacity - the number of such definitions the driver could run, if -1 - error happened
	AvailableCapacity(nodeUsage types.Resources, req types.LabelDefinition) (capacity int64)

	// Allocate the resource by definition and returns hw address
	// -> def - describes the driver options to allocate the required resource
	// -> metadata - user metadata to use during resource allocation
	// <- res - initial resource information to store driver instance state
	Allocate(def types.LabelDefinition, metadata map[string]any) (res *types.Resource, err error)

	// Get the status of the resource with given hw address
	// -> res - resource information with stored driver instance state
	// <- status - current status of the resource
	Status(res *types.Resource) (status string, err error)

	// Get task struct with implementation to execute it later
	// -> task - identifier of the task operation
	// -> options - additional config options for the task
	GetTask(task, options string) ResourceDriverTask

	// Deallocate resource with provided hw addr
	// -> res - resource information with stored driver instance state
	Deallocate(res *types.Resource) error
}

ResourceDriver interface of the functions that connects Fish to each driver

type ResourceDriverFactory added in v0.7.3

type ResourceDriverFactory interface {
	// Name of the driver
	Name() string

	// Generates new resource driver
	NewResourceDriver() ResourceDriver
}

ResourceDriverFactory allows to generate new instances of the drivers

type ResourceDriverTask added in v0.6.0

type ResourceDriverTask interface {
	// Name of the task
	Name() string

	// Copy the existing task structure
	// Will return new not related to the original task structure
	Clone() ResourceDriverTask

	// Fish provides the task information about the operated items
	SetInfo(task *types.ApplicationTask, def *types.LabelDefinition, res *types.Resource)

	// Run the task operation
	// <- result - json data with results of operation
	Execute() (result []byte, err error)
}

ResourceDriverTask is interface for driver tasks execution

Directories

Path Synopsis
Package aws implements driver
Package aws implements driver
Package docker implements driver
Package docker implements driver
Package native implements driver
Package native implements driver
Package test implements mock driver
Package test implements mock driver
Package vmx implements driver
Package vmx implements driver

Jump to

Keyboard shortcuts

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