provider/gce/gce_discover.go
func lookupProject() (string, error) {
	req, err := http.NewRequest("GET", "http://metadata.google.internal/computeMetadata/v1/project/project-id", nil)
	if err != nil {
		return "", err
	}
	req.Header.Add("Metadata-Flavor", "Google")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		return "", err
	}
	defer resp.Body.Close()

	if resp.StatusCode != 200 {
		return "", fmt.Errorf("discover-gce: invalid status code %d when fetching project id", resp.StatusCode)
	}

	project, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return "", err
	}
	return string(project), nil
}
func lookupProject() (string, error) {
	req, err := http.NewRequest("GET", "http://metadata.google.internal/computeMetadata/v1/project/project-id", nil)
	if err != nil {
		return "", err
	}
	req.Header.Add("Metadata-Flavor", "Google")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		return "", err
	}
	defer resp.Body.Close()

	if resp.StatusCode != 200 {
		return "", fmt.Errorf("discover-gce: invalid status code %d when fetching project id", resp.StatusCode)
	}

	project, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return "", err
	}
	return string(project), nil
}
func lookupProject ( ) ( string , error ) { req , err := http . NewRequest ( " " , " " , nil ) if err != nil { return " " , err } req . Header . Add ( " " , " " ) resp , err := http . DefaultClient . Do ( req ) if err != nil { return " " , err } defer resp . Body . Close ( ) if resp . StatusCode != 200 { return " " , fmt . Errorf ( " " , resp . StatusCode ) } project , err := ioutil . ReadAll ( resp . Body ) if err != nil { return " " , err } return string ( project ) , nil }
// lookupProject retrieves the project name from the metadata of the current node.
lookupProject retrieves the project name from the metadata of the current node .