instances

package
v0.0.0-...-8b5928e Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildHostInstance

func BuildHostInstance(in *compute.Instance) (*apiv1.HostInstance, error)

func EncodeOperationName

func EncodeOperationName(opType OPType, host string) string

Types

type Config

type Config struct {
	Type IMType
	// The protocol the host orchestrator expects, either http or https
	HostOrchestratorProtocol          string
	AllowSelfSignedHostSSLCertificate bool
	GCP                               *GCPIMConfig
	UNIX                              *UNIXIMConfig
	Docker                            *DockerIMConfig
}

type DockerIMConfig

type DockerIMConfig struct {
	DockerImageName      string
	HostOrchestratorPort int
}

type DockerInstanceManager

type DockerInstanceManager struct {
	Config Config
	Client client.Client
}

Docker implementation of the instance manager.

func NewDockerInstanceManager

func NewDockerInstanceManager(cfg Config, cli client.Client) *DockerInstanceManager

func (*DockerInstanceManager) CreateHost

func (*DockerInstanceManager) DeleteHost

func (m *DockerInstanceManager) DeleteHost(zone string, user accounts.User, host string) (*apiv1.Operation, error)

func (*DockerInstanceManager) GetHostAddr

func (m *DockerInstanceManager) GetHostAddr() (string, error)

func (*DockerInstanceManager) GetHostClient

func (m *DockerInstanceManager) GetHostClient(zone string, host string) (HostClient, error)

func (*DockerInstanceManager) GetHostPort

func (m *DockerInstanceManager) GetHostPort(host string) (int, error)

func (*DockerInstanceManager) GetHostURL

func (m *DockerInstanceManager) GetHostURL(host string) (*url.URL, error)

func (*DockerInstanceManager) ListHosts

func (*DockerInstanceManager) ListZones

func (*DockerInstanceManager) WaitOperation

func (m *DockerInstanceManager) WaitOperation(zone string, _ accounts.User, name string) (any, error)

type GCEInstanceManager

type GCEInstanceManager struct {
	Config                Config
	Service               *compute.Service
	InstanceNameGenerator NameGenerator
}

GCP implementation of the instance manager.

func NewGCEInstanceManager

func NewGCEInstanceManager(cfg Config, service *compute.Service, nameGenerator NameGenerator) *GCEInstanceManager

func (*GCEInstanceManager) CreateHost

func (m *GCEInstanceManager) CreateHost(zone string, req *apiv1.CreateHostRequest, user accounts.User) (*apiv1.Operation, error)

func (*GCEInstanceManager) DeleteHost

func (m *GCEInstanceManager) DeleteHost(zone string, user accounts.User, name string) (*apiv1.Operation, error)

func (*GCEInstanceManager) GetHostAddr

func (m *GCEInstanceManager) GetHostAddr(zone string, host string) (string, error)

func (*GCEInstanceManager) GetHostClient

func (m *GCEInstanceManager) GetHostClient(zone string, host string) (HostClient, error)

func (*GCEInstanceManager) GetHostURL

func (m *GCEInstanceManager) GetHostURL(zone string, host string) (*url.URL, error)

func (*GCEInstanceManager) ListHosts

func (*GCEInstanceManager) ListZones

func (m *GCEInstanceManager) ListZones() (*apiv1.ListZonesResponse, error)

func (*GCEInstanceManager) WaitOperation

func (m *GCEInstanceManager) WaitOperation(zone string, user accounts.User, name string) (any, error)

type GCPIMConfig

type GCPIMConfig struct {
	ProjectID            string
	HostImageFamily      string
	HostOrchestratorPort int
	// If true, instances created should be compatible with `acloud CLI`.
	AcloudCompatible bool
}

type HostClient

type HostClient interface {
	// Get and Post requests return the HTTP status code or an error.
	// The response body is parsed into the res output parameter if provided.
	Get(URLPath, URLQuery string, res *HostResponse) (int, error)
	Post(URLPath, URLQuery string, bodyJSON any, res *HostResponse) (int, error)
	GetReverseProxy() *httputil.ReverseProxy
}

type HostResponse

type HostResponse struct {
	Result any
	Error  *apiv1.Error
}

type IMType

type IMType string
const DockerIMType IMType = "docker"
const GCEIMType IMType = "GCP"
const UnixIMType IMType = "unix"

type InstanceNameGenerator

type InstanceNameGenerator struct {
	UUIDFactory func() string
}

func (*InstanceNameGenerator) NewName

func (g *InstanceNameGenerator) NewName() string

type ListHostsRequest

type ListHostsRequest struct {
	// The maximum number of results per page that should be returned. If the number of available results is larger
	// than MaxResults, a `NextPageToken` will be returned which can be used to get the next page of results
	// in subsequent List requests.
	MaxResults uint32
	// Specifies a page token to use.
	// Use the `NextPageToken` value returned by a previous List request.
	PageToken string
}

type LocalInstanceManager

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

Implements the Manager interface providing access to the first device in the local host orchestrator. This implementation is useful for both development and testing

func NewLocalInstanceManager

func NewLocalInstanceManager(cfg Config) *LocalInstanceManager

func (*LocalInstanceManager) CreateHost

func (*LocalInstanceManager) DeleteHost

func (m *LocalInstanceManager) DeleteHost(zone string, user accounts.User, name string) (*apiv1.Operation, error)

func (*LocalInstanceManager) GetHostAddr

func (m *LocalInstanceManager) GetHostAddr(_ string, _ string) (string, error)

func (*LocalInstanceManager) GetHostClient

func (m *LocalInstanceManager) GetHostClient(zone string, host string) (HostClient, error)

func (*LocalInstanceManager) GetHostURL

func (m *LocalInstanceManager) GetHostURL(zone string, host string) (*url.URL, error)

func (*LocalInstanceManager) ListHosts

func (*LocalInstanceManager) ListZones

func (*LocalInstanceManager) WaitOperation

func (m *LocalInstanceManager) WaitOperation(zone string, user accounts.User, name string) (any, error)

type Manager

type Manager interface {
	// List zones
	ListZones() (*apiv1.ListZonesResponse, error)
	// Creates a host instance.
	CreateHost(zone string, req *apiv1.CreateHostRequest, user accounts.User) (*apiv1.Operation, error)
	// List hosts
	ListHosts(zone string, user accounts.User, req *ListHostsRequest) (*apiv1.ListHostsResponse, error)
	// Deletes the given host instance.
	DeleteHost(zone string, user accounts.User, name string) (*apiv1.Operation, error)
	// Waits until operation is DONE or earlier. If DONE return the expected  response of the operation. If the
	// original method returns no data on success, such as `Delete`, response will be empty. If the original method
	// is standard `Get`/`Create`/`Update`, the response should be the relevant resource.
	WaitOperation(zone string, user accounts.User, name string) (any, error)
	// Creates a connector to the given host.
	GetHostClient(zone string, host string) (HostClient, error)
}

type NameGenerator

type NameGenerator interface {
	NewName() string
}

type NetHostClient

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

func NewNetHostClient

func NewNetHostClient(url *url.URL, allowSelfSigned bool) *NetHostClient

func (*NetHostClient) Get

func (c *NetHostClient) Get(path, query string, out *HostResponse) (int, error)

func (*NetHostClient) GetReverseProxy

func (c *NetHostClient) GetReverseProxy() *httputil.ReverseProxy

func (*NetHostClient) Post

func (c *NetHostClient) Post(path, query string, bodyJSON any, out *HostResponse) (int, error)

type OPType

type OPType string
const (
	CreateHostOPType OPType = "createhost"
	DeleteHostOPType OPType = "deletehost"
)

func DecodeOperationName

func DecodeOperationName(name string) (OPType, string, error)

type UNIXIMConfig

type UNIXIMConfig struct {
	HostOrchestratorPort int
}

Jump to

Keyboard shortcuts

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