package metadata

Import Path
	cloud.google.com/go/compute/metadata (on go.dev)

Dependency Relation
	imports 12 packages, and imported by 6 packages

Involved Source Files 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.
Package-Level Type Names (total 4, in which 3 are exported)
/* sort exporteds by: | */
A Client provides metadata. Email returns the email address associated with the service account. The account may be empty or the string "default" to use the instance's main account. ExternalIP returns the instance's primary external (public) IP address. 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. Hostname returns the instance's hostname. This will be of the form "<instanceID>.c.<projID>.internal". 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. 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. InstanceID returns the current VM's numeric instance ID. InstanceName returns the current VM's instance ID string. InstanceTags returns the list of user-defined instance tags, assigned when initially creating a GCE instance. InternalIP returns the instance's primary internal IP address. NumericProjectID returns the current instance's numeric project ID. 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. 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. ProjectID returns the current instance's project ID string. 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. Subscribe subscribes to a value from the metadata service. The suffix is appended to "http://${GCE_METADATA_HOST}/computeMetadata/v1/". The suffix may contain query parameters. Subscribe calls fn with the latest metadata value indicated by the provided suffix. If the metadata value is deleted, fn is called with the empty string and ok false. Subscribe blocks until fn returns a non-nil error or the value is deleted. Subscribe returns the error value returned from the last call to fn, which may be nil when ok == false. Zone returns the current VM's zone, such as "us-central1-b". func NewClient(c *http.Client) *Client
Error contains an error response from the server. Code is the HTTP response status code. Message is the server response message. (*T) Error() string *T : error
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. ( T) Error() string T : error
Package-Level Functions (total 23, in which 19 are exported)
Email calls Client.Email on the default client.
ExternalIP returns the instance's primary external (public) IP address.
Get calls Client.Get on the default client.
Hostname returns the instance's hostname. This will be of the form "<instanceID>.c.<projID>.internal".
InstanceAttributes calls Client.InstanceAttributes on the default client.
InstanceAttributeValue calls Client.InstanceAttributeValue on the default client.
InstanceID returns the current VM's numeric instance ID.
InstanceName returns the current VM's instance ID string.
InstanceTags returns the list of user-defined instance tags, assigned when initially creating a GCE instance.
InternalIP returns the instance's primary internal IP address.
NewClient returns a Client that can be used to fetch metadata. Returns the client that uses the specified http.Client for HTTP requests. If nil is specified, returns the default client.
NumericProjectID returns the current instance's numeric project ID.
OnGCE reports whether this process is running on Google Compute Engine.
ProjectAttributes calls Client.ProjectAttributes on the default client.
ProjectAttributeValue calls Client.ProjectAttributeValue on the default client.
ProjectID returns the current instance's project ID string.
Scopes calls Client.Scopes on the default client.
Subscribe calls Client.Subscribe on the default client.
Zone returns the current VM's zone, such as "us-central1-b".
Package-Level Variables (total 6, none are exported)
Package-Level Constants (total 3, none are exported)