Skip to content

Commit

Permalink
Merge pull request #40848 from smarterclayton/serverside_get
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue (batch tested with PRs 46432, 46701, 46326, 40848, 46396)

Add a server side Get operation

Implement proposal kubernetes/community#363

```release-note
The Kubernetes API supports retrieving tabular output for API resources via a new mime-type `application/json;as=Table;v=v1alpha1;g=meta.k8s.io`.  The returned object (if the server supports it) will be of type `meta.k8s.io/v1alpha1` with `Table`, and contain column and row information related to the resource.  Each row will contain information about the resource - by default it will be the object metadata, but callers can add the `?includeObject=Object` query parameter and receive the full object.  In the future kubectl will use this to retrieve the results of `kubectl get`.
```
  • Loading branch information
Kubernetes Submit Queue authored Jun 2, 2017
2 parents f5bcd98 + 7ce63eb commit 97a5d37
Show file tree
Hide file tree
Showing 42 changed files with 2,067 additions and 269 deletions.
6 changes: 6 additions & 0 deletions hack/lib/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ kube::util::group-version-to-pkg-path() {
meta/v1)
echo "../vendor/k8s.io/apimachinery/pkg/apis/meta/v1"
;;
meta/v1alpha1)
echo "vendor/k8s.io/apimachinery/pkg/apis/meta/v1alpha1"
;;
meta/v1alpha1)
echo "../vendor/k8s.io/apimachinery/pkg/apis/meta/v1alpha1"
;;
unversioned)
echo "pkg/api/unversioned"
;;
Expand Down
2 changes: 1 addition & 1 deletion hack/update-generated-swagger-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ source "${KUBE_ROOT}/hack/lib/swagger.sh"

kube::golang::setup_env

GROUP_VERSIONS=(meta/v1 ${KUBE_AVAILABLE_GROUP_VERSIONS})
GROUP_VERSIONS=(meta/v1 meta/v1alpha1 ${KUBE_AVAILABLE_GROUP_VERSIONS})

# To avoid compile errors, remove the currently existing files.
for group_version in "${GROUP_VERSIONS[@]}"; do
Expand Down
19 changes: 10 additions & 9 deletions pkg/kubectl/cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func Example_printReplicationControllerWithNamespace() {
},
}
mapper, _ := f.Object()
err := f.PrintObject(cmd, mapper, ctrl, os.Stdout)
err := f.PrintObject(cmd, mapper, ctrl, printers.GetNewTabWriter(os.Stdout))
if err != nil {
fmt.Printf("Unexpected error: %v", err)
}
Expand Down Expand Up @@ -247,7 +247,7 @@ func Example_printMultiContainersReplicationControllerWithWide() {
},
}
mapper, _ := f.Object()
err := f.PrintObject(cmd, mapper, ctrl, os.Stdout)
err := f.PrintObject(cmd, mapper, ctrl, printers.GetNewTabWriter(os.Stdout))
if err != nil {
fmt.Printf("Unexpected error: %v", err)
}
Expand Down Expand Up @@ -301,7 +301,7 @@ func Example_printReplicationController() {
},
}
mapper, _ := f.Object()
err := f.PrintObject(cmd, mapper, ctrl, os.Stdout)
err := f.PrintObject(cmd, mapper, ctrl, printers.GetNewTabWriter(os.Stdout))
if err != nil {
fmt.Printf("Unexpected error: %v", err)
}
Expand Down Expand Up @@ -344,7 +344,7 @@ func Example_printPodWithWideFormat() {
},
}
mapper, _ := f.Object()
err := f.PrintObject(cmd, mapper, pod, os.Stdout)
err := f.PrintObject(cmd, mapper, pod, printers.GetNewTabWriter(os.Stdout))
if err != nil {
fmt.Printf("Unexpected error: %v", err)
}
Expand Down Expand Up @@ -390,7 +390,7 @@ func Example_printPodWithShowLabels() {
},
}
mapper, _ := f.Object()
err := f.PrintObject(cmd, mapper, pod, os.Stdout)
err := f.PrintObject(cmd, mapper, pod, printers.GetNewTabWriter(os.Stdout))
if err != nil {
fmt.Printf("Unexpected error: %v", err)
}
Expand Down Expand Up @@ -514,7 +514,7 @@ func Example_printPodHideTerminated() {
}
for _, pod := range filteredPodList {
mapper, _ := f.Object()
err := f.PrintObject(cmd, mapper, pod, os.Stdout)
err := f.PrintObject(cmd, mapper, pod, printers.GetNewTabWriter(os.Stdout))
if err != nil {
fmt.Printf("Unexpected error: %v", err)
}
Expand Down Expand Up @@ -542,7 +542,7 @@ func Example_printPodShowAll() {
cmd := NewCmdRun(f, os.Stdin, os.Stdout, os.Stderr)
podList := newAllPhasePodList()
mapper, _ := f.Object()
err := f.PrintObject(cmd, mapper, podList, os.Stdout)
err := f.PrintObject(cmd, mapper, podList, printers.GetNewTabWriter(os.Stdout))
if err != nil {
fmt.Printf("Unexpected error: %v", err)
}
Expand Down Expand Up @@ -616,9 +616,10 @@ func Example_printServiceWithNamespacesAndLabels() {
}
ld := strings.NewLineDelimiter(os.Stdout, "|")
defer ld.Flush()

out := printers.GetNewTabWriter(ld)
defer out.Flush()
mapper, _ := f.Object()
err := f.PrintObject(cmd, mapper, svc, ld)
err := f.PrintObject(cmd, mapper, svc, out)
if err != nil {
fmt.Printf("Unexpected error: %v", err)
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/printers/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ go_library(
"//pkg/util/slice:go_default_library",
"//vendor/github.com/fatih/camelcase:go_default_library",
"//vendor/github.com/ghodss/yaml:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1alpha1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
"//vendor/k8s.io/client-go/util/jsonpath:go_default_library",
],
)
Expand Down Expand Up @@ -63,6 +65,7 @@ filegroup(
srcs = [
":package-srcs",
"//pkg/printers/internalversion:all-srcs",
"//pkg/printers/storage:all-srcs",
],
tags = ["automanaged"],
)
Expand Down
Loading

0 comments on commit 97a5d37

Please sign in to comment.