Documentation
¶
Index ¶
- Constants
- func EachMessage[T any](recv recvFunc[T], fn func(*T) error) error
- func EncodeResources(cmd *cli.Command, resources resourcetypes.Resources) (map[string][]byte, error)
- func EnvParser(b []byte) ([]byte, error)
- func ExitCoder(f cli.ActionFunc) cli.ActionFunc
- func GetHostname() string
- func GetNetworks(network string) map[string]string
- func GetSpecFromRemote(ctx context.Context, uri string) ([]byte, error)
- func NewCoreRPCClient(ctx context.Context, cmd *cli.Command) (corepb.CoreRPCClient, error)
- func ParseDeployStrategy(name string) (corepb.DeployOptions_Strategy, error)
- func ParseRAMInHuman(ram string) (int64, error)
- func ReadAllFiles(files []string) (map[string]*types.LinuxFile, error)
- func SplitEquality(elements []string) map[string]string
- func SplitFiles(files []string) map[string]string
- func StorageParams(storageRequest, storageLimit int64, volumesRequest, volumesLimit []string) resourcetypes.RawParams
- func StreamToChan[T any](recv recvFunc[T]) (<-chan *T, func() error)
- func TarDirectory(dir string) ([]byte, error)
- type FileOptions
Constants ¶
const ( ResourceCPUMem = "cpumem" ResourceStorage = "resource-storage" FlagExtraResources = "extra-resources" )
Variables ¶
This section is empty.
Functions ¶
func EachMessage ¶
func EncodeResources ¶
func EncodeResources(cmd *cli.Command, resources resourcetypes.Resources) (map[string][]byte, error)
EncodeResources encodes plugin params for the core rpc; --extra-resources fills only the plugins not already present.
func ExitCoder ¶
func ExitCoder(f cli.ActionFunc) cli.ActionFunc
ExitCoder turns an action error into a cli.ExitCoder.
func GetHostname ¶
func GetHostname() string
GetHostname returns the local hostname, empty when it cannot be read.
func GetNetworks ¶
GetNetworks returns a networkmode -> ip map.
func GetSpecFromRemote ¶
GetSpecFromRemote fetches a spec over HTTP.
func NewCoreRPCClient ¶
NewCoreRPCClient dials the core address in cmd and returns its RPC client.
func ParseDeployStrategy ¶
func ParseDeployStrategy(name string) (corepb.DeployOptions_Strategy, error)
ParseDeployStrategy maps a --deploy-strategy value onto the core enum.
func ParseRAMInHuman ¶
ParseRAMInHuman converts a human readable size such as 100KB into bytes.
func ReadAllFiles ¶
ReadAllFiles reads srcfile:dstfile[:mode[:uid:gid]] pairs into a dstfile keyed map.
func SplitEquality ¶
SplitEquality turns a list of key=value strings into a map.
func SplitFiles ¶
SplitFiles turns a list of src:dst strings into a map.
func StorageParams ¶ added in v0.1.2
func StorageParams(storageRequest, storageLimit int64, volumesRequest, volumesLimit []string) resourcetypes.RawParams
StorageParams builds the storage plugin request; zero values stay out, so an untouched entry defers to --extra-resources.
func StreamToChan ¶
StreamToChan returns a wait func that reports the recv error once the channel is drained.
func TarDirectory ¶ added in v0.1.1
TarDirectory packs dir into an uncompressed tar whose entry names are relative to dir.
Types ¶
type FileOptions ¶
type FileOptions struct {
Data map[string][]byte
Modes map[string]*corepb.FileMode
Owners map[string]*corepb.FileOwner
}
FileOptions carries the --file pairs in the shape the core rpc expects.
func GenerateFileOptions ¶
func GenerateFileOptions(cmd *cli.Command) (*FileOptions, error)