Documentation ¶
Index ¶
- Constants
- func AddCipherCtxToDev(dev *device.Ctx, cipherCtx *evecommon.CipherContext) *evecommon.CipherContext
- func AddTimestamp(inp string) string
- func AddTimestampf(format string, args ...interface{}) string
- func CompareProtoMessages(m1, m2 proto.Message) (bool, error)
- func CompareSlices[T comparable](lhs, rhs []T) bool
- func CopyFile(src string, dst string) (err error)
- func CopyFileNotExists(src string, dst string) (err error)
- func CopyFolder(source, destination string) error
- func CreateAndRunContainer(containerName string, imageName string, portMap map[string]string, ...) error
- func CreateCipherCtx(cmnCryptoCfg *CommonCryptoConfig) (*evecommon.CipherContext, error)
- func CreateDisk(diskFile, format string, size uint64) error
- func CreateDockerNetwork(name string) error
- func CreateImage(dir, tag, platform string) error
- func CreateTarGz(dstFile string, paths []FileToSave) error
- func CreateUsbNetConfImg(jsonConfigPath, outputImagePath string) error
- func CryptoConfigUnwrapper(cipherBlock *evecommon.CipherBlock, cmnCryptoCfg *CommonCryptoConfig) (*evecommon.EncryptionBlock, error)
- func CryptoConfigWrapper(encBlock *evecommon.EncryptionBlock, cmnCryptoCfg *CommonCryptoConfig, ...) (*evecommon.CipherBlock, error)
- func CurrentDirConfigPath() (string, error)
- func DefaultConfigPath() (string, error)
- func DefaultEdenDir() (string, error)
- func DelEleInSlice(arr interface{}, index int)
- func DelEleInSliceByFunction(arr interface{}, f func(interface{}) bool)
- func DownloadEveInstaller(eve EVEDescription, outputFile string) (err error)
- func DownloadEveLive(eve EVEDescription, outputFile string) (err error)
- func DownloadEveNetBoot(eve EVEDescription, outputDir string) (err error)
- func DownloadEveRootFS(eve EVEDescription, outputDir string) (filePath string, err error)
- func DownloadFile(filepath string, url string) error
- func DownloadUEFI(eve EVEDescription, outputDir string) (err error)
- func ExtractFromImage(imageName, localPath, containerPath string) error
- func ExtractFromTar(u io.Reader, destination string) error
- func FileNameWithoutExtension(fileName string) string
- func FindEleInSlice(slice []string, val string) (int, bool)
- func FindUnusedPort() (uint16, error)
- func GenCARoot() (*x509.Certificate, *rsa.PrivateKey)
- func GenServerCertElliptic(cert *x509.Certificate, key *rsa.PrivateKey, serial *big.Int, ip []net.IP, ...) (*x509.Certificate, *ecdsa.PrivateKey)
- func GenServerCertFromPrevCertAndKey(writePath string) error
- func GenerateConfigFile(filePath string) error
- func GenerateConfigFileDiff(filePath string, context *Context) error
- func GenerateConfigFileFromViper() error
- func GeneratePassword(length int) string
- func GenerateSSHKeyPair(privateKeyFile string, publicKeyFile string) error
- func GenerateStateFile(dirToSave string, state StateObject) error
- func GetConfig(name string) string
- func GetControllerMode(controllerMode string) (modeType, modeURL string, err error)
- func GetDesktopName(address string, password string) (string, error)
- func GetDockerNetworks() ([]*net.IPNet, error)
- func GetFileFollowLinks(filePath string) (string, error)
- func GetFileSize(filePath string) int64
- func GetFileSizeURL(url string) int64
- func GetIPForDockerAccess() (ip string, err error)
- func GetParams(line, regEx string) (paramsMap map[string]string)
- func GetSubnetIPs(subnet string) (result []net.IP)
- func HasImage(image string) (bool, error)
- func IsInputFromPipe() bool
- func LoadCertChain(certPath string, certType certs.ZCertType) ([]*certs.ZCert, error)
- func LoadConfigFile(config string) (loaded bool, err error)
- func LoadConfigFileContext(config string) (loaded bool, err error)
- func LoadRegistry(image, remote string) (string, error)
- func LookUp(i interface{}, path string) (value reflect.Value, err error)
- func LookupWithCallback(inpValue interface{}, inpPath string, callback checkPart)
- func ParseCertificate(certFile string) (*x509.Certificate, error)
- func ParseFirstCertFromBlock(b []byte) (*x509.Certificate, error)
- func ParsePrivateKey(keyFile string) (*rsa.PrivateKey, error)
- func PrepareAuthContainer(payload []byte, signingCertPath, signingKeyPath string) (*auth.AuthContainer, error)
- func PullImage(image string) error
- func PushImage(image, remote string) error
- func ReencryptConfigData(holder CipherDataHolder, oldCryptoConfig, newCryptoConfig *CommonCryptoConfig, ...) error
- func RemoveGeneratedVolumeOfContainer(containerName string) error
- func RenderTemplate(configFile string, tmpl string) (string, error)
- func RepeatableAttempt(client *http.Client, req *http.Request) (response *http.Response, err error)
- func RequestHTTPRepeatWithTimeout(url string, returnEmpty bool, timeoutSeconds time.Duration) (string, error)
- func RequestHTTPWithTimeout(url string, timeoutSeconds time.Duration) (string, error)
- func ResolveAbsPath(curPath string) string
- func ResolveAbsPathWithRoot(rootPath, curPath string) string
- func ResolveHomeDir(filePath string) string
- func ResolveURL(b, p string) (string, error)
- func RunCommandAndWait(name string, args ...string) (stdout string, stderr string, err error)
- func RunCommandBackground(name string, logOutput io.Writer, args ...string) (pid int, err error)
- func RunCommandForeground(name string, args ...string) (err error)
- func RunCommandForegroundWithOpts(name string, args []string, opts ...CommandOpt) (err error)
- func RunCommandNohup(name string, logFile string, pidFile string, args ...string) (err error)
- func RunCommandWithLogAndWait(name string, logLevel log.Level, args ...string) (err error)
- func RunDockerCommand(image string, command string, volumeMap map[string]string) (result string, err error)
- func SHA256SUM(filePath string) string
- func SHA256SUMAll(dir string) (string, error)
- func SaveImage(image string) (io.ReadCloser, error)
- func SaveImageToTar(image, tarFile string) error
- func StartContainer(containerName string) error
- func StateContainer(containerName string) (state string, err error)
- func StatusCommandWithPid(pidFile string) (status string, err error)
- func StopCommandWithPid(pidFile string) (err error)
- func StopContainer(containerName string, remove bool) error
- func TagImage(oldTag, newTag string) error
- func TouchFile(src string) (err error)
- func UnpackTarGz(srcFile string, paths []FileToSave) error
- func Untar(srcFile string, destination string) error
- func UploadFile(client *http.Client, url, filePath, prefix string) (result *http.Response, err error)
- func WriteToFiles(crt *x509.Certificate, key interface{}, certFile string, keyFile string) (err error)
- type CipherDataHolder
- type CommandOpt
- type CommonCryptoConfig
- type ConfigVars
- type Context
- type EVEDescription
- type FileToSave
- type IFInfo
- type QemuSettings
- type QueueWithCapacity
- type RegistryHTTP
- type StateObject
Constants ¶
const MaxDecompressedContentSize = 1024 * 1024 * 1024 // 1 GB
MaxDecompressedContentSize is the maximum size of a file that can be written to disk after decompression. This is to prevent a DoS attack by unpacking a compressed file that is too big to be decompressed.
Variables ¶
This section is empty.
Functions ¶
func AddCipherCtxToDev ¶ added in v1.0.0
func AddCipherCtxToDev(dev *device.Ctx, cipherCtx *evecommon.CipherContext) *evecommon.CipherContext
AddCipherCtxToDev add cipher context to device, unless it already exists. It returns the existing or the added cipher context.
func AddTimestampf ¶ added in v1.0.0
AddTimestampf works like AddTimestamp, but accepts formatting arguments
func CompareProtoMessages ¶
CompareProtoMessages returns true if messages are equal
func CompareSlices ¶ added in v1.0.0
func CompareSlices[T comparable](lhs, rhs []T) bool
CompareSlices compares two slices of comparable types. It returns true if they are equal and false otherwise.
func CopyFileNotExists ¶
CopyFileNotExists copy file from src to dst with same permission if not exists
func CopyFolder ¶
CopyFolder from source to destination
func CreateAndRunContainer ¶
func CreateAndRunContainer(containerName string, imageName string, portMap map[string]string, volumeMap map[string]string, command []string, envs []string) error
CreateAndRunContainer run container with defined name from image with port and volume mapping and defined command
func CreateCipherCtx ¶
func CreateCipherCtx(cmnCryptoCfg *CommonCryptoConfig) (*evecommon.CipherContext, error)
CreateCipherCtx for edge dev config.
func CreateDisk ¶ added in v1.0.0
CreateDisk creates empty disk with defined format on diskFile with size bytes capacity
func CreateDockerNetwork ¶
CreateDockerNetwork create network for docker`s containers
func CreateImage ¶
CreateImage create new image from directory with tag If Dockerfile is inside the directory will use it otherwise will create image from scratch
func CreateTarGz ¶
func CreateTarGz(dstFile string, paths []FileToSave) error
CreateTarGz generates tar.gz file in dstFile by putting files and directories described in paths
func CreateUsbNetConfImg ¶ added in v1.0.0
func CryptoConfigUnwrapper ¶ added in v1.0.0
func CryptoConfigUnwrapper(cipherBlock *evecommon.CipherBlock, cmnCryptoCfg *CommonCryptoConfig) (*evecommon.EncryptionBlock, error)
CryptoConfigUnwrapper reverses the process of CryptoConfigWrapper
func CryptoConfigWrapper ¶
func CryptoConfigWrapper(encBlock *evecommon.EncryptionBlock, cmnCryptoCfg *CommonCryptoConfig, cipherCtx *evecommon.CipherContext) (*evecommon.CipherBlock, error)
CryptoConfigWrapper create cipherCtx and encrypt secrets for all the objects.
func CurrentDirConfigPath ¶
CurrentDirConfigPath returns path to eden-config.yml in current folder
func DefaultConfigPath ¶
DefaultConfigPath returns path to default config
func DefaultEdenDir ¶
DefaultEdenDir returns path to default directory
func DelEleInSlice ¶
func DelEleInSlice(arr interface{}, index int)
DelEleInSlice delete an element from slice by index
- arr: the reference of slice
- index: the index of element will be deleted
func DelEleInSliceByFunction ¶
func DelEleInSliceByFunction(arr interface{}, f func(interface{}) bool)
DelEleInSliceByFunction delete an element from slice by function
- arr: the reference of slice
- f: delete if it returns true on element of slice
func DownloadEveInstaller ¶
func DownloadEveInstaller(eve EVEDescription, outputFile string) (err error)
DownloadEveInstaller pulls EVE installer image from docker
func DownloadEveLive ¶
func DownloadEveLive(eve EVEDescription, outputFile string) (err error)
DownloadEveLive pulls EVE live image from docker
func DownloadEveNetBoot ¶
func DownloadEveNetBoot(eve EVEDescription, outputDir string) (err error)
DownloadEveNetBoot pulls EVE image from docker and prepares files for net boot
func DownloadEveRootFS ¶
func DownloadEveRootFS(eve EVEDescription, outputDir string) (filePath string, err error)
DownloadEveRootFS pulls EVE rootfs image from docker
func DownloadFile ¶
DownloadFile download a url to a local file.
func DownloadUEFI ¶ added in v1.0.0
func DownloadUEFI(eve EVEDescription, outputDir string) (err error)
DownloadUEFI downloads and extracts uefi from EVE-OS image
func ExtractFromImage ¶ added in v1.0.0
ExtractFromImage creates a container from an image, copies a file or directory from it, and then removes the container.
func ExtractFromTar ¶ added in v1.0.0
ExtractFromTar extracts files from a tar reader into the destination directory
func FileNameWithoutExtension ¶
FileNameWithoutExtension trim file extension and path
func FindEleInSlice ¶
FindEleInSlice takes a slice and looks for an element in it. If found it will return it's key, otherwise it will return -1 and a bool of false.
func FindUnusedPort ¶ added in v1.0.0
FindUnusedPort : find port number not currently used by the host.
func GenServerCertElliptic ¶
func GenServerCertElliptic(cert *x509.Certificate, key *rsa.PrivateKey, serial *big.Int, ip []net.IP, dns []string, uuid string) (*x509.Certificate, *ecdsa.PrivateKey)
GenServerCertElliptic elliptic cert
func GenServerCertFromPrevCertAndKey ¶ added in v1.0.0
GenServerCertFromPrevCertAndKey generate new signing certificate for the controller using the same signing key and saves it to give path
func GenerateConfigFile ¶
GenerateConfigFile is a function to generate default yml
func GenerateConfigFileDiff ¶
GenerateConfigFileDiff is a function to generate diff yml for new context
func GenerateConfigFileFromViper ¶
func GenerateConfigFileFromViper() error
GenerateConfigFileFromViper is a function to generate yml from viper config
func GeneratePassword ¶
GeneratePassword returns string with defined length and random characters
func GenerateSSHKeyPair ¶
GenerateSSHKeyPair generates keypair for ssh
func GenerateStateFile ¶
func GenerateStateFile(dirToSave string, state StateObject) error
GenerateStateFile generates state in file
func GetControllerMode ¶ added in v1.0.0
GetControllerMode parse url with controller
func GetDesktopName ¶
GetDesktopName return DesktopName from VNC server address with password (if not empty)
func GetDockerNetworks ¶
GetDockerNetworks returns gateways IPs of networks in docker
func GetFileFollowLinks ¶
GetFileFollowLinks resolve file by walking through symlinks
func GetFileSizeURL ¶
GetFileSizeURL returns file size for url
func GetIPForDockerAccess ¶
GetIPForDockerAccess is service function to obtain IP for adam access The function is filter out docker bridge
func GetSubnetIPs ¶
GetSubnetIPs return all IPs from subnet
func IsInputFromPipe ¶
func IsInputFromPipe() bool
IsInputFromPipe returns true if the command is running from pipe
func LoadCertChain ¶ added in v1.0.0
func LoadConfigFile ¶
LoadConfigFile load config from file with viper
func LoadConfigFileContext ¶
LoadConfigFileContext load config from context file with viper
func LoadRegistry ¶
LoadRegistry push image into registry
func LookupWithCallback ¶
func LookupWithCallback(inpValue interface{}, inpPath string, callback checkPart)
LookupWithCallback travels through inpValue by inpPath and apply callback you can pass [] without index for iterate over loops
func ParseCertificate ¶
func ParseCertificate(certFile string) (*x509.Certificate, error)
ParseCertificate from file
func ParseFirstCertFromBlock ¶
func ParseFirstCertFromBlock(b []byte) (*x509.Certificate, error)
ParseFirstCertFromBlock process provided certificate date
func ParsePrivateKey ¶
func ParsePrivateKey(keyFile string) (*rsa.PrivateKey, error)
ParsePrivateKey from file
func PrepareAuthContainer ¶ added in v1.0.0
func PrepareAuthContainer( payload []byte, signingCertPath, signingKeyPath string) (*auth.AuthContainer, error)
func ReencryptConfigData ¶ added in v1.0.0
func ReencryptConfigData(holder CipherDataHolder, oldCryptoConfig, newCryptoConfig *CommonCryptoConfig, cipherCtx *evecommon.CipherContext) error
ReencryptConfigData re-encrypts config data with new crypto config.
func RemoveGeneratedVolumeOfContainer ¶
RemoveGeneratedVolumeOfContainer remove volumes created by eden
func RenderTemplate ¶
RenderTemplate render Go template with Eden-related fuctions
func RepeatableAttempt ¶
RepeatableAttempt do request several times waiting for nil error and expected status code
func RequestHTTPRepeatWithTimeout ¶
func RequestHTTPRepeatWithTimeout(url string, returnEmpty bool, timeoutSeconds time.Duration) (string, error)
RequestHTTPRepeatWithTimeout make series of requests to url with timeout returnEmpty control if empty string is normal result
func RequestHTTPWithTimeout ¶
RequestHTTPWithTimeout make request to url with timeout
func ResolveAbsPath ¶
ResolveAbsPath use eden.root parameter to resolve path
func ResolveAbsPathWithRoot ¶ added in v1.0.0
ResolveAbsPathWithRoot use rootPath parameter to resolve path
func RunCommandAndWait ¶
RunCommandAndWait run process in foreground
func RunCommandBackground ¶
RunCommandBackground command run in goroutine
func RunCommandForeground ¶
RunCommandForeground command run in foreground
func RunCommandForegroundWithOpts ¶ added in v1.0.0
func RunCommandForegroundWithOpts(name string, args []string, opts ...CommandOpt) (err error)
RunCommandForeground command run in foreground
func RunCommandNohup ¶
RunCommandNohup run process in background
func RunCommandWithLogAndWait ¶
RunCommandWithLogAndWait run process in foreground
func RunDockerCommand ¶
func RunDockerCommand(image string, command string, volumeMap map[string]string) (result string, err error)
RunDockerCommand is run wrapper for docker container
func SHA256SUMAll ¶
SHA256SUMAll calculates sha256 of directory
func SaveImage ¶
func SaveImage(image string) (io.ReadCloser, error)
SaveImage get a reader to save an image
func SaveImageToTar ¶
SaveImageToTar creates tar from image
func StartContainer ¶
StartContainer start container with containerName
func StateContainer ¶
StateContainer return state of container if found or "" state if not found
func StatusCommandWithPid ¶
StatusCommandWithPid check if process with pid from pidFile running
func StopCommandWithPid ¶
StopCommandWithPid sends kill to pid from pidFile
func StopContainer ¶
StopContainer stop container and remove if remove is true
func UnpackTarGz ¶
func UnpackTarGz(srcFile string, paths []FileToSave) error
UnpackTarGz observes tar.gz file in srcFile and extracts files and directories described in paths
func UploadFile ¶
func UploadFile(client *http.Client, url, filePath, prefix string) (result *http.Response, err error)
UploadFile send file in form
func WriteToFiles ¶
func WriteToFiles(crt *x509.Certificate, key interface{}, certFile string, keyFile string) (err error)
WriteToFiles write cert and key
Types ¶
type CipherDataHolder ¶ added in v1.0.0
type CipherDataHolder interface {
GetCipherData() *evecommon.CipherBlock
}
CipherDataHolder is an interface for objects that have CipherData field.
type CommandOpt ¶ added in v1.0.0
CommandOpt allows to modify Cmd config.
func SetCommandEnvVars ¶ added in v1.0.0
func SetCommandEnvVars(vars []string) CommandOpt
SetCommandEnvVars sets the given list of key=value strings as the environment variables for the command.
func SetCommandStdin ¶ added in v1.0.0
func SetCommandStdin(stdin string) CommandOpt
SetCommandStdin sets the given string as the standard input for the command.
type CommonCryptoConfig ¶
type CommonCryptoConfig struct { ControllerEncCertHash []byte DevCertHash []byte SymmetricKey []byte }
CommonCryptoConfig stores information about certificates
func GetCommonCryptoConfig ¶
func GetCommonCryptoConfig(devCert, signCert, controllerKey []byte) (*CommonCryptoConfig, error)
GetCommonCryptoConfig calculate common crypto config and keep it in a structure. Common config are: 1. Calculate sha of controller cert. 2. Calculate sha of device cert. 3. Calculate symmetric key.
type ConfigVars ¶
type ConfigVars struct { AdamIP string AdamPort string AdamDomain string AdamDir string AdamCA string AdamRemote bool AdamCaching bool AdamCachingRedis bool AdamCachingPrefix string AdamRemoteRedis bool AdamRedisURLEden string AdamRedisURLAdam string EveHV string EveSSID string EveUUID string EveName string EveRemote bool EveRemoteAddr string EveQemuPorts map[string]string EveQemuConfig string EveDist string SSHKey string EveCert string EveDeviceCert string EveSerial string ZArch string DevModel string DevModelFIle string EdenBinDir string EdenProg string TestProg string TestScenario string EServerImageDist string EServerPort string EServerIP string RegistryIP string RegistryPort string LogLevel string AdamLogLevel string }
ConfigVars struct with parameters from config file
type Context ¶
Context for use with multiple config files
func ContextInit ¶
ContextInit generates and returns default context
func (*Context) GetCurrentConfig ¶
GetCurrentConfig return path to config file
func (*Context) ListContexts ¶
ListContexts show available contexts
func (*Context) SetContext ¶
SetContext set current contexts
type EVEDescription ¶
type EVEDescription struct { ConfigPath string Arch string Platform string HV string Registry string Tag string Format string ImageSizeMB int }
EVEDescription provides information about EVE to download
func (EVEDescription) Image ¶
func (desc EVEDescription) Image() (string, error)
Image extracts image tag from EVEDescription
func (EVEDescription) Version ¶
func (desc EVEDescription) Version() (string, error)
Version extracts version from EVEDescription
type FileToSave ¶
FileToSave provides pattern to save or load files based on Location and Destination inside fs and tar
type IFInfo ¶
IFInfo stores information about net address and subnet
func GetSubnetsNotUsed ¶
GetSubnetsNotUsed prepare map with subnets and ip not used by any interface of host
type QemuSettings ¶
type QemuSettings struct { DTBDrive string Firmware []string Disks []string MemoryMB int CPUs int USBSerials int USBTablets int }
QemuSettings struct for pass into template
func (QemuSettings) GenerateQemuConfig ¶
func (settings QemuSettings) GenerateQemuConfig() ([]byte, error)
GenerateQemuConfig provides string representation of Qemu config for QemuSettings object
type QueueWithCapacity ¶
type QueueWithCapacity struct {
// contains filtered or unexported fields
}
QueueWithCapacity for represent FIFO queue with defined capacity
func InitQueueWithCapacity ¶
func InitQueueWithCapacity(capacity int) *QueueWithCapacity
InitQueueWithCapacity initialises queue
func (*QueueWithCapacity) Dequeue ¶
func (queue *QueueWithCapacity) Dequeue() (item interface{}, err error)
Dequeue get last element from queue
func (*QueueWithCapacity) Enqueue ¶
func (queue *QueueWithCapacity) Enqueue(item interface{}) error
Enqueue add element into queue if queue is full, it drop last element
type RegistryHTTP ¶
RegistryHTTP for http access to local registry
func NewRegistryHTTP ¶
NewRegistryHTTP creates new RegistryHTTP with plainHTTP resolver