ops: github.com/nanovms/ops/lepton Index | Files

package lepton

import "github.com/nanovms/ops/lepton"

Index

Package Files

aws.go config.go const.go download.go gcp.go gcpstore.go homedir.go hv_support_linux.go hypervisor.go image.go ldd_linux.go manifest.go onprem.go package.go provider.go qemu.go s3.go update.go

Constants

const (
    // WarningColor used in warning texts
    WarningColor = "\033[1;33m%s\033[0m"
    // ErrorColor used in error texts
    ErrorColor = "\033[1;31m%s\033[0m"
)
const GCPStorageURL string = "https://storage.googleapis.com/%v/%v"

GCPStorageURL is GCP storage path

const OpsReleaseURL = "https://storage.googleapis.com/cli/%v/ops"

OpsReleaseURL gives URL to download latest ops binary

const PackageBaseURL string = "https://storage.googleapis.com/packagehub/%v"

PackageBaseURL gives URL for downloading of packages

const PackageManifestFileName string = "manifest.json"

PackageManifestFileName is manifest file path

const PackageManifestURL string = "https://storage.googleapis.com/packagehub/manifest.json"

PackageManifestURL stores info about all packages

const Version = "0.1.7"

Version for ops

Variables

var LatestReleaseVersion = getLatestRelVersion()

LatestReleaseVersion give latest stable release for nanos

var LocalReleaseVersion = getLocalRelVersion()

LocalReleaseVersion is version latest release downloaded in ops home

var NightlyLocalFolder = nightlyLocalFolder()

NightlyLocalFolder is directory path where nightly builds are stored

var NightlyReleaseURL = nightlyReleaseURL()

NightlyReleaseURL give URL for nightly build

var PackagesCache = getPackageCache()

PackagesCache where all packages are stored

func Apply Uses

func Apply(update io.Reader, opts Options) error

Apply performs an update of the current executable (or opts.TargetFile, if set) with the contents of the given io.Reader.

Apply performs the following actions to ensure a safe cross-platform update:

1. If configured, applies the contents of the update io.Reader as a binary patch.

2. If configured, computes the checksum of the new executable and verifies it matches.

3. If configured, verifies the signature with a public key.

4. Creates a new file, /path/to/.target.new with the TargetMode with the contents of the updated file

5. Renames /path/to/target to /path/to/.target.old

6. Renames /path/to/.target.new to /path/to/target

7. If the final rename is successful, deletes /path/to/.target.old, returns no error. On Windows, the removal of /path/to/target.old always fails, so instead Apply hides the old file instead.

8. If the final rename fails, attempts to roll back by renaming /path/to/.target.old back to /path/to/target.

func BuildImage Uses

func BuildImage(c Config) error

BuildImage builds a unikernel image for user supplied ELF binary.

func BuildImageFromPackage Uses

func BuildImageFromPackage(packagepath string, c Config) error

BuildImageFromPackage builds nanos image using a package

func DoUpdate Uses

func DoUpdate(url string) error

DoUpdate updates file using provided URL

func DownloadFile Uses

func DownloadFile(filepath string, url string, timeout int) error

DownloadFile downloads file using URL

func DownloadNightlyImages Uses

func DownloadNightlyImages(c *Config) error

DownloadNightlyImages downloads nightly build for nanos

func DownloadPackage Uses

func DownloadPackage(name string) (string, error)

DownloadPackage downloads package by name

func DownloadReleaseImages Uses

func DownloadReleaseImages(version string) error

DownloadReleaseImages downloads nanos for particular release version

func Expand Uses

func Expand(path string) (string, error)

Expand expands the path to include the home directory if the path is prefixed with `~`. If it isn't prefixed with `~`, the path is returned as-is.

func ExtractPackage Uses

func ExtractPackage(archive string, dest string)

ExtractPackage extracts package in ops home

func GenerateImageName Uses

func GenerateImageName(program string) string

GenerateImageName generate image name

func GetOpsHome Uses

func GetOpsHome() string

GetOpsHome get ops directory path We store all ops related info, packages, images in this directory

func GetPackageList Uses

func GetPackageList() *map[string]Package

GetPackageList provides list of packages

func GetPackageManifestFile Uses

func GetPackageManifestFile() string

GetPackageManifestFile give path for package manifest file

func HomeDir Uses

func HomeDir() (string, error)

HomeDir from https://github.com/mitchellh/go-homedir Dir returns the home directory for the executing user. This uses an OS-specific method for discovering the home directory. An error is returned if a home directory cannot be detected.

func LocalTimeStamp Uses

func LocalTimeStamp() (string, error)

LocalTimeStamp gives local timestamp from download nightly build

func PackageManifestChanged Uses

func PackageManifestChanged(fino os.FileInfo, remoteURL string) bool

PackageManifestChanged verifies if package manifest changed

func RemoteTimeStamp Uses

func RemoteTimeStamp() (string, error)

RemoteTimeStamp gives latest nightly build timestamp

func RollbackError Uses

func RollbackError(err error) error

RollbackError takes an error value returned by Apply and returns the error, if any, that occurred when attempting to roll back from a failed update. Applications should always call this function on any non-nil errors returned by Apply.

If no rollback was needed or if the rollback was successful, RollbackError returns nil, otherwise it returns the error encountered when trying to roll back.

type AWS Uses

type AWS struct {
    Storage *S3
}

AWS contains all operations for AWS

func (*AWS) BuildImage Uses

func (p *AWS) BuildImage(ctx *Context) (string, error)

BuildImage to be upload on AWS

func (*AWS) BuildImageWithPackage Uses

func (p *AWS) BuildImageWithPackage(ctx *Context, pkgpath string) (string, error)

BuildImageWithPackage to upload on AWS

func (*AWS) CreateImage Uses

func (p *AWS) CreateImage(ctx *Context) error

CreateImage - Creates image on AWS using nanos images TODO : re-use and cache DefaultClient and instances.

func (*AWS) CreateInstance Uses

func (p *AWS) CreateInstance(ctx *Context) error

CreateInstance - Creates instance on AWS Platform

func (*AWS) CreateSG Uses

func (p *AWS) CreateSG(ctx *Context, svc *ec2.EC2, imgName string) (string, error)

CreateSG - Create security group for now just use default vpc

func (*AWS) DeleteImage Uses

func (p *AWS) DeleteImage(ctx *Context, imagename string) error

DeleteImage deletes image from AWS by ami name

func (*AWS) DeleteInstance Uses

func (p *AWS) DeleteInstance(ctx *Context, instancename string) error

DeleteInstance deletes instnace from AWS

func (*AWS) GetInstanceLogs Uses

func (p *AWS) GetInstanceLogs(ctx *Context, instancename string, watch bool) error

GetInstanceLogs gets instance related logs

func (*AWS) Initialize Uses

func (p *AWS) Initialize() error

Initialize AWS related things

func (*AWS) ListImages Uses

func (p *AWS) ListImages(ctx *Context) error

ListImages lists images on AWS

func (*AWS) ListInstances Uses

func (p *AWS) ListInstances(ctx *Context) error

ListInstances lists instances on AWS

type Config Uses

type Config struct {
    Args         []string
    Dirs         []string
    Files        []string
    MapDirs      map[string]string
    Env          map[string]string
    Debugflags   []string
    NoTrace      []string
    Program      string
    Version      string
    Boot         string
    Kernel       string
    Mkfs         string
    NameServer   string
    NightlyBuild bool
    RunConfig    RunConfig
    CloudConfig  ProviderConfig
    Force        bool
    TargetRoot   string
    ManifestName string // save manifest to
}

Config for Build

type Context Uses

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

Context captures required info for provider operation

func NewContext Uses

func NewContext(c *Config, provider *Provider) *Context

NewContext Create a new context for the given provider valid providers are "gcp", "aws" and "onprem"

type GCPStorage Uses

type GCPStorage struct{}

GCPStorage provides GCP storage related operations

func (*GCPStorage) CopyToBucket Uses

func (s *GCPStorage) CopyToBucket(config *Config, archPath string) error

CopyToBucket copies archive to bucket

type GCloud Uses

type GCloud struct {
    Storage *GCPStorage
}

GCloud contains all operations for GCP

func (*GCloud) BuildImage Uses

func (p *GCloud) BuildImage(ctx *Context) (string, error)

BuildImage to be upload on GCP

func (*GCloud) BuildImageWithPackage Uses

func (p *GCloud) BuildImageWithPackage(ctx *Context, pkgpath string) (string, error)

BuildImageWithPackage to upload on GCP

func (*GCloud) CreateImage Uses

func (p *GCloud) CreateImage(ctx *Context) error

CreateImage - Creates image on GCP using nanos images TODO : re-use and cache DefaultClient and instances.

func (*GCloud) CreateInstance Uses

func (p *GCloud) CreateInstance(ctx *Context) error

CreateInstance - Creates instance on Google Cloud Platform

func (*GCloud) DeleteImage Uses

func (p *GCloud) DeleteImage(ctx *Context, imagename string) error

DeleteImage deletes image from Gcloud

func (*GCloud) DeleteInstance Uses

func (p *GCloud) DeleteInstance(ctx *Context, instancename string) error

DeleteInstance deletes instnace from Gcloud

func (*GCloud) GetInstanceLogs Uses

func (p *GCloud) GetInstanceLogs(ctx *Context, instancename string, watch bool) error

GetInstanceLogs gets instance related logs

func (*GCloud) Initialize Uses

func (p *GCloud) Initialize() error

Initialize GCP related things

func (*GCloud) ListImages Uses

func (p *GCloud) ListImages(ctx *Context) error

ListImages lists images on Google Cloud

func (*GCloud) ListInstances Uses

func (p *GCloud) ListInstances(ctx *Context) error

ListInstances lists instances on Gcloud

type GCloudOperation Uses

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

GCloudOperation status check

type Hypervisor Uses

type Hypervisor interface {
    Start(rconfig *RunConfig) error
    Command(rconfig *RunConfig) *exec.Cmd
    Stop()
}

Hypervisor interface

func HypervisorInstance Uses

func HypervisorInstance() Hypervisor

HypervisorInstance provides available hypervisor

type Manifest Uses

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

Manifest represent the filesystem.

func BuildManifest Uses

func BuildManifest(c *Config) (*Manifest, error)

BuildManifest builds manifest using config

func BuildPackageManifest Uses

func BuildPackageManifest(packagepath string, c *Config) (*Manifest, error)

BuildPackageManifest builds manifest using package

func NewManifest Uses

func NewManifest(targetRoot string) *Manifest

NewManifest init

func (*Manifest) AddArgument Uses

func (m *Manifest) AddArgument(arg string)

AddArgument add commandline arguments to user program

func (*Manifest) AddDebugFlag Uses

func (m *Manifest) AddDebugFlag(name string, value rune)

AddDebugFlag enables debug flags

func (*Manifest) AddDirectory Uses

func (m *Manifest) AddDirectory(dir string) error

AddDirectory adds all files in dir to image

func (*Manifest) AddEnvironmentVariable Uses

func (m *Manifest) AddEnvironmentVariable(name string, value string)

AddEnvironmentVariable adds environment variables

func (*Manifest) AddFile Uses

func (m *Manifest) AddFile(filepath string, hostpath string) error

AddFile to add a file to manifest

func (*Manifest) AddKernel Uses

func (m *Manifest) AddKernel(path string)

AddKernel the kernel to use

func (*Manifest) AddLibrary Uses

func (m *Manifest) AddLibrary(path string)

AddLibrary to add a dependent library

func (*Manifest) AddNoTrace Uses

func (m *Manifest) AddNoTrace(name string)

AddNoTrace enables debug flags

func (*Manifest) AddRelative Uses

func (m *Manifest) AddRelative(key string, path string)

AddRelative path

func (*Manifest) AddUserData Uses

func (m *Manifest) AddUserData(dir string)

AddUserData adds all files in dir to final image.

func (*Manifest) AddUserProgram Uses

func (m *Manifest) AddUserProgram(imgpath string)

AddUserProgram adds user program

func (*Manifest) FileExists Uses

func (m *Manifest) FileExists(filepath string) bool

FileExists checks if file is present at path in manifest

func (*Manifest) String Uses

func (m *Manifest) String() string

type OnPrem Uses

type OnPrem struct{}

OnPrem provider for ops

func (*OnPrem) BuildImage Uses

func (p *OnPrem) BuildImage(ctx *Context) (string, error)

BuildImage for onprem

func (*OnPrem) BuildImageWithPackage Uses

func (p *OnPrem) BuildImageWithPackage(ctx *Context, pkgpath string) (string, error)

BuildImageWithPackage for onprem

func (*OnPrem) CreateImage Uses

func (p *OnPrem) CreateImage(ctx *Context) error

CreateImage on prem

func (*OnPrem) CreateInstance Uses

func (p *OnPrem) CreateInstance(ctx *Context) error

CreateInstance on premise

func (*OnPrem) DeleteImage Uses

func (p *OnPrem) DeleteImage(ctx *Context, imagename string) error

DeleteImage on premise

func (*OnPrem) DeleteInstance Uses

func (p *OnPrem) DeleteInstance(ctx *Context, instancename string) error

DeleteInstance from on premise

func (*OnPrem) GetInstanceLogs Uses

func (p *OnPrem) GetInstanceLogs(ctx *Context, instancename string, watch bool) error

GetInstanceLogs for onprem instance logs

func (*OnPrem) Initialize Uses

func (p *OnPrem) Initialize() error

Initialize on prem provider

func (*OnPrem) ListImages Uses

func (p *OnPrem) ListImages(ctx *Context) error

ListImages on premise

func (*OnPrem) ListInstances Uses

func (p *OnPrem) ListInstances(ctx *Context) error

ListInstances on premise

type Options Uses

type Options struct {
    // TargetPath defines the path to the file to update.
    // The emptry string means 'the executable file of the running program'.
    TargetPath string

    // Create TargetPath replacement with this file mode. If zero, defaults to 0755.
    TargetMode os.FileMode

    // Checksum of the new binary to verify against. If nil, no checksum or signature verification is done.
    Checksum []byte

    // Public key to use for signature verification. If nil, no signature verification is done.
    PublicKey crypto.PublicKey

    // Signature to verify the updated file. If nil, no signature verification is done.
    Signature []byte

    // Use this hash function to generate the checksum. If not set, SHA256 is used.
    Hash crypto.Hash

    // Store the old executable file at this path after a successful update.
    // The empty string means the old executable file will be removed after the update.
    OldSavePath string
}

Options for binary update

func (*Options) CheckPermissions Uses

func (o *Options) CheckPermissions() error

CheckPermissions determines whether the process has the correct permissions to perform the requested update. If the update can proceed, it returns nil, otherwise it returns the error that would occur if an update were attempted.

func (*Options) SetPublicKeyPEM Uses

func (o *Options) SetPublicKeyPEM(pembytes []byte) error

SetPublicKeyPEM is a convenience method to set the PublicKey property used for checking a completed update's signature by parsing a Public Key formatted as PEM data.

type Package Uses

type Package struct {
    Runtime     string `json:"runtime"`
    Version     string `json:"version"`
    Language    string `json:"language"`
    Description string `json:"description,omitempty"`
    MD5         string `json:"md5,omitempty"`
}

Package is the definition of an OPS package.

type PackageList Uses

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

PackageList contains a list of known packages.

type Provider Uses

type Provider interface {
    Initialize() error
    BuildImage(ctx *Context) (string, error)
    BuildImageWithPackage(ctx *Context, pkgpath string) (string, error)
    CreateImage(ctx *Context) error
    ListImages(ctx *Context) error
    DeleteImage(ctx *Context, imagename string) error
    CreateInstance(ctx *Context) error
    ListInstances(ctx *Context) error
    DeleteInstance(ctx *Context, instancename string) error
    GetInstanceLogs(ctx *Context, instancename string, watch bool) error
}

Provider is an interface that provider must implement

type ProviderConfig Uses

type ProviderConfig struct {
    Platform   string `cloud:"platfom"`
    ProjectID  string `cloud:"projectid"`
    Zone       string `cloud:"zone"`
    BucketName string `cloud:"bucketname"`
    ImageName  string `cloud:"imagename"`
    Flavor     string `cloud:"flavor"`
}

ProviderConfig give provider details

type RunConfig Uses

type RunConfig struct {
    Imagename string
    Ports     []int
    GdbPort   int
    Verbose   bool
    Memory    string
    Bridged   bool
    TapName   string
    Accel     bool
}

RunConfig provides runtime details

func RuntimeConfig Uses

func RuntimeConfig(image string, ports []int, verbose bool) RunConfig

RuntimeConfig constructs runtime config

type S3 Uses

type S3 struct{}

S3 provides AWS storage related operations

func (*S3) CopyToBucket Uses

func (s *S3) CopyToBucket(config *Config, archPath string) error

CopyToBucket copies archive to bucket

func (*S3) DeleteFromBucket Uses

func (s *S3) DeleteFromBucket(config *Config, key string) error

DeleteFromBucket deletes key from config's bucket

type WriteCounter Uses

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

WriteCounter counts the number of bytes written to it. It implements to the io.Writer interface and we can pass this into io.TeeReader() which will report progress on each write cycle.

func NewWriteCounter Uses

func NewWriteCounter(total int) *WriteCounter

NewWriteCounter creates new write counter

func (*WriteCounter) Finish Uses

func (wc *WriteCounter) Finish()

Finish progress bar

func (*WriteCounter) Start Uses

func (wc *WriteCounter) Start()

Start progress bar

func (*WriteCounter) Write Uses

func (wc *WriteCounter) Write(p []byte) (int, error)

Package lepton imports 44 packages (graph) and is imported by 1 packages. Updated 2019-10-22. Refresh now. Tools for package owners.