Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotOnGCE = errors.New("not on GCE")
ErrNotOnGCE is returned when requesting metadata while not on GCE.
Functions ¶
This section is empty.
Types ¶
type MetadataType ¶
type MetadataType struct { // OnGCE comes from the metadata server OnGCE bool `json:""` // ProjectID comes from the metadata server ProjectID string `json:",omitempty"` // InstanceID comes from the metadata server InstanceID string `json:",omitempty"` // Hostname comes from the metadata server Hostname string `json:",omitempty"` // Zone comes from the metadata server Zone string `json:",omitempty"` // ClusterName comes from the metadata server ClusterName string `json:",omitempty"` // ClusterLocation comes from the metadata server ClusterLocation string `json:",omitempty"` // ClusterUid comes from the metadata server ClusterUid string // InstanceAttributes comes from the metadata server. It is not // included in JSON serialization to prevent sending sensitive data. InstanceAttributes map[string]string `json:"-"` // ProjectAttributes comes from the metadata server. It is not // included in JSON serialization to prevent sending sensitive data. ProjectAttributes map[string]string `json:"-"` // PodName comes from /etc/k8info/pod_name. // PodName can be provided by a Downward API volume. PodName string `json:",omitempty"` // PodNamespace comes from /etc/k8info/pod_namespace. // PodNamespace can be provided by a Downward API volume. PodNamespace string `json:",omitempty"` // PodLabels comes from /etc/k8info/pod_labels. // PodLabels can be provided by a Downward API volume. PodLabels map[string]string `json:",omitempty"` // ContainerName comes from /etc/k8info/container_name ContainerName string `json:",omitempty"` }
MetadataType is structured GCE metadata.
func Metadata ¶
func Metadata() (md *MetadataType, err error)
Metadata returns a cached instance of the GCE metadata. If not on GCE, Metadata() returns ErrNotOnGCE. The data comes from various sources including the GCE metadata server and K8 downward API volumes.
Click to show internal directories.
Click to hide internal directories.