Merge pull request #3875 from vmarmol/metadata

Using metadata library for GCE metadata fetch.
This commit is contained in:
Alex Mohr 2015-01-28 16:38:43 -08:00
commit dff727c50b

View File

@ -37,6 +37,7 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
"golang.org/x/oauth2" "golang.org/x/oauth2"
"golang.org/x/oauth2/google" "golang.org/x/oauth2/google"
"google.golang.org/cloud/compute/metadata"
) )
// GCECloud is an implementation of Interface, TCPLoadBalancer and Instances for Google Compute Engine. // GCECloud is an implementation of Interface, TCPLoadBalancer and Instances for Google Compute Engine.
@ -72,8 +73,7 @@ func getMetadata(url string) (string, error) {
} }
func getProjectAndZone() (string, string, error) { func getProjectAndZone() (string, string, error) {
url := "http://metadata/computeMetadata/v1/instance/zone" result, err := metadata.Get("instance/zone")
result, err := getMetadata(url)
if err != nil { if err != nil {
return "", "", err return "", "", err
} }
@ -85,8 +85,7 @@ func getProjectAndZone() (string, string, error) {
} }
func getInstanceID() (string, error) { func getInstanceID() (string, error) {
url := "http://metadata/computeMetadata/v1/instance/hostname" result, err := metadata.Get("instance/hostname")
result, err := getMetadata(url)
if err != nil { if err != nil {
return "", err return "", err
} }