flaps

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: Apache-2.0 Imports: 23 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FlapsErrorNotFound = &FlapsError{ResponseStatusCode: http.StatusNotFound}
)
View Source
var NonceHeader = "fly-machine-lease-nonce"

Functions

func GetErrorRequestID

func GetErrorRequestID(err error) string

func GetErrorTraceID added in v0.1.5

func GetErrorTraceID(err error) string

Types

type Client

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

func NewWithOptions

func NewWithOptions(ctx context.Context, opts NewClientOpts) (*Client, error)

func (*Client) AcquireLease

func (f *Client) AcquireLease(ctx context.Context, machineID string, ttl *int) (*fly.MachineLease, error)

func (*Client) Cordon

func (f *Client) Cordon(ctx context.Context, machineID string, nonce string) (err error)

func (*Client) CreateApp

func (f *Client) CreateApp(ctx context.Context, name string, org string) (err error)

func (*Client) CreateVolume

func (f *Client) CreateVolume(ctx context.Context, req fly.CreateVolumeRequest) (*fly.Volume, error)

func (*Client) CreateVolumeSnapshot

func (f *Client) CreateVolumeSnapshot(ctx context.Context, volumeId string) error

func (*Client) DeleteMetadata

func (f *Client) DeleteMetadata(ctx context.Context, machineID, key string) error

func (*Client) DeleteVolume

func (f *Client) DeleteVolume(ctx context.Context, volumeId string) (*fly.Volume, error)

func (*Client) Destroy

func (f *Client) Destroy(ctx context.Context, input fly.RemoveMachineInput, nonce string) (err error)

func (*Client) Exec

func (f *Client) Exec(ctx context.Context, machineID string, in *fly.MachineExecRequest) (*fly.MachineExecResponse, error)

func (*Client) ExtendVolume

func (f *Client) ExtendVolume(ctx context.Context, volumeId string, size_gb int) (*fly.Volume, bool, error)

func (*Client) FindLease

func (f *Client) FindLease(ctx context.Context, machineID string) (*fly.MachineLease, error)

func (*Client) Get

func (f *Client) Get(ctx context.Context, machineID string) (*fly.Machine, error)

func (*Client) GetAllVolumes

func (f *Client) GetAllVolumes(ctx context.Context) ([]fly.Volume, error)

func (*Client) GetMany

func (f *Client) GetMany(ctx context.Context, machineIDs []string) ([]*fly.Machine, error)

func (*Client) GetMetadata

func (f *Client) GetMetadata(ctx context.Context, machineID string) (map[string]string, error)

func (*Client) GetProcesses

func (f *Client) GetProcesses(ctx context.Context, machineID string) (fly.MachinePsResponse, error)

func (*Client) GetVolume

func (f *Client) GetVolume(ctx context.Context, volumeId string) (*fly.Volume, error)

func (*Client) GetVolumeSnapshots

func (f *Client) GetVolumeSnapshots(ctx context.Context, volumeId string) ([]fly.VolumeSnapshot, error)

func (*Client) GetVolumes

func (f *Client) GetVolumes(ctx context.Context) ([]fly.Volume, error)

func (*Client) Kill

func (f *Client) Kill(ctx context.Context, machineID string) (err error)

func (*Client) Launch

func (f *Client) Launch(ctx context.Context, builder fly.LaunchMachineInput) (out *fly.Machine, err error)

func (*Client) List

func (f *Client) List(ctx context.Context, state string) ([]*fly.Machine, error)

func (*Client) ListActive

func (f *Client) ListActive(ctx context.Context) ([]*fly.Machine, error)

ListActive returns only non-destroyed that aren't in a reserved process group.

func (*Client) ListFlyAppsMachines

func (f *Client) ListFlyAppsMachines(ctx context.Context) ([]*fly.Machine, *fly.Machine, error)

ListFlyAppsMachines returns apps that are part of Fly Launch. Destroyed machines and console machines are excluded. Unlike other List functions, this function retries multiple times.

func (*Client) NewRequest

func (f *Client) NewRequest(ctx context.Context, method, path string, in interface{}, headers map[string][]string) (*http.Request, error)

func (*Client) RefreshLease

func (f *Client) RefreshLease(ctx context.Context, machineID string, ttl *int, nonce string) (*fly.MachineLease, error)

func (*Client) ReleaseLease

func (f *Client) ReleaseLease(ctx context.Context, machineID, nonce string) error

func (*Client) Restart

func (f *Client) Restart(ctx context.Context, in fly.RestartMachineInput, nonce string) (err error)

func (*Client) SetMetadata

func (f *Client) SetMetadata(ctx context.Context, machineID, key, value string) error

func (*Client) Start

func (f *Client) Start(ctx context.Context, machineID string, nonce string) (out *fly.MachineStartResponse, err error)

func (*Client) Stop

func (f *Client) Stop(ctx context.Context, in fly.StopMachineInput, nonce string) (err error)

func (*Client) Suspend added in v0.1.17

func (f *Client) Suspend(ctx context.Context, machineID, nonce string) error

func (*Client) Uncordon

func (f *Client) Uncordon(ctx context.Context, machineID string, nonce string) (err error)

func (*Client) Update

func (f *Client) Update(ctx context.Context, builder fly.LaunchMachineInput, nonce string) (out *fly.Machine, err error)

func (*Client) UpdateVolume

func (f *Client) UpdateVolume(ctx context.Context, volumeId string, req fly.UpdateVolumeRequest) (*fly.Volume, error)

func (*Client) Wait

func (f *Client) Wait(ctx context.Context, machine *fly.Machine, state string, timeout time.Duration) (err error)

func (*Client) WaitForApp

func (f *Client) WaitForApp(ctx context.Context, name string) error

type ErrorRequestID

type ErrorRequestID interface {
	ErrRequestID() string
}

TODO: we might not actually need an interface type here

type ErrorStatusCode

type ErrorStatusCode interface {
	error
	StatusCode() *StatusCode
}

type ErrorTraceID added in v0.1.5

type ErrorTraceID interface {
	ErrTraceID() string
}

type ExtendVolumeRequest

type ExtendVolumeRequest struct {
	SizeGB int `json:"size_gb"`
}

type ExtendVolumeResponse

type ExtendVolumeResponse struct {
	Volume       *fly.Volume `json:"volume"`
	NeedsRestart bool        `json:"needs_restart"`
}

type FlapsError

type FlapsError struct {
	OriginalError      error
	ResponseStatusCode int
	ResponseBody       []byte
	FlyRequestId       string
	TraceID            string
}

func (*FlapsError) ErrRequestID

func (fe *FlapsError) ErrRequestID() string

func (*FlapsError) ErrTraceID added in v0.1.5

func (fe *FlapsError) ErrTraceID() string

func (*FlapsError) Error

func (fe *FlapsError) Error() string

func (*FlapsError) Is

func (fe *FlapsError) Is(target error) bool

func (*FlapsError) ResponseBodyString

func (fe *FlapsError) ResponseBodyString() string

func (*FlapsError) StatusCode

func (fe *FlapsError) StatusCode() *StatusCode

func (*FlapsError) Suggestion

func (fe *FlapsError) Suggestion() string

func (*FlapsError) Unwrap

func (fe *FlapsError) Unwrap() error

type NewClientOpts

type NewClientOpts struct {
	// required:
	AppName string

	// optional, avoids API roundtrip when connecting to flaps by wireguard:
	AppCompact *fly.AppCompact

	// optional, sent with requests
	UserAgent string

	// optional, used to connect to machines API
	DialContext func(ctx context.Context, network, address string) (net.Conn, error)
	OrgSlug     string // required if DialContext set

	// URL used when connecting via usermode wireguard.
	BaseURL *url.URL

	Tokens *tokens.Tokens

	// optional:
	Logger fly.Logger

	// optional, used to construct the underlying HTTP client
	Transport http.RoundTripper
}

type StatusCode

type StatusCode string

func GetErrorStatusCode

func GetErrorStatusCode(err error) *StatusCode

Jump to

Keyboard shortcuts

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