gcloud

package
v0.0.0-...-a355528 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EnvProject is the environment variable that defines the default GCP project
	EnvProject = "CLOUDSDK_CORE_PROJECT"

	// EnvZone is the environment variable that defines the default GCP zone
	EnvZone = "CLOUDSDK_COMPUTE_ZONE"
)

Variables

This section is empty.

Functions

func HasDifferentTag

func HasDifferentTag(expected, actual map[string]string) bool

HasDifferentTag compares two sets of tags.

func MetaDataToTags

func MetaDataToTags(metaData []*compute.MetadataItems) map[string]string

MetaDataToTags converts VM Metadata items into a tag map.

func TagsToMetaData

func TagsToMetaData(tags map[string]string) []*compute.MetadataItems

TagsToMetaData converts a tag map into VM Metadata items.

Types

type API

type API interface {
	// GetProject returns the project name.
	GetProject() string

	// GetZone returns the zone short name.
	GetZone() string

	// ListInstances lists the instances.
	ListInstances() ([]*compute.Instance, error)

	// GetInstance find an instance by name.
	GetInstance(name string) (*compute.Instance, error)

	// CreateInstance creates an instance.
	CreateInstance(name string, settings *InstanceSettings) error

	// AddInstanceToTargetPool adds a list of instances to a target pool.
	AddInstanceToTargetPool(targetPool string, instances ...string) error

	// AddInstanceMetadata replaces/adds metadata items to an instance
	AddInstanceMetadata(instanceName string, items []*compute.MetadataItems) error

	// DeleteInstance deletes an instance.
	DeleteInstance(name string) error

	// DeleteInstanceGroupManager deletes an instance group manager.
	DeleteInstanceGroupManager(name string) error

	// DeleteInstanceTemplate deletes an instance template.
	DeleteInstanceTemplate(name string) error

	// ListInstanceGroupInstances lists the instances of an instance group found by its name.
	ListInstanceGroupInstances(name string) ([]*compute.InstanceWithNamedPorts, error)

	// CreateInstanceTemplate creates an instance template
	CreateInstanceTemplate(name string, settings *InstanceSettings) error

	// CreateInstanceGroupManager creates an instance group manager.
	CreateInstanceGroupManager(name string, settings *InstanceManagerSettings) error

	// SetInstanceTemplate sets the instance template used by a group manager.
	SetInstanceTemplate(name string, templateName string) error

	// ResizeInstanceGroupManager changes the target size of an instance group manager.
	ResizeInstanceGroupManager(name string, targetSize int64) error
}

API is the list of operations that can execute on Google Cloud Platform.

func NewAPI

func NewAPI(project, zone string) (API, error)

NewAPI creates a new API instance.

type APIMetadata

type APIMetadata interface {
	// Get returns a value from the metadata service.
	// The suffix is appended to "http://${GCE_METADATA_HOST}/computeMetadata/v1/".
	//
	// If the GCE_METADATA_HOST environment variable is not defined, a default of
	// 169.254.169.254 will be used instead.
	//
	// If the requested metadata is not defined, the returned error will
	// be of type NotDefinedError.
	Get(suffix string) (string, error)

	// ProjectID returns the current instance's project ID string.
	ProjectID() (string, error)

	// NumericProjectID returns the current instance's numeric project ID.
	NumericProjectID() (string, error)

	// InternalIP returns the instance's primary internal IP address.
	InternalIP() (string, error)

	// ExternalIP returns the instance's primary external (public) IP address.
	ExternalIP() (string, error)

	// Hostname returns the instance's hostname. This will be of the form
	// "<instanceID>.c.<projID>.internal".
	Hostname() (string, error)

	// InstanceTags returns the list of user-defined instance tags,
	// assigned when initially creating a GCE instance.
	InstanceTags() ([]string, error)

	// InstanceID returns the current VM's numeric instance ID.
	InstanceID() (string, error)

	// InstanceName returns the current VM's instance ID string.
	InstanceName() (string, error)

	// Zone returns the current VM's zone, such as "us-central1-b".
	Zone() (string, error)

	// InstanceAttributes returns the list of user-defined attributes,
	// assigned when initially creating a GCE VM instance. The value of an
	// attribute can be obtained with InstanceAttributeValue.
	InstanceAttributes() ([]string, error)

	// ProjectAttributes returns the list of user-defined attributes
	// applying to the project as a whole, not just this VM.  The value of
	// an attribute can be obtained with ProjectAttributeValue.
	ProjectAttributes() ([]string, error)

	// InstanceAttributeValue returns the value of the provided VM
	// instance attribute.
	//
	// If the requested attribute is not defined, the returned error will
	// be of type NotDefinedError.
	//
	// InstanceAttributeValue may return ("", nil) if the attribute was
	// defined to be the empty string.
	InstanceAttributeValue(attr string) (string, error)

	// ProjectAttributeValue returns the value of the provided
	// project attribute.
	//
	// If the requested attribute is not defined, the returned error will
	// be of type NotDefinedError.
	//
	// ProjectAttributeValue may return ("", nil) if the attribute was
	// defined to be the empty string.
	ProjectAttributeValue(attr string) (string, error)

	// Scopes returns the service account scopes for the given account.
	// The account may be empty or the string "default" to use the instance's
	// main account.
	Scopes(serviceAccount string) ([]string, error)
}

APIMetadata gives access to the GCE metadata service.

func NewAPIMetadata

func NewAPIMetadata() APIMetadata

NewAPIMetadata creates a new APIMetadata instance.

type ByKey

type ByKey []*compute.MetadataItems

ByKey implements sort.Interface for []*compute.MetadataItems based on the Key field.

func (ByKey) Len

func (a ByKey) Len() int

func (ByKey) Less

func (a ByKey) Less(i, j int) bool

func (ByKey) Swap

func (a ByKey) Swap(i, j int)

type Call

type Call interface {
	Do(opts ...googleapi.CallOption) (*compute.Operation, error)
}

Call is an async Google Api call

type DiskSettings

type DiskSettings struct {
	Boot          bool
	Type          string
	Mode          string
	SizeGb        int64
	Image         string
	AutoDelete    bool
	ReuseExisting bool
	NameSuffix    string
}

DiskSettings lists the characteristics of an attached disk.

type InstanceManagerSettings

type InstanceManagerSettings struct {
	Description      string
	TemplateName     string
	TargetSize       int64
	TargetPools      []string
	BaseInstanceName string
}

InstanceManagerSettings the characteristics of a VM instance template manager.

type InstanceSettings

type InstanceSettings struct {
	Description string
	MachineType string
	Network     string
	Subnetwork  string
	PrivateIP   string
	Tags        []string
	Scopes      []string
	Disks       []DiskSettings
	Preemptible bool
	MetaData    []*compute.MetadataItems
}

InstanceSettings lists the characteristics of a VM instance.

Jump to

Keyboard shortcuts

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