machineapi

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NonceHeader = "fly-machine-lease-nonce"

Functions

This section is empty.

Types

type GuestConfig

type GuestConfig struct {
	Cpus     int    `json:"cpus,omitempty"`
	MemoryMb int    `json:"memory_mb,omitempty"`
	CpuType  string `json:"cpu_kind,omitempty"`
}

type InitConfig

type InitConfig struct {
	Cmd        []string `json:"cmd,omitempty"`
	Entrypoint []string `json:"entrypoint,omitempty"`
	Exec       []string `json:"exec,omitempty"`
}

type MachineAPI

type MachineAPI struct {
	HttpClient *hreq.Client
	// contains filtered or unexported fields
}

func NewMachineApi added in v0.1.13

func NewMachineApi(ctx context.Context, state *providerstate.State) *MachineAPI

func (*MachineAPI) CreateMachine

func (a *MachineAPI) CreateMachine(req MachineCreateOrUpdateRequest, app string, res *MachineResponse) error

CreateMachine takes a MachineCreateOrUpdateRequest and creates the requested machine in the given app and then writes the response into the `res` param

func (*MachineAPI) CreateVolume

func (a *MachineAPI) CreateVolume(ctx context.Context, name, app, region string, size int) (*api.Volume, error)

func (*MachineAPI) DeleteMachine

func (a *MachineAPI) DeleteMachine(app string, id string, maxRetries int) error

func (*MachineAPI) DeleteVolume

func (a *MachineAPI) DeleteVolume(ctx context.Context, app string, id string) error

func (*MachineAPI) ExtendVolume added in v0.1.13

func (a *MachineAPI) ExtendVolume(ctx context.Context, app string, id string, size int) error

func (*MachineAPI) GetVolume

func (a *MachineAPI) GetVolume(ctx context.Context, id, app string) (*api.Volume, error)

func (*MachineAPI) LockMachine

func (a *MachineAPI) LockMachine(app string, id string, timeout int) (*MachineLease, error)

func (*MachineAPI) ReadMachine

func (a *MachineAPI) ReadMachine(app string, id string, res *MachineResponse) (*hreq.Response, error)

func (*MachineAPI) ReleaseMachine

func (a *MachineAPI) ReleaseMachine(lease MachineLease, app string, id string) error

func (*MachineAPI) UpdateMachine

func (a *MachineAPI) UpdateMachine(req MachineCreateOrUpdateRequest, app string, id string, res *MachineResponse) error

func (*MachineAPI) WaitForMachine

func (a *MachineAPI) WaitForMachine(app string, id string, instanceID string) error

type MachineConfig

type MachineConfig struct {
	Image       string            `json:"image"`
	Env         map[string]string `json:"env"`
	Init        InitConfig        `json:"init,omitempty"`
	Mounts      []MachineMount    `json:"mounts,omitempty"`
	Services    []Service         `json:"services"`
	Guest       GuestConfig       `json:"guest,omitempty"`
	AutoDestroy bool              `json:"auto_destroy"`
}

type MachineCreateOrUpdateRequest

type MachineCreateOrUpdateRequest struct {
	Name   string        `json:"name"`
	Region string        `json:"region"`
	Config MachineConfig `json:"config"`
}

type MachineLease

type MachineLease struct {
	Status string `json:"status"`
	Data   struct {
		Nonce     string `json:"nonce"`
		ExpiresAt int64  `json:"expires_at"`
		Owner     string `json:"owner"`
	}
}

type MachineMount

type MachineMount struct {
	Encrypted bool   `json:"encrypted,omitempty"`
	Path      string `json:"path"`
	SizeGb    int    `json:"size_gb,omitempty"`
	Volume    string `json:"volume"`
}

type MachineResponse

type MachineResponse struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	State      string `json:"state"`
	Region     string `json:"region"`
	InstanceID string `json:"instance_id"`
	PrivateIP  string `json:"private_ip"`
	Config     struct {
		Env  map[string]string `json:"env"`
		Init struct {
			Exec       []string `json:"exec"`
			Entrypoint []string `json:"entrypoint"`
			Cmd        []string `json:"cmd"`
		} `json:"init"`
		Image    string      `json:"image"`
		Metadata interface{} `json:"metadata"`
		Restart  struct {
			Policy string `json:"policy"`
		} `json:"restart"`
		Services []Service      `json:"services"`
		Mounts   []MachineMount `json:"mounts"`
		Guest    struct {
			CPUKind  string `json:"cpu_kind"`
			Cpus     int    `json:"cpus"`
			MemoryMb int    `json:"memory_mb"`
		} `json:"guest"`
		AutoDestroy bool `json:"auto_destroy"`
	} `json:"config"`
	ImageRef struct {
		Registry   string `json:"registry"`
		Repository string `json:"repository"`
		Tag        string `json:"tag"`
		Digest     string `json:"digest"`
		Labels     struct {
		} `json:"labels"`
	} `json:"image_ref"`
	CreatedAt time.Time `json:"created_at"`
}

type Port

type Port struct {
	Port       *int64   `json:"port"`
	StartPort  *int64   `json:"start_port"`
	EndPort    *int64   `json:"end_port"`
	Handlers   []string `json:"handlers"`
	ForceHttps bool     `json:"force_https"`
}

type Service

type Service struct {
	Ports        []Port `json:"ports"`
	Protocol     string `json:"protocol"`
	InternalPort int64  `json:"internal_port"`
}

Jump to

Keyboard shortcuts

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