Add context object to kubecfg/client

This commit is contained in:
derekwaynecarr
2014-09-30 14:27:19 -04:00
parent 33afc2f210
commit b7b1193919
6 changed files with 25 additions and 12 deletions

View File

@@ -27,6 +27,7 @@ import (
"strings"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
"github.com/GoogleCloudPlatform/kubernetes/pkg/capabilities"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
@@ -126,7 +127,8 @@ func main() {
Port: *minionPort,
}
client, err := client.New(net.JoinHostPort(*address, strconv.Itoa(int(*port))), *storageVersion, nil)
ctx := api.NewContext()
client, err := client.New(ctx, net.JoinHostPort(*address, strconv.Itoa(int(*port))), *storageVersion, nil)
if err != nil {
glog.Fatalf("Invalid server address: %v", err)
}

View File

@@ -27,6 +27,7 @@ import (
"strconv"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/controller"
@@ -53,8 +54,8 @@ func main() {
if len(*master) == 0 {
glog.Fatal("usage: controller-manager -master <master>")
}
kubeClient, err := client.New(*master, latest.OldestVersion, nil)
ctx := api.NewContext()
kubeClient, err := client.New(ctx, *master, latest.OldestVersion, nil)
if err != nil {
glog.Fatalf("Invalid -master: %v", err)
}

View File

@@ -173,7 +173,11 @@ func main() {
} else {
masterServer = "http://localhost:8080"
}
kubeClient, err := client.New(masterServer, *apiVersion, nil)
// TODO: get the namespace context when kubecfg ns is completed
ctx := api.NewContext()
kubeClient, err := client.New(ctx, masterServer, *apiVersion, nil)
if err != nil {
glog.Fatalf("Can't configure client: %v", err)
}
@@ -194,7 +198,7 @@ func main() {
if *keyFile != "" {
auth.KeyFile = *keyFile
}
kubeClient, err = client.New(masterServer, *apiVersion, auth)
kubeClient, err = client.New(ctx, masterServer, *apiVersion, auth)
if err != nil {
glog.Fatalf("Can't configure client: %v", err)
}

View File

@@ -20,6 +20,7 @@ import (
"flag"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/proxy"
@@ -54,8 +55,9 @@ func main() {
// define api config source
if *master != "" {
glog.Infof("Using api calls to get config %v", *master)
ctx := api.NewContext()
//TODO: add auth info
client, err := client.New(*master, latest.OldestVersion, nil)
client, err := client.New(ctx, *master, latest.OldestVersion, nil)
if err != nil {
glog.Fatalf("Invalid -master: %v", err)
}