compute

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package compute provides infrastructure provider implementations. DigitalOcean provider for creating and managing DigitalOcean droplets https://github.com/digitalocean/godo/blob/main/droplets.go#L18

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitXimeraConfig added in v0.0.16

func InitXimeraConfig() (*computeTypes.XimeraConfiguration, error)

InitXimeraConfig initializes the configuration from environment variables

func NewDOClient

func NewDOClient(token string) computeTypes.DOClient

NewDOClient creates a new DigitalOcean client

Types

type AnsibleConfigurator

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

AnsibleConfigurator implements the Provisioner interface

func NewAnsibleConfigurator

func NewAnsibleConfigurator(jobID string) *AnsibleConfigurator

NewAnsibleConfigurator creates a new Ansible configurator

func (*AnsibleConfigurator) ConfigureHost

func (a *AnsibleConfigurator) ConfigureHost(ctx context.Context, host string, sshKeyPath string) error

ConfigureHost implements the Provisioner interface

NOTE: this isn't a create name since all it is really doing is ensuring SSH readiness

func (*AnsibleConfigurator) ConfigureHosts

func (a *AnsibleConfigurator) ConfigureHosts(ctx context.Context, hosts []string, sshKeyPath string) error

ConfigureHosts ensures SSH readiness for multiple hosts in parallel. It no longer creates the inventory or runs the playbook.

NOTE: this isn't a create name since all it is really doing is ensuring SSH readiness

func (*AnsibleConfigurator) CreateInventory

func (a *AnsibleConfigurator) CreateInventory(instance *types.InstanceRequest, talisSSHKeyPath string) (string, error)

CreateInventory creates the inventory file directly from InstanceRequest and returns the inventory path file

func (*AnsibleConfigurator) RunAnsiblePlaybook

func (a *AnsibleConfigurator) RunAnsiblePlaybook(inventoryPath string, tags []string) error

RunAnsiblePlaybook runs the Ansible playbook for all instances in parallel

type DefaultDOClient

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

DefaultDOClient is the default implementation of DOClient

func (*DefaultDOClient) ConfigureProvider

func (c *DefaultDOClient) ConfigureProvider(_ interface{}) error

ConfigureProvider configures the provider with the given stack

func (*DefaultDOClient) CreateInstance

func (c *DefaultDOClient) CreateInstance(ctx context.Context, config *talisTypes.InstanceRequest) error

CreateInstance creates a new instance

func (*DefaultDOClient) DeleteInstance

func (c *DefaultDOClient) DeleteInstance(ctx context.Context, dropletID int) error

DeleteInstance deletes an instance

func (*DefaultDOClient) Droplets

Droplets returns the droplet service

func (*DefaultDOClient) GetEnvironmentVars

func (c *DefaultDOClient) GetEnvironmentVars() map[string]string

GetEnvironmentVars returns the environment variables needed for the provider

func (*DefaultDOClient) Keys

Keys returns the key service

func (*DefaultDOClient) Storage

Storage returns the storage service

func (*DefaultDOClient) ValidateCredentials

func (c *DefaultDOClient) ValidateCredentials() error

ValidateCredentials validates the provider credentials

type DefaultDropletService

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

DefaultDropletService adapts godo.DropletService to our DropletService interface

func (*DefaultDropletService) Create

Create creates a new droplet

func (*DefaultDropletService) Delete

func (s *DefaultDropletService) Delete(ctx context.Context, dropletID int) (*godo.Response, error)

Delete deletes a droplet

func (*DefaultDropletService) Get

func (s *DefaultDropletService) Get(ctx context.Context, dropletID int) (*godo.Droplet, *godo.Response, error)

Get gets a droplet

func (*DefaultDropletService) List

List lists all droplets

type DefaultKeyService

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

DefaultKeyService adapts godo.KeyService to our KeyService interface

func (*DefaultKeyService) List

List lists all SSH keys

type DefaultStorageService

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

DefaultStorageService adapts godo.StorageService to our StorageService interface

func (*DefaultStorageService) AttachVolume

func (s *DefaultStorageService) AttachVolume(ctx context.Context, volumeID string, dropletID int) (*godo.Response, error)

AttachVolume attaches a block storage volume to a droplet and waits for completion. The operation is considered complete when the volume is successfully attached or when it fails after maximum retries.

func (*DefaultStorageService) CreateVolume

CreateVolume creates a new volume

func (*DefaultStorageService) DeleteVolume

func (s *DefaultStorageService) DeleteVolume(ctx context.Context, id string) (*godo.Response, error)

DeleteVolume deletes a volume

func (*DefaultStorageService) DetachVolume

func (s *DefaultStorageService) DetachVolume(ctx context.Context, volumeID string, dropletID int) (*godo.Response, error)

DetachVolume detaches a block storage volume from a droplet and waits for completion. The operation is considered complete when the volume is successfully detached or when it fails after maximum retries.

func (*DefaultStorageService) GetVolume

GetVolume gets a volume

func (*DefaultStorageService) GetVolumeAction

func (s *DefaultStorageService) GetVolumeAction(ctx context.Context, volumeID string, actionID int) (*godo.Action, *godo.Response, error)

GetVolumeAction gets a volume action

func (*DefaultStorageService) ListVolumes

ListVolumes lists all volumes

type DigitalOceanProvider

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

DigitalOceanProvider implements the ComputeProvider interface

func NewDigitalOceanProvider

func NewDigitalOceanProvider() (*DigitalOceanProvider, error)

NewDigitalOceanProvider creates a new DigitalOcean provider instance

func (*DigitalOceanProvider) ConfigureProvider

func (p *DigitalOceanProvider) ConfigureProvider(_ interface{}) error

ConfigureProvider is a no-op since we're not using Pulumi anymore

func (*DigitalOceanProvider) CreateInstance

func (p *DigitalOceanProvider) CreateInstance(
	ctx context.Context,
	config *talisTypes.InstanceRequest,
) error

CreateInstance creates a new DigitalOcean droplet

func (*DigitalOceanProvider) DeleteInstance

func (p *DigitalOceanProvider) DeleteInstance(ctx context.Context, dropletID int) error

DeleteInstance deletes a DigitalOcean droplet and its associated volumes

func (*DigitalOceanProvider) GetEnvironmentVars

func (p *DigitalOceanProvider) GetEnvironmentVars() map[string]string

GetEnvironmentVars returns the environment variables needed for the provider

func (*DigitalOceanProvider) SetClient

func (p *DigitalOceanProvider) SetClient(client computeTypes.DOClient)

SetClient sets the DO client for testing

func (*DigitalOceanProvider) ValidateCredentials

func (p *DigitalOceanProvider) ValidateCredentials() error

ValidateCredentials validates the DigitalOcean credentials

type Provider

type Provider interface {
	// ValidateCredentials validates the provider credentials
	ValidateCredentials() error

	// GetEnvironmentVars returns the environment variables needed for the provider
	GetEnvironmentVars() map[string]string

	// ConfigureProvider configures the provider with the given stack
	ConfigureProvider(stack interface{}) error

	// CreateInstance creates a new instance
	CreateInstance(ctx context.Context, req *types.InstanceRequest) error

	// DeleteInstance deletes an instance
	DeleteInstance(ctx context.Context, providerInstanceID int) error
}

Provider defines the interface for cloud providers

func NewComputeProvider

func NewComputeProvider(provider models.ProviderID) (Provider, error)

NewComputeProvider creates a new compute provider based on the provider name

type Provisioner

type Provisioner interface {
	// ConfigureHost configures a single host
	ConfigureHost(ctx context.Context, host string, sshKeyPath string) error

	// ConfigureHosts configures multiple hosts in parallel, ensuring SSH readiness
	ConfigureHosts(ctx context.Context, hosts []string, sshKeyPath string) error

	// CreateInventory creates an Ansible inventory file from instance info
	CreateInventory(instance *types.InstanceRequest, sshKeyPath string) (string, error)

	// RunAnsiblePlaybook runs the Ansible playbook
	RunAnsiblePlaybook(inventoryName string, tags []string) error
}

Provisioner is the interface for system configuration

func NewProvisioner

func NewProvisioner(jobID string) Provisioner

NewProvisioner creates a new system provisioner

type XimeraAPIClient added in v0.0.16

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

XimeraAPIClient is a client for interacting with the Ximera API Uses local ximera models

func NewXimeraAPIClient added in v0.0.16

func NewXimeraAPIClient(config *computeTypes.XimeraConfiguration) *XimeraAPIClient

NewXimeraAPIClient creates a new API client

func (*XimeraAPIClient) BuildServer added in v0.0.16

func (c *XimeraAPIClient) BuildServer(id int, osID, name, sshKey string) (*computeTypes.XimeraServerResponse, error)

BuildServer builds a server with the given ID

func (*XimeraAPIClient) CreateServer added in v0.0.16

func (c *XimeraAPIClient) CreateServer(name string, packageID int, storage, traffic, memory, cpuCores int) (*computeTypes.XimeraServerResponse, error)

CreateServer creates a new server

func (*XimeraAPIClient) DeleteServer added in v0.0.16

func (c *XimeraAPIClient) DeleteServer(id int) error

DeleteServer deletes a server with the given ID

func (*XimeraAPIClient) GetServer added in v0.0.16

GetServer gets a server by ID

func (*XimeraAPIClient) ListServers added in v0.0.16

ListServers lists all servers

func (*XimeraAPIClient) ListTemplates added in v0.0.16

func (c *XimeraAPIClient) ListTemplates(packageID int) (*computeTypes.XimeraTemplatesResponse, error)

ListTemplates lists available OS templates for a package

func (*XimeraAPIClient) MakeRequest added in v0.0.16

func (c *XimeraAPIClient) MakeRequest(method, endpoint string, body interface{}) ([]byte, error)

MakeRequest makes a request to the API

func (*XimeraAPIClient) ServerExists added in v0.0.16

func (c *XimeraAPIClient) ServerExists(name string) (bool, int, error)

ServerExists checks if a server with the given name exists TODO: Optimize this method if the API supports filtering servers by name instead of retrieving all servers and filtering client-side

func (*XimeraAPIClient) WaitForServerCreation added in v0.0.16

func (c *XimeraAPIClient) WaitForServerCreation(serverID int, timeoutSeconds int) error

WaitForServerCreation waits for a server to be fully created using a time ticker

type XimeraProvider added in v0.0.16

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

XimeraProvider implements the Provider interface for Ximera

func NewXimeraProvider added in v0.0.16

func NewXimeraProvider() (*XimeraProvider, error)

NewXimeraProvider creates a new Ximera provider instance

func (*XimeraProvider) ConfigureProvider added in v0.0.16

func (p *XimeraProvider) ConfigureProvider(_ interface{}) error

ConfigureProvider configures the provider with the given stack (no-op for ximera)

func (*XimeraProvider) CreateInstance added in v0.0.16

func (p *XimeraProvider) CreateInstance(_ context.Context, req *types.InstanceRequest) error

CreateInstance creates a new instance using Ximera

func (*XimeraProvider) DeleteInstance added in v0.0.16

func (p *XimeraProvider) DeleteInstance(_ context.Context, providerInstanceID int) error

DeleteInstance deletes an instance using Ximera

func (*XimeraProvider) GetEnvironmentVars added in v0.0.16

func (p *XimeraProvider) GetEnvironmentVars() map[string]string

GetEnvironmentVars returns the environment variables needed for the provider

func (*XimeraProvider) ValidateCredentials added in v0.0.16

func (p *XimeraProvider) ValidateCredentials() error

ValidateCredentials validates the Ximera credentials

Directories

Path Synopsis
Package types provides interface definitions for compute providers
Package types provides interface definitions for compute providers

Jump to

Keyboard shortcuts

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