metadata

package
v1.0.1-0...-664d2ef Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2015 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package metadata provides access to Google Compute Engine (GCE) metadata and API service accounts.

This package is a wrapper around the GCE metadata service, as documented at https://developers.google.com/compute/docs/metadata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExternalIP

func ExternalIP() (string, error)

ExternalIP returns the instance's primary external (public) IP address.

func Get

func Get(suffix string) (string, error)

Get returns a value from the metadata service. The suffix is appended to "http://metadata/computeMetadata/v1/".

If the requested metadata is not defined, the returned error will be of type NotDefinedError.

func Hostname

func Hostname() (string, error)

Hostname returns the instance's hostname. This will probably be of the form "INSTANCENAME.c.PROJECT.internal" but that isn't guaranteed.

TODO: what is this defined to be? Docs say "The host name of the instance."

func InstanceAttributeValue

func InstanceAttributeValue(attr string) (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.

func InstanceAttributes

func InstanceAttributes() ([]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.

func InstanceID

func InstanceID() (string, error)

InstanceID returns the current VM's numeric instance ID.

func InstanceTags

func InstanceTags() ([]string, error)

InstanceTags returns the list of user-defined instance tags, assigned when initially creating a GCE instance.

func InternalIP

func InternalIP() (string, error)

InternalIP returns the instance's primary internal IP address.

func NumericProjectID

func NumericProjectID() (string, error)

NumericProjectID returns the current instance's numeric project ID.

func OnGCE

func OnGCE() bool

OnGCE reports whether this process is running on Google Compute Engine.

func ProjectAttributeValue

func ProjectAttributeValue(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.

func ProjectAttributes

func ProjectAttributes() ([]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.

func ProjectID

func ProjectID() (string, error)

ProjectID returns the current instance's project ID string.

func Scopes

func Scopes(serviceAccount 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.

Types

type NotDefinedError

type NotDefinedError string

NotDefinedError is returned when requested metadata is not defined.

The underlying string is the suffix after "/computeMetadata/v1/".

This error is not returned if the value is defined to be the empty string.

func (NotDefinedError) Error

func (suffix NotDefinedError) Error() string

Jump to

Keyboard shortcuts

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