utils

package
v0.0.0-...-9e55d38 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChooseProject

func ChooseProject(cfg *GcpConfig)

GetProject gets the GCP project ID from GCP credentials.

func ChooseZone

func ChooseZone(cfg *GcpConfig)

func ConnectCompute

func ConnectCompute()

func Execute

func Execute(cfg *GcpConfig, operation Operation) int

func ExecuteParallel

func ExecuteParallel(cfg *GcpConfig, operations map[string]Operation) int

func ExpandNetworkPrefix

func ExpandNetworkPrefix(prefix string) (addrs []netip.Addr, err error)

func GetInstancesFromMIG

func GetInstancesFromMIG(cfg *GcpConfig) (map[string]*GceInstance, error)

func ListInstanceGroups

func ListInstanceGroups(cfg *GcpConfig) (names []string, err error)

func ListInstancesInGroup

func ListInstancesInGroup(cfg *GcpConfig) (names []string, err error)

func StartWorkers

func StartWorkers(cfg *GcpConfig, workers uint)

func UpdateAliasIPs

func UpdateAliasIPs(cfg *GcpConfig, instance *GceInstance, ips []string) error

func WaitForUpdate

func WaitForUpdate(cfg *GcpConfig, instanceName string, newState []string)

func Worker

func Worker(i int, cfg *GcpConfig, in chan Operation, out chan int)

Types

type GceInstance

type GceInstance struct {
	Name               string
	NetworkInterface   string
	NetworkFingerprint string
	AliasNetwork       string
	AliasIps           *[]string
}

func GetInstance

func GetInstance(cfg *GcpConfig, name string) (*GceInstance, error)

type GcpConfig

type GcpConfig struct {
	Project          string
	Zone             string
	GceInstanceGroup string
	AliasNetwork     string
	WaitSeconds      uint
}

type Operation

type Operation struct {
	Type     Type
	Instance *GceInstance
	Ips      []string
}

type Type

type Type int
const (
	Add Type = iota
	Remove
)

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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