build/kubernetes: add secret API methods

- add Get and Create secret
- refactor client
- fix example

Change-Id: Ia5c6f17e86cb01aa8093ec058630b40ee61fa74f
Reviewed-on: https://go-review.googlesource.com/21765
Reviewed-by: Evan Brown <evanbrown@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/kubernetes/client_test.go b/kubernetes/client_test.go
index 909da1a..e5e0b60 100644
--- a/kubernetes/client_test.go
+++ b/kubernetes/client_test.go
@@ -4,26 +4,28 @@
 	"log"
 	"net/http"
 
-	api "github.com/kubernetes/kubernetes/pkg/api/v1"
 	"golang.org/x/build/kubernetes"
+	"golang.org/x/build/kubernetes/api"
+	"golang.org/x/net/context"
 	"golang.org/x/oauth2"
 )
 
-func ExampleRun() {
-	kube, err := kubernetes.NewClient("example.com", &http.Client{
+func ExampleRunPod() {
+	kube, err := kubernetes.NewClient("https://example.com", &http.Client{
 		Transport: &oauth2.Transport{
 			Source: oauth2.StaticTokenSource(&oauth2.Token{AccessToken: "aCcessWbU3toKen"}),
-		}})
+		},
+	})
 	if err != nil {
 		log.Fatalf("failed to create client: %v", err)
 	}
-	kube.Run(&api.Pod{
+	podResult, err := kube.RunLongLivedPod(context.Background(), &api.Pod{
 		TypeMeta: api.TypeMeta{
-			APIVersion: "v1beta3",
+			APIVersion: "v1",
 			Kind:       "Pod",
 		},
 		ObjectMeta: api.ObjectMeta{
-			Name: "my-nginx-pod",
+			Name: "redis-pod-example",
 			Labels: map[string]string{
 				"tag": "prod",
 			},
@@ -31,10 +33,19 @@
 		Spec: api.PodSpec{
 			Containers: []api.Container{
 				{
-					Name:  "my-nginx-container",
-					Image: "nginx:latest",
+					Name:  "redis-container",
+					Image: "redis:alpine",
 				},
 			},
 		},
 	})
+	if err != nil {
+		log.Fatalf("failed to run pod: %v", err)
+	}
+	log.Printf("pod created: %#v", podResult)
+	logs, err := kube.PodLog(context.Background(), "redis-pod-example")
+	if err != nil {
+		log.Fatalf("failed to get pod logs: %v", err)
+	}
+	log.Printf("pod logs: %q", logs)
 }