gcp

package
v1.22.6 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package gcp provides Google Cloud Platform integration utilities.

Package gcp provides Google Cloud Platform integration for Lux CLI.

Index

Constants

This section is empty.

Variables

View Source
var ErrNodeNotFoundToBeRunning = errors.New("node not found to be running")

ErrNodeNotFoundToBeRunning is returned when a node is not found in running state.

Functions

This section is empty.

Types

type GcpCloud

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

GcpCloud provides GCP cloud operations.

func NewGcpCloud

func NewGcpCloud(ctx context.Context, gcpClient *compute.Service, projectID string) (*GcpCloud, error)

NewGcpCloud creates a GCP cloud.

func (*GcpCloud) AddFirewall

func (c *GcpCloud) AddFirewall(publicIP, networkName, projectName, firewallName string, ports []string, checkMonitoring bool) error

AddFirewall adds firewall into an existing project in GCP

func (*GcpCloud) ChangeInstanceType

func (c *GcpCloud) ChangeInstanceType(instanceID, zone, machineType string) error

ChangeInstanceType changes the instance type of the instance on-the-fly

func (*GcpCloud) CheckFirewallExists

func (c *GcpCloud) CheckFirewallExists(firewallName string, checkMonitoring bool) (bool, error)

CheckFirewallExists checks that firewall firewallName exists in GCP project projectName

func (*GcpCloud) CheckNetworkExists

func (c *GcpCloud) CheckNetworkExists(networkName string) (bool, error)

CheckNetworkExists checks that network networkName exists in GCP project projectName

func (*GcpCloud) DestroyGCPNode

func (c *GcpCloud) DestroyGCPNode(nodeConfig models.NodeConfig, clusterName string) error

DestroyGCPNode terminates GCP node in GCP

func (*GcpCloud) GetInstancePublicIPs

func (c *GcpCloud) GetInstancePublicIPs(zone string, nodeIDs []string) (map[string]string, error)

GetInstancePublicIPs gets public IP(s) of GCP instance(s) without static IP and returns a map with gcp instance id as key and public ip as value

func (*GcpCloud) GetRandomZone

func (c *GcpCloud) GetRandomZone(region string) (string, error)

GetRandomZone returns a random zone in the specified region.

func (*GcpCloud) GetRootVolumeID

func (c *GcpCloud) GetRootVolumeID(instanceID string, zone string) (string, error)

ListAttachedVolumes returns a list of attached volumes to the instance excluding the boot volume

func (*GcpCloud) GetUbuntuImageID

func (c *GcpCloud) GetUbuntuImageID() (string, error)

func (*GcpCloud) IsInstanceTypeSupported

func (c *GcpCloud) IsInstanceTypeSupported(machineType string, zone string) (bool, error)

IsInstanceTypeSupported checks if the machine type is supported in the zone

func (*GcpCloud) ListRegions

func (c *GcpCloud) ListRegions() []string

ListRegions returns a list of regions for the GcpCloud instance.

func (*GcpCloud) ListZonesInRegion

func (c *GcpCloud) ListZonesInRegion(region string) ([]string, error)

ListZonesInRegion returns a list of zones in a specific region for a given project ID.

func (*GcpCloud) ResizeVolume

func (c *GcpCloud) ResizeVolume(volumeID string, zone string, newSizeGb int64) error

ResizeVolume resizes the volume to the new size

func (*GcpCloud) SetFirewallRule

func (c *GcpCloud) SetFirewallRule(ipAddress, firewallName, networkName string, ports []string) (*compute.Firewall, error)

SetFirewallRule creates a new firewall rule in GCP

func (*GcpCloud) SetPublicIP

func (c *GcpCloud) SetPublicIP(zone, nodeName string, numNodes int) ([]string, error)

SetPublicIP creates a static IP in GCP

func (*GcpCloud) SetupInstances

func (c *GcpCloud) SetupInstances(
	cliDefaultName,
	zone,
	networkName,
	sshPublicKey,
	ami,
	instancePrefix,
	instanceType string,
	staticIP []string,
	numNodes int,
	forMonitoring bool,
) ([]*compute.Instance, error)

SetupInstances creates GCP instances

func (*GcpCloud) SetupNetwork

func (c *GcpCloud) SetupNetwork(ipAddress, networkName string) (*compute.Network, error)

SetupNetwork creates a new network in GCP

Jump to

Keyboard shortcuts

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