in plugin/http_client.go [42:75]
func NewHTTPClient(ctx context.Context, pathToGCEConf string) (*http.Client, error) {
if pathToGCEConf != "" {
r, err := os.Open(pathToGCEConf)
if err != nil {
return nil, fmt.Errorf("failed to open GCE Config: %s", pathToGCEConf)
}
defer r.Close()
c, err := readConfig(r)
if err != nil {
return nil, err
}
if (tokenConfig{} == *c) {
glog.Infof("Since TokenConfig contains neither TokenURI nor TokenBody assuming that running on GCE (ex. via kube-up.sh)")
return getDefaultClient(ctx)
}
// Running on GKE Hosted Master
glog.Infof("TokenURI:%s, TokenBody:%s - assuming that running on a Hosted Master - GKE.", c.Global.TokenURL, c.Global.TokenBody)
a := newAltTokenSource(ctx, c.Global.TokenURL, c.Global.TokenBody)
// TODO: Do I need to call a.Token to get access token here?
if _, err := a.Token(); err != nil {
glog.Errorf("error fetching initial token: %v", err)
return nil, err
}
return oauth2.NewClient(ctx, a), nil
}
glog.Infof("Path to gce.conf was not supplied - assuming that need to rely on exported service account key.")
return getDefaultClient(ctx)
}