gcp

package
v0.0.0-...-6054725 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const GCPStorageURL string = "https://storage.googleapis.com/%v/%v"

GCPStorageURL is GCP storage path

View Source
const ProviderName = "gcp"

ProviderName of the cloud platform provider

Variables

This section is empty.

Functions

This section is empty.

Types

type GCloud

type GCloud struct {
	Storage   *Storage
	Service   *compute.Service
	ProjectID string
	Zone      string
	// contains filtered or unexported fields
}

GCloud Provider to interact with GCP cloud infrastructure

func NewProvider

func NewProvider() *GCloud

NewProvider GCP

func (*GCloud) AttachVolume

func (g *GCloud) AttachVolume(ctx *lepton.Context, image, name string, attachID int) error

AttachVolume attaches Compute Engine Disk volume to existing instance

func (*GCloud) BuildImage

func (p *GCloud) BuildImage(ctx *lepton.Context) (string, error)

BuildImage to be upload on GCP

func (*GCloud) BuildImageWithPackage

func (p *GCloud) BuildImageWithPackage(ctx *lepton.Context, pkgpath string) (string, error)

BuildImageWithPackage to upload on GCP

func (*GCloud) CreateImage

func (p *GCloud) CreateImage(ctx *lepton.Context, imagePath string) error

CreateImage - Creates image on GCP using nanos images TODO : re-use and cache DefaultClient and instances.

func (*GCloud) CreateInstance

func (p *GCloud) CreateInstance(ctx *lepton.Context) error

CreateInstance - Creates instance on Google Cloud Platform

func (*GCloud) CreateSubnet

func (p *GCloud) CreateSubnet(computeService *compute.Service, project string, region string, name string, vpc *compute.Network) (network *compute.Subnetwork, err error)

CreateSubnet creates a subnet with the name specified TODO: Specify required subnet IpCidrRange without overlapping other subnetworks ip range. Requires fetching every subnet and find an unused Ip range

func (*GCloud) CreateVPC

func (p *GCloud) CreateVPC(computeService *compute.Service, project string, name string) (network *compute.Network, err error)

CreateVPC creates a legacy virtual network with the name specified

func (*GCloud) CreateVolume

func (g *GCloud) CreateVolume(ctx *lepton.Context, name, data, provider string) (lepton.NanosVolume, error)

CreateVolume creates local volume and converts it to GCP format before orchestrating the necessary upload procedures

func (*GCloud) CreateZoneRecord

func (p *GCloud) CreateZoneRecord(config *types.Config, zoneID string, record *lepton.DNSRecord) error

CreateZoneRecord creates a record in a DNS zone

func (*GCloud) CustomizeImage

func (p *GCloud) CustomizeImage(ctx *lepton.Context) (string, error)

CustomizeImage returns image path with adaptations needed by cloud provider

func (*GCloud) DeleteImage

func (p *GCloud) DeleteImage(ctx *lepton.Context, imagename string) error

DeleteImage deletes image from Gcloud

func (*GCloud) DeleteInstance

func (p *GCloud) DeleteInstance(ctx *lepton.Context, instancename string) error

DeleteInstance deletes instance from Gcloud

func (*GCloud) DeleteVolume

func (g *GCloud) DeleteVolume(ctx *lepton.Context, name string) error

DeleteVolume deletes specific disk and image in GCP

func (*GCloud) DeleteZoneRecordIfExists

func (p *GCloud) DeleteZoneRecordIfExists(config *types.Config, zoneID string, recordName string) error

DeleteZoneRecordIfExists deletes a record from a DNS zone if it exists

func (*GCloud) DetachVolume

func (g *GCloud) DetachVolume(ctx *lepton.Context, image, volumeName string) error

DetachVolume detaches Compute Engine Disk volume from existing instance

func (*GCloud) FindOrCreateZoneIDByName

func (p *GCloud) FindOrCreateZoneIDByName(config *types.Config, dnsName string) (string, error)

FindOrCreateZoneIDByName searches for a DNS zone with the name passed by argument and if it doesn't exist it creates one

func (*GCloud) GetAllVolumes

func (g *GCloud) GetAllVolumes(ctx *lepton.Context) (*[]lepton.NanosVolume, error)

GetAllVolumes gets all volumes created in GCP as Compute Engine Disks

func (*GCloud) GetImages

func (p *GCloud) GetImages(ctx *lepton.Context) ([]lepton.CloudImage, error)

GetImages return all images on GCloud

func (*GCloud) GetInstanceByName

func (p *GCloud) GetInstanceByName(ctx *lepton.Context, name string) (*lepton.CloudInstance, error)

GetInstanceByName returns instance with given name

func (*GCloud) GetInstanceLogs

func (p *GCloud) GetInstanceLogs(ctx *lepton.Context, instancename string) (string, error)

GetInstanceLogs gets instance related logs

func (*GCloud) GetInstances

func (p *GCloud) GetInstances(ctx *lepton.Context) ([]lepton.CloudInstance, error)

GetInstances return all instances on GCloud

func (*GCloud) GetStorage

func (p *GCloud) GetStorage() lepton.Storage

GetStorage returns storage interface for cloud provider

func (*GCloud) GetSubnet

func (p *GCloud) GetSubnet(computeService *compute.Service, project string, region string, vpc string, name string) (subnet *compute.Subnetwork, err error)

GetSubnet returns the subnet in vpc with the name specified

func (*GCloud) GetVPC

func (p *GCloud) GetVPC(computeService *compute.Service, project string, name string) (network *compute.Network, err error)

GetVPC returns the vpc with the name specified

func (*GCloud) Initialize

func (p *GCloud) Initialize(config *types.ProviderConfig) error

Initialize GCP related things

func (*GCloud) ListImages

func (p *GCloud) ListImages(ctx *lepton.Context) error

ListImages lists images on Google Cloud

func (*GCloud) ListInstances

func (p *GCloud) ListInstances(ctx *lepton.Context) error

ListInstances lists instances on Gcloud

func (*GCloud) PrintInstanceLogs

func (p *GCloud) PrintInstanceLogs(ctx *lepton.Context, instancename string, watch bool) error

PrintInstanceLogs writes instance logs to console

func (*GCloud) RebootInstance

func (p *GCloud) RebootInstance(ctx *lepton.Context, instancename string) error

RebootInstance reboots the instance.

func (*GCloud) ResetInstance

func (p *GCloud) ResetInstance(ctx *lepton.Context, instancename string) error

ResetInstance resets instance

func (*GCloud) ResizeImage

func (p *GCloud) ResizeImage(ctx *lepton.Context, imagename string, hbytes string) error

ResizeImage is not supported on google cloud.

func (*GCloud) StartInstance

func (p *GCloud) StartInstance(ctx *lepton.Context, instancename string) error

StartInstance starts an instance in GCloud

func (*GCloud) StopInstance

func (p *GCloud) StopInstance(ctx *lepton.Context, instancename string) error

StopInstance stops instance

func (*GCloud) SyncImage

func (p *GCloud) SyncImage(config *types.Config, target lepton.Provider, image string) error

SyncImage syncs image from provider to another provider

type GCloudOperation

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

GCloudOperation status check

type Storage

type Storage struct{}

Storage provides GCP storage related operations

func (*Storage) CopyToBucket

func (s *Storage) CopyToBucket(config *types.Config, archPath string) error

CopyToBucket copies archive to bucket

func (*Storage) DeleteFromBucket

func (s *Storage) DeleteFromBucket(config *types.Config, archPath string) error

DeleteFromBucket delete archive from bucket

Jump to

Keyboard shortcuts

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