Documentation ¶
Index ¶
- Constants
- Variables
- func CheckPath(path string) (bool, error)
- func CollectErrors(errs ...error) error
- func Color(colorString string) func(...interface{}) string
- func CopyFile(src, dst string) error
- func CreateDirectory(dirPath string) error
- func ExecCommand(name string, arg ...string) error
- func ExecCommandWReturn(name string, arg ...string) (string, error)
- func FileExists(filename string) bool
- func FileHash(filePath string) (string, error)
- func FileSha256Hash(path string) (fingerprint string, err error)
- func FormatByteCountSI(b int64) string
- func GenerateRandomRFC1919() (string, error)
- func RandomSequence(n int) string
- func ReadFile(path string) (*bytes.Buffer, error)
- func SizeCountToInt(s string) (int64, error)
- func StrSliceIndexOf(slice []string, element string) (index int, err error)
- func StringInSlice(a string, list []string) bool
- func StringSliceSearch(array []string, expression string) ([]int, error)
- func TCPPortStatus(host string, ports []string) error
- func TruncateStringLeft(str string, num int) string
- func TruncateStringRight(str string, num int) string
- func VersionString() string
- func WalkMatch(root, pattern string) ([]string, error)
- type BraveProfile
- type BraveUnit
- type Bravefile
- type ComposeFile
- type ComposeService
- type CopyCommand
- type DiskDevice
- type ImageDescription
- type NicDevice
- type Packages
- type Postdeploy
- type ProxyDevice
- type Resources
- type RunCommand
- type Service
Constants ¶
const ( ComposefileName = "brave-compose.yaml" ComposefileAlias = "brave-compose.yml" )
const BraveCertStore = BraveHome + "/certs"
const BraveClientCert = BraveCertStore + "/client.crt"
BraveClientCert ..
const BraveClientKey = BraveCertStore + "/client.key"
BraveClientKey ..
const BraveDB = BraveHome + "/bravetools.db"
BraveDB path to Bravetools database
const BraveHome = "/.bravetools"
const BraveRemoteStore = BraveHome + "/remotes"
BraveRemoteStore is path to remotes dir
const BraveServerCertStore = BraveHome + "/servercerts"
const BravefileTemplate = `` /* 319-byte string literal not displayed */
Bravefile template
const BravetoolsRemote = "local"
Bravetools local remote name
const BravetoolsVmName = "bravetools"
Name of Bravetools VM if not on Linux
const DefaultUnitCpuLimit = "2"
DefaultUnitCpuLimit - used if not specified
const DefaultUnitRamLimit = "2GB"
DefaultUnitRamLimit - used if not specified
const ImageStore = BraveHome + "/images/"
ImageStore ..
const PlatformConfig = BraveHome + "/config.yml"
PlatformConfig ..
const REINIT = `` /* 179-byte string literal not displayed */
REINIT ..
const REMOVELIN = `` /* 271-byte string literal not displayed */
REMOVELIN ..
const REMOVEMP = `` /* 135-byte string literal not displayed */
REMOVEMP ..
const SnapLXC = "/snap/bin/lxc"
SnapLXC lxc command path in Snap
Variables ¶
var ( // Info .. Info = teal // Warn .. Warn = yellow // Fatal .. Fatal = red )
var Version string
Functions ¶
func CollectErrors ¶
CollectErrors returns the first error encountered or nil if there are none
func CreateDirectory ¶
CreateDirectory creates a directory path if not exists
func ExecCommandWReturn ¶
ExecCommandWReturn ..
func FileExists ¶
FileExists checks if path exists and ensures that it's a file
func FileSha256Hash ¶
func FormatByteCountSI ¶
FormatByteCountSI Returns formatted byte
func GenerateRandomRFC1919 ¶
GenerateRandomRFC1919 generates a random address in 10.x.x.1/24 range
func RandomSequence ¶
RandomSequence generates a random sequence with length n
func SizeCountToInt ¶
SizeCountToInt convert size strings to integer bytes
func StrSliceIndexOf ¶
StrSliceIndexOf returns index of first occurence of element in a str slice or err if not found
func StringInSlice ¶
StringInSlice checks if string is present in a slice
func StringSliceSearch ¶
StringSliceSearch searches a string slice for an expression and returns its indeces
func TCPPortStatus ¶
TCPPortStatus checks if multiple ports are available on the host
func TruncateStringLeft ¶
TruncateStringLeft to specific number of characters fro the left
func TruncateStringRight ¶
TruncateStringRight to specific number of characters fro the right
Types ¶
type BraveProfile ¶
BraveProfile ..
type BraveUnit ¶
type BraveUnit struct { Name string Status string Address string Disk []DiskDevice Proxy []ProxyDevice NIC NicDevice }
BraveUnit ..
type Bravefile ¶
type Bravefile struct { Image string `yaml:"image,omitempty"` Base ImageDescription `yaml:"base,omitempty"` SystemPackages Packages `yaml:"packages,omitempty"` Run []RunCommand `yaml:"run,omitempty"` Copy []CopyCommand `yaml:"copy,omitempty"` PlatformService Service `yaml:"service,omitempty"` }
Bravefile describes unit configuration
func GetBravefileFromGitHub ¶
GetBravefileFromGitHub reads bravefile from a github URL
func (*Bravefile) ValidateBuild ¶
Validate validates Bravefile for build
type ComposeFile ¶
type ComposeFile struct { Path string Services map[string]*ComposeService `yaml:"services"` }
A ComposeFile maps service names to services
func NewComposeFile ¶
func NewComposeFile() *ComposeFile
NewComposeFile returns a pointer to a newly created empty ComposeFile struct
func (*ComposeFile) Load ¶
func (composeFile *ComposeFile) Load(file string) error
Load reads a compose file from disk and loads its settings into the composeFile struct
func (*ComposeFile) TopologicalOrdering ¶
func (composeFile *ComposeFile) TopologicalOrdering() (topologicalOrdering []string, err error)
TopologicalOrdering returns a string array of service names that are ordered so that each service comes after the services it depends on. If a valid ordering cannot be found due to cycles in the graph an error will be returned.
type ComposeService ¶
type ComposeService struct { Service `yaml:",inline"` BravefileBuild *Bravefile Bravefile string `yaml:"bravefile,omitempty"` Build bool `yaml:"build,omitempty"` Base bool `yaml:"base,omitempty"` Context string `yaml:"context,omitempty"` Depends []string `yaml:"depends_on,omitempty"` }
ComposeService defines a service
type CopyCommand ¶
type CopyCommand struct { Source string `yaml:"source,omitempty"` Target string `yaml:"target,omitempty"` Action string `yaml:"action,omitempty"` }
CopyCommand defines source and target for files to be copied into container
type ImageDescription ¶
type ImageDescription struct { Image string `yaml:"image"` Location string `yaml:"location"` Architecture string `yaml:"architecture"` }
ImageDescription defines base image type and source
type Packages ¶
type Packages struct { Manager string `yaml:"manager,omitempty"` System []string `yaml:"system,omitempty"` }
Packages defines system packages to install in container
type Postdeploy ¶
type Postdeploy struct { Run []RunCommand `yaml:"run,omitempty"` Copy []CopyCommand `yaml:"copy,omitempty"` }
Postdeploy defines operations to perform after service deployment finish
type ProxyDevice ¶
ProxyDevice ..
type Resources ¶
type Resources struct { RAM string `yaml:"ram"` CPU string `yaml:"cpu"` GPU string `yaml:"gpu"` Disk string `yaml:"disk"` }
Resources defines resources allocated to service
type RunCommand ¶
type RunCommand struct { Command string `yaml:"command,omitempty"` Content string `yaml:"content,omitempty"` Args []string `yaml:"args,omitempty"` Env map[string]string `yaml:"env,omitempty"` Detach bool `yaml:"detach,omitempty"` }
RunCommand defines custom commands to run inside continer
type Service ¶
type Service struct { Name string `yaml:"name,omitempty"` Image string `yaml:"image,omitempty"` Version string `yaml:"version,omitempty"` Profile string `yaml:"profile,omitempty"` Storage string `yaml:"storage,omitempty"` Network string `yaml:"network,omitempty"` Docker string `yaml:"docker,omitempty"` IP string `yaml:"ip"` Ports []string `yaml:"ports"` Resources Resources `yaml:"resources"` Postdeploy Postdeploy `yaml:"postdeploy,omitempty"` }
Service defines command to install app