models

package
v0.18.3-0...-c90ca1e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DB is the path to the local nanobox database
	DB = filepath.ToSlash(filepath.Join(config.GlobalDir(), "data.db"))
)

Functions

func AppIDByAlias

func AppIDByAlias(alias string) string

AppIDByAlias looks up an app id from an alias

func DeleteAllConsoles

func DeleteAllConsoles() error

DeleteAllConsoles deletes all console

func DeleteAuth

func DeleteAuth(endpoint string) error

DeleteAuth ...

func DoneRead

func DoneRead() error

DoneRead stores that the high sierra guide has been read.

func HasRead

func HasRead() bool

HasRead returns true if the value is set. Used for prompting high sierra warning on first config.

func Inspect

func Inspect(bucket, key string) interface{}

Inspect ...

func VersionString

func VersionString() string

Types

type App

type App struct {
	EnvID string
	ID    string
	Name  string
	// State is used to ensure we don't setup this environment multiple times
	State  string
	Status string
	// Appironment variables available to the environment
	Evars map[string]string
	// There are also certain platform service ips that need to 1) remain constant
	// even if the component were repaired and 2) be available even before the
	// component is. logvac and mist ips are examples. We'll store those here.
	LocalIPs map[string]string
	// the boxfile from the most recent deploy
	DeployedBoxfile string
	// the https key used
	Key string
	// the https cert used
	Cert string
}

App ...

func AllApps

func AllApps() ([]*App, error)

AllApps loads all of the Apps across all environments

func AllAppsByEnv

func AllAppsByEnv(envID string) ([]*App, error)

AllAppsByEnv loads all of the Apps in the database

func AllAppsByStatus

func AllAppsByStatus(status string) ([]*App, error)

AllAppsByStatus loads all of the Apps filtering by status

func FindAppBySlug

func FindAppBySlug(envID, name string) (*App, error)

FindAppBySlug finds an app by an appID and name

func (*App) Components

func (a *App) Components() ([]*Component, error)

Components ...

func (*App) Delete

func (a *App) Delete() error

Delete deletes the app record from the database

func (*App) DisplayName

func (a *App) DisplayName() string

func (*App) Env

func (a *App) Env() (*Env, error)

Env ...

func (*App) Generate

func (a *App) Generate(env *Env, name string) error

Generate populates an App with data and persists the record

func (*App) IsNew

func (a *App) IsNew() bool

IsNew returns true if the App hasn't been created yet

func (*App) Save

func (a *App) Save() error

Save persists the App to the database

type Auth

type Auth struct {
	Endpoint string // nanobox, bonesalt, dev, sim
	Key      string // api_token from dashboard
}

Auth ...

func LoadAuth

func LoadAuth() (*Auth, error)

LoadAuth loads the default (nanobox) auth entry

func LoadAuthByEndpoint

func LoadAuthByEndpoint(endpoint string) (*Auth, error)

loads an auth by a specific endpoint

func (*Auth) Delete

func (a *Auth) Delete() error

Delete deletes the auth record from the database

func (*Auth) IsNew

func (a *Auth) IsNew() bool

determines if the auth record is new

func (*Auth) Save

func (a *Auth) Save() error

Save persists the Auth to the database

type Component

type Component struct {
	// the docker id
	ID    string `json:"id"`
	AppID string `json:"app_id"`
	EnvID string `json:"env_id"`
	// name is used for boltdb storage
	Name  string `json:"name"`
	Label string `json:"label"`
	Image string `json:"image"`
	Type  string `json:"type"`
	IP    string `json:"ip"`
	// ExternalIP string        `json:"external_ip"`
	InternalIP string        `json:"internal_ip"`
	Plan       ComponentPlan `json:"plan"`
	State      string        `json:"state"`
}

Component ...

func AllComponentsByApp

func AllComponentsByApp(appID string) ([]*Component, error)

AllComponentsByApp loads all of the components in the database

func FindComponentBySlug

func FindComponentBySlug(appID, name string) (*Component, error)

FindComponentBySlug finds a component by an appID and name

func (*Component) Delete

func (c *Component) Delete() error

Delete deletes the component record from the database

func (*Component) Generate

func (c *Component) Generate(app *App, ttype string) error

Generate populates a Component with data and persists the record

func (*Component) GenerateEvars

func (c *Component) GenerateEvars(app *App) error

GenerateEvars generates the evars for this component

func (*Component) GeneratePlan

func (c *Component) GeneratePlan(data string) error

GeneratePlan generates the plan from the plan hook output

func (*Component) IPAddr

func (c *Component) IPAddr() string

backword compatibility function so we can transition to the new single ip system

func (*Component) IsNew

func (c *Component) IsNew() bool

IsNew returns true if the Component hasn't been created yet

func (*Component) PurgeEvars

func (c *Component) PurgeEvars(a *App) error

PurgeEvars purges the generated evars for a component

func (*Component) Save

func (c *Component) Save() error

Save persists the Component to the database

type ComponentPlan

type ComponentPlan struct {
	IPs           []string            `json:"ips"`
	Users         []ComponentPlanUser `json:"users"`
	MountProtocol string              `json:"mount_protocol"`
	Behaviors     []string            `json:"behaviors"`
	DefaultUser   string              `json:"user"`
}

ComponentPlan ...

func (ComponentPlan) BehaviorPresent

func (p ComponentPlan) BehaviorPresent(b string) bool

BehaviorPresent ...

type ComponentPlanUser

type ComponentPlanUser struct {
	Username string                 `json:"username"`
	Password string                 `json:"password"`
	Meta     map[string]interface{} `json:"meta"`
}

ComponentPlanUser ...

type Config

type Config struct {
	Provider      string `json:"provider"`
	CIMode        bool   `json:"ci-mode"`
	CISyncVerbose bool   `json:"ci-sync-verbose"`

	// required for docker-machine
	MountType      string `json:"mount-type"`
	NetfsMountOpts string `json:"netfs-mount-opts"`
	CPUs           int    `json:"cpus"`
	RAM            int    `json:"ram"`
	Disk           int    `json:"disk"`

	// ip address spaces
	ExternalNetworkSpace      string `json:"external-network-space"`
	DockerMachineNetworkSpace string `json:"docker-machine-network-space"`
	NativeNetworkSpace        string `json:"native-network-space"`

	SshKey           string `json:"ssh-key"`
	SshEncryptedKeys bool   `json:"ssh-encrypted-keys"`

	Anonymous bool `json:"anonymous"`
	LockPort  int  `json:"lock-port"`
}

Config ...

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads the Config entry

func (*Config) Delete

func (c *Config) Delete() error

Delete deletes the Config record from the database

func (*Config) Save

func (c *Config) Save() error

Save persists the Config to the database

type Console

type Console struct {
	ID          string
	ContainerID string
}

func AllConsoles

func AllConsoles() ([]*Console, error)

AllConsoles loads all of the Consoles in the database

func (*Console) Delete

func (c *Console) Delete() error

Delete deletes the dev record from the database

func (*Console) Save

func (c *Console) Save() error

Save persists the Console to the database

type Env

type Env struct {
	ID        string
	Directory string
	Name      string

	// Remotes map a local app to multiple production apps, by an alias
	Remotes map[string]Remote
	// the boxfile from the most recent build
	BuiltBoxfile  string
	UserBoxfile   string
	BuiltID       string
	DeployedID    string
	LastBuild     time.Time
	LastCompile   time.Time
	BuildTriggers map[string]string
}

Env ...

func AllEnvs

func AllEnvs() ([]*Env, error)

AllEnvs loads all of the Envs in the database

func FindEnvByID

func FindEnvByID(ID string) (*Env, error)

FindEnvByID finds an app by an ID

func (*Env) Apps

func (e *Env) Apps() ([]*App, error)

Apps get a list of the apps that belong to this

func (*Env) Delete

func (e *Env) Delete() error

Delete deletes the app record from the database

func (*Env) Generate

func (e *Env) Generate() error

Generate populates an Env from config data and persists the record

func (*Env) IsNew

func (e *Env) IsNew() bool

IsNew returns true if the Env hasn't been created yet

func (*Env) Save

func (e *Env) Save() error

Save persists the Env to the database

type IPs

type IPs []net.IP

IPs ...

func LoadIPs

func LoadIPs() (IPs, error)

LoadIPs loads the auth entry

func (*IPs) Delete

func (ips *IPs) Delete() error

Delete deletes the auth record from the database

func (*IPs) Save

func (ips *IPs) Save() error

Save persists the IPs to the database

type LogOpts

type LogOpts struct {
	Follow bool   // Follow is whether or not to follow the log stream.
	Number int    // Number of logs to print.
	Raw    bool   // Raw will not strip out the timestamp from the log stream.
	Start  string // Start is where to start the logs from.
	End    string // End is where to end the logs.
	Limit  string // Limit is how many logs to show.
}

LogOpts are options for logging

type Provider

type Provider struct {
	Name    string // name of the provider
	HostIP  string // the ip the host knows about
	MountIP string // the ip we reserved for mounting
}

Provider ...

func LoadProvider

func LoadProvider() (*Provider, error)

LoadProvider loads the provider entry

func (*Provider) Delete

func (a *Provider) Delete() error

Delete deletes the provider record from the database

func (*Provider) Save

func (a *Provider) Save() error

Save persists the Provider to the database

type Remote

type Remote struct {
	ID       string
	Name     string
	Endpoint string
}

Remote ...

type TunnelConfig

type TunnelConfig struct {
	AppName    string // name of app to tunnel to
	ListenPort int    // local port to listen on
	DestPort   int    // port to tunnel to
	Component  string // component to tunnel to
}

TunnelConfig contains the endpoint information.

type TunnelInfo

type TunnelInfo struct {
	Name  string `json:"name,omitempty"`  // component name being tunneled to
	Token string `json:"token,omitempty"` // token to complete the tunnel
	URL   string `json:"url,omitempty"`   // url/ip of nanoagent
	Port  int    `json:"port,omitempty"`  // port to tunnel to. *must* omitempty. odin will use whatever port is passed (if 0, don't send)
}

type Update

type Update struct {
	LastCheckAt   time.Time
	LastUpdatedAt time.Time
}

Update ...

func LoadUpdate

func LoadUpdate() (*Update, error)

LoadUpdate loads the update entry

func (*Update) Save

func (u *Update) Save() error

Save persists the Update to the database

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL