types

import "github.com/analog-substance/carbon/pkg/types"

Index

Variables

var StateRunning = MachineState{"Running"}

var StateSleeping = MachineState{"Sleeping"}

var StateStarting = MachineState{"Starting"}

var StateStopped = MachineState{"Stopped"}

var StateStopping = MachineState{"Stopping"}

var StateTerminated = MachineState{"Terminated"}

var StateTerminating = MachineState{"Terminating"}

var StateUnknown = MachineState{"Unknown"}

type Environment

type Environment interface {
    Name() string
    VMs() []VM
    Profile() Profile
    StartVM(string) error
    StopVM(string) error
    RestartVM(string) error
    ImageBuilds() ([]ImageBuild, error)
    Images() ([]Image, error)
    CreateVM(MachineLaunchOptions) error
    DestroyVM(string) error
    DestroyImage(string) error
}

type Image

type Image interface {
    ID() string
    Name() string
    CreatedAt() string
    Environment() Environment
    Profile() Profile
    Provider() Provider
    Launch(imageLaunchOptions ImageLaunchOptions) error
    Destroy() error
}

type ImageBuild

type ImageBuild interface {
    Name() string
    ProviderType() string
    Provisioner() string
    Build() error
}

type ImageLaunchOptions

type ImageLaunchOptions struct {
    Name string
}

type MachineLaunchOptions

type MachineLaunchOptions struct {
    CloudInitTpl string `json:"cloud-init"`
    Image        Image  `json:"image"`
    Name         string `json:"name"`
}

type MachineState

type MachineState struct {
    Name string `json:"name"`
}

type Profile

type Profile interface {
    Environments() []Environment
    Name() string
    Provider() Provider
    SetConfig(config common.ProfileConfig)
    GetConfig() common.ProfileConfig
    ShouldIncludeEnvironment(envName string) bool
}

type Project

type Project interface {
    Name() string
    TerraformApply() error
    AddMachine(machine *ProjectMachine, noApply bool) error
}

type ProjectConfig

type ProjectConfig struct {
    Machines []*ProjectMachine `yaml:"machines"`
}

type ProjectMachine

type ProjectMachine struct {
    Name       string `yaml:"name"`
    Image      string `yaml:"image,omitempty"`
    Type       string `yaml:"type,omitempty"`
    Profile    string `yaml:"profile,omitempty"`
    Purpose    string `yaml:"purpose,omitempty"`
    VolumeSize int    `yaml:"volume_size,omitempty"`
    Provider   string `yaml:"provider,omitempty"`
}

type Provider

type Provider interface {
    Profiles() []Profile
    Name() string
    Type() string
    IsAvailable() bool
    SetConfig(config common.ProviderConfig)
    GetConfig() common.ProviderConfig
    NewImageBuild(name string, tplDir string) (ImageBuild, error)
    NewProject(name string, force bool) (Project, error)
}

type VM

VM interface provides access to useful information and actions related to Virtual Machines

type VM interface {
    // Name returns the name of a virtual machine
    Name() string

    // ID returns the ID of the virtual machine
    ID() string

    // IPAddress returns the public IP address of the virtual machine
    IPAddress() string

    // PrivateIPAddress of the virtual machine
    PrivateIPAddress() string
    UpTime() time.Duration
    State() string
    Type() string

    Environment() Environment
    Profile() Profile
    Provider() Provider

    Destroy() error
    Start() error
    Stop() error
    Restart() error

    ExecSSH(string, bool, ...string) error
    StartVNC(user string, privateIP bool, killVNC bool) error
    StartRDPClient(user string, privateIP bool) error
    Cmd(string, bool, ...string) (string, error)
    NewSSHSession(string, bool) (*ssh_util.Session, error)
}
Last modified March 27, 2025: Add GCP Support (#88) (dccf344)