Merge pull request #15351 from caesarxuchao/fix-14584-1

Auto commit by PR queue bot
This commit is contained in:
k8s-merge-robot 2015-10-13 02:19:43 -07:00
commit 2dec0826f7
31 changed files with 4006 additions and 3667 deletions

View File

@ -560,7 +560,7 @@
"allowMultiple": false
},
{
"type": "api.Patch",
"type": "unversioned.Patch",
"paramType": "body",
"name": "body",
"description": "",
@ -1184,7 +1184,7 @@
"allowMultiple": false
},
{
"type": "api.Patch",
"type": "unversioned.Patch",
"paramType": "body",
"name": "body",
"description": "",
@ -1808,7 +1808,7 @@
"allowMultiple": false
},
{
"type": "api.Patch",
"type": "unversioned.Patch",
"paramType": "body",
"name": "body",
"description": "",
@ -2392,7 +2392,7 @@
"allowMultiple": false
},
{
"type": "api.Patch",
"type": "unversioned.Patch",
"paramType": "body",
"name": "body",
"description": "",
@ -2920,7 +2920,7 @@
"allowMultiple": false
},
{
"type": "api.Patch",
"type": "unversioned.Patch",
"paramType": "body",
"name": "body",
"description": "",
@ -3761,7 +3761,7 @@
"allowMultiple": false
},
{
"type": "api.Patch",
"type": "unversioned.Patch",
"paramType": "body",
"name": "body",
"description": "",
@ -4404,7 +4404,7 @@
"allowMultiple": false
},
{
"type": "api.Patch",
"type": "unversioned.Patch",
"paramType": "body",
"name": "body",
"description": "",
@ -4921,7 +4921,7 @@
"allowMultiple": false
},
{
"type": "api.Patch",
"type": "unversioned.Patch",
"paramType": "body",
"name": "body",
"description": "",
@ -7088,7 +7088,7 @@
"allowMultiple": false
},
{
"type": "api.Patch",
"type": "unversioned.Patch",
"paramType": "body",
"name": "body",
"description": "",
@ -7712,7 +7712,7 @@
"allowMultiple": false
},
{
"type": "api.Patch",
"type": "unversioned.Patch",
"paramType": "body",
"name": "body",
"description": "",
@ -8395,7 +8395,7 @@
"allowMultiple": false
},
{
"type": "api.Patch",
"type": "unversioned.Patch",
"paramType": "body",
"name": "body",
"description": "",
@ -9078,7 +9078,7 @@
"allowMultiple": false
},
{
"type": "api.Patch",
"type": "unversioned.Patch",
"paramType": "body",
"name": "body",
"description": "",
@ -9702,7 +9702,7 @@
"allowMultiple": false
},
{
"type": "api.Patch",
"type": "unversioned.Patch",
"paramType": "body",
"name": "body",
"description": "",
@ -10326,7 +10326,7 @@
"allowMultiple": false
},
{
"type": "api.Patch",
"type": "unversioned.Patch",
"paramType": "body",
"name": "body",
"description": "",
@ -11414,8 +11414,9 @@
}
}
},
"api.Patch": {
"id": "api.Patch",
"unversioned.Patch": {
"id": "unversioned.Patch",
"description": "Patch is provided to give a concrete name and type to the Kubernetes PATCH request body.",
"properties": {}
},
"unversioned.Status": {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,106 +0,0 @@
/*
Copyright 2014 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package api
import (
"strings"
)
// This file contains API types that are unversioned.
// APIVersions lists the versions that are available, to allow clients to
// discover the API at /api, which is the root path of the legacy v1 API.
type APIVersions struct {
// versions are the api versions that are available.
Versions []string `json:"versions"`
}
// APIGroupList is a list of APIGroup, to allow clients to discover the API at
// /apis.
type APIGroupList struct {
// groups is a list of APIGroup.
Groups []APIGroup `json:"groups"`
}
// APIGroup contains the name, the supported versions, and the preferred version
// of a group.
type APIGroup struct {
// name is the name of the group.
Name string `json:"name"`
// versions are the versions supported in this group.
Versions []GroupVersion `json:"versions"`
// preferredVersion is the version preferred by the API server, which
// probably is the storage version.
PreferredVersion GroupVersion `json:"preferredVersion,omitempty"`
}
// GroupVersion contains the "group/version" and "version" string of a version.
// It is made a struct to keep extensiblity.
type GroupVersion struct {
// groupVersion specifies the API group and version in the form "group/version"
GroupVersion string `json:"groupVersion"`
// version specifies the version in the form of "version". This is to save
// the clients the trouble of splitting the GroupVersion.
Version string `json:"version"`
}
// APIResource specifies the name of a resource and whether it is namespaced.
type APIResource struct {
// name is the name of the resource.
Name string `json:"name"`
// namespaced indicates if a resource is namespaced or not.
Namespaced bool `json:"namespaced"`
}
// APIResourceList is a list of APIResource, it is used to expose the name of the
// resources supported in a specific group and version, and if the resource
// is namespaced.
type APIResourceList struct {
// groupVersion is the group and version this APIResourceList is for.
GroupVersion string `json:"groupVersion"`
// resources contains the name of the resources and if they are namespaced.
APIResources []APIResource `json:"resources"`
}
// RootPaths lists the paths available at root.
// For example: "/healthz", "/apis".
type RootPaths struct {
// paths are the paths available at root.
Paths []string `json:"paths"`
}
// TODO: remove me when watch is refactored
func LabelSelectorQueryParam(version string) string {
return "labelSelector"
}
// TODO: remove me when watch is refactored
func FieldSelectorQueryParam(version string) string {
return "fieldSelector"
}
// String returns available api versions as a human-friendly version string.
func (apiVersions APIVersions) String() string {
return strings.Join(apiVersions.Versions, ",")
}
func (apiVersions APIVersions) GoString() string {
return apiVersions.String()
}
// Patch is provided to give a concrete name and type to the Kubernetes PATCH request body.
type Patch struct{}

View File

@ -17,6 +17,8 @@ limitations under the License.
// Package unversioned contains API types that are common to all versions.
package unversioned
import "strings"
// TypeMeta describes an individual object in an API response or request
// with strings representing the type of the object and its API schema version.
// Structures that are versioned or persisted should inline TypeMeta.
@ -269,3 +271,86 @@ const (
)
func (*Status) IsAnAPIObject() {}
// APIVersions lists the versions that are available, to allow clients to
// discover the API at /api, which is the root path of the legacy v1 API.
type APIVersions struct {
// versions are the api versions that are available.
Versions []string `json:"versions"`
}
// APIGroupList is a list of APIGroup, to allow clients to discover the API at
// /apis.
type APIGroupList struct {
// groups is a list of APIGroup.
Groups []APIGroup `json:"groups"`
}
// APIGroup contains the name, the supported versions, and the preferred version
// of a group.
type APIGroup struct {
// name is the name of the group.
Name string `json:"name"`
// versions are the versions supported in this group.
Versions []GroupVersion `json:"versions"`
// preferredVersion is the version preferred by the API server, which
// probably is the storage version.
PreferredVersion GroupVersion `json:"preferredVersion,omitempty"`
}
// GroupVersion contains the "group/version" and "version" string of a version.
// It is made a struct to keep extensiblity.
type GroupVersion struct {
// groupVersion specifies the API group and version in the form "group/version"
GroupVersion string `json:"groupVersion"`
// version specifies the version in the form of "version". This is to save
// the clients the trouble of splitting the GroupVersion.
Version string `json:"version"`
}
// APIResource specifies the name of a resource and whether it is namespaced.
type APIResource struct {
// name is the name of the resource.
Name string `json:"name"`
// namespaced indicates if a resource is namespaced or not.
Namespaced bool `json:"namespaced"`
}
// APIResourceList is a list of APIResource, it is used to expose the name of the
// resources supported in a specific group and version, and if the resource
// is namespaced.
type APIResourceList struct {
// groupVersion is the group and version this APIResourceList is for.
GroupVersion string `json:"groupVersion"`
// resources contains the name of the resources and if they are namespaced.
APIResources []APIResource `json:"resources"`
}
// RootPaths lists the paths available at root.
// For example: "/healthz", "/apis".
type RootPaths struct {
// paths are the paths available at root.
Paths []string `json:"paths"`
}
// TODO: remove me when watch is refactored
func LabelSelectorQueryParam(version string) string {
return "labelSelector"
}
// TODO: remove me when watch is refactored
func FieldSelectorQueryParam(version string) string {
return "fieldSelector"
}
// String returns available api versions as a human-friendly version string.
func (apiVersions APIVersions) String() string {
return strings.Join(apiVersions.Versions, ",")
}
func (apiVersions APIVersions) GoString() string {
return apiVersions.String()
}
// Patch is provided to give a concrete name and type to the Kubernetes PATCH request body.
type Patch struct{}

View File

@ -27,6 +27,65 @@ package unversioned
// Those methods can be generated by using hack/update-generated-swagger-docs.sh
// AUTO-GENERATED FUNCTIONS START HERE
var map_APIGroup = map[string]string{
"": "APIGroup contains the name, the supported versions, and the preferred version of a group.",
"name": "name is the name of the group.",
"versions": "versions are the versions supported in this group.",
"preferredVersion": "preferredVersion is the version preferred by the API server, which probably is the storage version.",
}
func (APIGroup) SwaggerDoc() map[string]string {
return map_APIGroup
}
var map_APIGroupList = map[string]string{
"": "APIGroupList is a list of APIGroup, to allow clients to discover the API at /apis.",
"groups": "groups is a list of APIGroup.",
}
func (APIGroupList) SwaggerDoc() map[string]string {
return map_APIGroupList
}
var map_APIResource = map[string]string{
"": "APIResource specifies the name of a resource and whether it is namespaced.",
"name": "name is the name of the resource.",
"namespaced": "namespaced indicates if a resource is namespaced or not.",
}
func (APIResource) SwaggerDoc() map[string]string {
return map_APIResource
}
var map_APIResourceList = map[string]string{
"": "APIResourceList is a list of APIResource, it is used to expose the name of the resources supported in a specific group and version, and if the resource is namespaced.",
"groupVersion": "groupVersion is the group and version this APIResourceList is for.",
"resources": "resources contains the name of the resources and if they are namespaced.",
}
func (APIResourceList) SwaggerDoc() map[string]string {
return map_APIResourceList
}
var map_APIVersions = map[string]string{
"": "APIVersions lists the versions that are available, to allow clients to discover the API at /api, which is the root path of the legacy v1 API.",
"versions": "versions are the api versions that are available.",
}
func (APIVersions) SwaggerDoc() map[string]string {
return map_APIVersions
}
var map_GroupVersion = map[string]string{
"": "GroupVersion contains the \"group/version\" and \"version\" string of a version. It is made a struct to keep extensiblity.",
"groupVersion": "groupVersion specifies the API group and version in the form \"group/version\"",
"version": "version specifies the version in the form of \"version\". This is to save the clients the trouble of splitting the GroupVersion.",
}
func (GroupVersion) SwaggerDoc() map[string]string {
return map_GroupVersion
}
var map_ListMeta = map[string]string{
"": "ListMeta describes metadata that synthetic resources must have, including lists and various status objects. A resource may have only one of {ObjectMeta, ListMeta}.",
"selfLink": "SelfLink is a URL representing this object. Populated by the system. Read-only.",
@ -37,6 +96,23 @@ func (ListMeta) SwaggerDoc() map[string]string {
return map_ListMeta
}
var map_Patch = map[string]string{
"": "Patch is provided to give a concrete name and type to the Kubernetes PATCH request body.",
}
func (Patch) SwaggerDoc() map[string]string {
return map_Patch
}
var map_RootPaths = map[string]string{
"": "RootPaths lists the paths available at root. For example: \"/healthz\", \"/apis\".",
"paths": "paths are the paths available at root.",
}
func (RootPaths) SwaggerDoc() map[string]string {
return map_RootPaths
}
var map_Status = map[string]string{
"": "Status is a return value for calls that don't return other objects.",
"metadata": "Standard list metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds",

View File

@ -29,6 +29,7 @@ import (
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/conversion"
"k8s.io/kubernetes/pkg/runtime"
watchjson "k8s.io/kubernetes/pkg/watch/json"
@ -60,7 +61,7 @@ type documentable interface {
var errEmptyName = errors.NewBadRequest("name must be provided")
// Installs handlers for API resources.
func (a *APIInstaller) Install(ws *restful.WebService) (apiResources []api.APIResource, errors []error) {
func (a *APIInstaller) Install(ws *restful.WebService) (apiResources []unversioned.APIResource, errors []error) {
errors = make([]error, 0)
proxyHandler := (&ProxyHandler{a.prefix + "/proxy/", a.group.Storage, a.group.Codec, a.group.Context, a.info})
@ -99,7 +100,7 @@ func (a *APIInstaller) NewWebService() *restful.WebService {
return ws
}
func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storage, ws *restful.WebService, proxyHandler http.Handler) (*api.APIResource, error) {
func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storage, ws *restful.WebService, proxyHandler http.Handler) (*unversioned.APIResource, error) {
admit := a.group.Admit
context := a.group.Context
@ -266,7 +267,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
params := []*restful.Parameter{}
actions := []action{}
var apiResource api.APIResource
var apiResource unversioned.APIResource
// Get the list of actions for the given scope.
switch scope.Name() {
case meta.RESTScopeNameRoot:
@ -479,7 +480,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
Operation("patch"+namespaced+kind+strings.Title(subresource)).
Produces(append(storageMeta.ProducesMIMETypes(action.Verb), "application/json")...).
Returns(http.StatusOK, "OK", versionedObject).
Reads(api.Patch{}).
Reads(unversioned.Patch{}).
Writes(versionedObject)
addParams(route, action.Params)
ws.Route(route)

View File

@ -36,6 +36,7 @@ import (
"k8s.io/kubernetes/pkg/api/latest"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apiserver/metrics"
"k8s.io/kubernetes/pkg/healthz"
"k8s.io/kubernetes/pkg/runtime"
@ -256,7 +257,7 @@ func AddApiWebService(container *restful.Container, apiPrefix string, versions [
}
// Adds a service to return the supported api versions at /apis.
func AddApisWebService(container *restful.Container, apiPrefix string, groups []api.APIGroup) {
func AddApisWebService(container *restful.Container, apiPrefix string, groups []unversioned.APIGroup) {
rootAPIHandler := RootAPIHandler(groups)
ws := new(restful.WebService)
ws.Path(apiPrefix)
@ -271,7 +272,7 @@ func AddApisWebService(container *restful.Container, apiPrefix string, groups []
// Adds a service to return the supported versions, preferred version, and name
// of a group. E.g., a such web service will be registered at /apis/extensions.
func AddGroupWebService(container *restful.Container, path string, group api.APIGroup) {
func AddGroupWebService(container *restful.Container, path string, group unversioned.APIGroup) {
groupHandler := GroupHandler(group)
ws := new(restful.WebService)
ws.Path(path)
@ -286,7 +287,7 @@ func AddGroupWebService(container *restful.Container, path string, group api.API
// Adds a service to return the supported resources, E.g., a such web service
// will be registered at /apis/extensions/v1.
func AddSupportedResourcesWebService(ws *restful.WebService, groupVersion string, apiResources []api.APIResource) {
func AddSupportedResourcesWebService(ws *restful.WebService, groupVersion string, apiResources []unversioned.APIResource) {
resourceHandler := SupportedResourcesHandler(groupVersion, apiResources)
ws.Route(ws.GET("/").To(resourceHandler).
Doc("get available resources").
@ -305,21 +306,21 @@ func handleVersion(req *restful.Request, resp *restful.Response) {
func APIVersionHandler(versions ...string) restful.RouteFunction {
return func(req *restful.Request, resp *restful.Response) {
// TODO: use restful's Response methods
writeRawJSON(http.StatusOK, api.APIVersions{Versions: versions}, resp.ResponseWriter)
writeRawJSON(http.StatusOK, unversioned.APIVersions{Versions: versions}, resp.ResponseWriter)
}
}
// RootAPIHandler returns a handler which will list the provided groups and versions as available.
func RootAPIHandler(groups []api.APIGroup) restful.RouteFunction {
func RootAPIHandler(groups []unversioned.APIGroup) restful.RouteFunction {
return func(req *restful.Request, resp *restful.Response) {
// TODO: use restful's Response methods
writeRawJSON(http.StatusOK, api.APIGroupList{Groups: groups}, resp.ResponseWriter)
writeRawJSON(http.StatusOK, unversioned.APIGroupList{Groups: groups}, resp.ResponseWriter)
}
}
// GroupHandler returns a handler which will return the api.GroupAndVersion of
// the group.
func GroupHandler(group api.APIGroup) restful.RouteFunction {
func GroupHandler(group unversioned.APIGroup) restful.RouteFunction {
return func(req *restful.Request, resp *restful.Response) {
// TODO: use restful's Response methods
writeRawJSON(http.StatusOK, group, resp.ResponseWriter)
@ -327,10 +328,10 @@ func GroupHandler(group api.APIGroup) restful.RouteFunction {
}
// SupportedResourcesHandler returns a handler which will list the provided resources as available.
func SupportedResourcesHandler(groupVersion string, apiResources []api.APIResource) restful.RouteFunction {
func SupportedResourcesHandler(groupVersion string, apiResources []unversioned.APIResource) restful.RouteFunction {
return func(req *restful.Request, resp *restful.Response) {
// TODO: use restful's Response methods
writeRawJSON(http.StatusOK, api.APIResourceList{GroupVersion: groupVersion, APIResources: apiResources}, resp.ResponseWriter)
writeRawJSON(http.StatusOK, unversioned.APIResourceList{GroupVersion: groupVersion, APIResources: apiResources}, resp.ResponseWriter)
}
}

View File

@ -20,7 +20,7 @@ import (
"net/http"
"sort"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"github.com/emicklei/go-restful"
)
@ -41,6 +41,6 @@ func IndexHandler(container *restful.Container, muxHelper *MuxHelper) func(http.
// Extract the paths handled using mux handler.
handledPaths = append(handledPaths, muxHelper.RegisteredPaths...)
sort.Strings(handledPaths)
writeRawJSON(status, api.RootPaths{Paths: handledPaths}, w)
writeRawJSON(status, unversioned.RootPaths{Paths: handledPaths}, w)
}
}

View File

@ -23,6 +23,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/util"
@ -54,7 +55,7 @@ func buildLocation(resourcePath string, query url.Values) string {
}
func TestListWatchesCanList(t *testing.T) {
fieldSelectorQueryParamName := api.FieldSelectorQueryParam(testapi.Default.Version())
fieldSelectorQueryParamName := unversioned.FieldSelectorQueryParam(testapi.Default.Version())
table := []struct {
location string
resource string
@ -104,7 +105,7 @@ func TestListWatchesCanList(t *testing.T) {
}
func TestListWatchesCanWatch(t *testing.T) {
fieldSelectorQueryParamName := api.FieldSelectorQueryParam(testapi.Default.Version())
fieldSelectorQueryParamName := unversioned.FieldSelectorQueryParam(testapi.Default.Version())
table := []struct {
rv string
location string

View File

@ -116,7 +116,7 @@ func (c *Client) ComponentStatuses() ComponentStatusInterface {
// VersionInterface has a method to retrieve the server version.
type VersionInterface interface {
ServerVersion() (*version.Info, error)
ServerAPIVersions() (*api.APIVersions, error)
ServerAPIVersions() (*unversioned.APIVersions, error)
}
// APIStatus is exposed by errors that can be converted to an api.Status object
@ -146,12 +146,12 @@ func (c *Client) ServerVersion() (*version.Info, error) {
}
// ServerAPIVersions retrieves and parses the list of API versions the server supports.
func (c *Client) ServerAPIVersions() (*api.APIVersions, error) {
func (c *Client) ServerAPIVersions() (*unversioned.APIVersions, error) {
body, err := c.Get().UnversionedPath("").Do().Raw()
if err != nil {
return nil, err
}
var v api.APIVersions
var v unversioned.APIVersions
err = json.Unmarshal(body, &v)
if err != nil {
return nil, fmt.Errorf("got '%s': %v", string(body), err)

View File

@ -30,6 +30,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
@ -149,9 +150,9 @@ func (c *testClient) ValidateCommon(t *testing.T, err error) {
validator, ok := c.QueryValidator[key]
if !ok {
switch key {
case api.LabelSelectorQueryParam(testapi.Default.Version()):
case unversioned.LabelSelectorQueryParam(testapi.Default.Version()):
validator = validateLabels
case api.FieldSelectorQueryParam(testapi.Default.Version()):
case unversioned.FieldSelectorQueryParam(testapi.Default.Version()):
validator = validateFields
default:
validator = func(a, b string) bool { return a == b }
@ -272,7 +273,7 @@ func TestGetServerVersion(t *testing.T) {
func TestGetServerAPIVersions(t *testing.T) {
versions := []string{"v1", "v2", "v3"}
expect := api.APIVersions{Versions: versions}
expect := unversioned.APIVersions{Versions: versions}
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
output, err := json.Marshal(expect)
if err != nil {
@ -300,7 +301,7 @@ func swaggerSchemaFakeServer() (*httptest.Server, error) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
var resp interface{}
if request == 1 {
resp = api.APIVersions{Versions: []string{"v1", "v2", "v3"}}
resp = unversioned.APIVersions{Versions: []string{"v1", "v2", "v3"}}
request++
} else {
resp = swagger.ApiDeclaration{}

View File

@ -34,12 +34,12 @@ func TestEventSearch(t *testing.T) {
Method: "GET",
Path: testapi.Default.ResourcePath("events", "baz", ""),
Query: url.Values{
api.FieldSelectorQueryParam(testapi.Default.Version()): []string{
unversioned.FieldSelectorQueryParam(testapi.Default.Version()): []string{
getInvolvedObjectNameFieldLabel(testapi.Default.Version()) + "=foo,",
"involvedObject.namespace=baz,",
"involvedObject.kind=Pod",
},
api.LabelSelectorQueryParam(testapi.Default.Version()): []string{},
unversioned.LabelSelectorQueryParam(testapi.Default.Version()): []string{},
},
},
Response: Response{StatusCode: 200, Body: &api.EventList{}},

View File

@ -21,8 +21,8 @@ import (
"fmt"
"strings"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/latest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/version"
)
@ -63,12 +63,12 @@ func (c *ExperimentalClient) ServerVersion() (*version.Info, error) {
// ServerAPIVersions retrieves and parses the list of experimental API versions the
// server supports.
func (c *ExperimentalClient) ServerAPIVersions() (*api.APIVersions, error) {
func (c *ExperimentalClient) ServerAPIVersions() (*unversioned.APIVersions, error) {
body, err := c.Get().UnversionedPath("").Do().Raw()
if err != nil {
return nil, err
}
var v api.APIVersions
var v unversioned.APIVersions
err = json.Unmarshal(body, &v)
if err != nil {
return nil, fmt.Errorf("got '%s': %v", string(body), err)

View File

@ -34,6 +34,7 @@ import (
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/latest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
@ -179,7 +180,7 @@ func MatchesServerVersion(client *Client, c *Config) error {
return nil
}
func extractGroupVersions(l *api.APIGroupList) []string {
func extractGroupVersions(l *unversioned.APIGroupList) []string {
var groupVersions []string
for _, g := range l.Groups {
for _, gv := range g.Versions {
@ -213,7 +214,7 @@ func ServerAPIVersions(c *Config) (groupVersions []string, err error) {
if err != nil {
return nil, err
}
var v api.APIVersions
var v unversioned.APIVersions
defer resp.Body.Close()
err = json.NewDecoder(resp.Body).Decode(&v)
if err != nil {
@ -227,7 +228,7 @@ func ServerAPIVersions(c *Config) (groupVersions []string, err error) {
if err != nil {
return nil, err
}
var apiGroupList api.APIGroupList
var apiGroupList unversioned.APIGroupList
defer resp2.Body.Close()
err = json.NewDecoder(resp2.Body).Decode(&apiGroupList)
if err != nil {

View File

@ -24,8 +24,8 @@ import (
"net/http"
"testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
unversioned_api "k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/client/unversioned/fake"
)
@ -90,10 +90,10 @@ func TestNegotiateVersion(t *testing.T) {
Codec: codec,
Resp: &http.Response{
StatusCode: 200,
Body: objBody(&api.APIVersions{Versions: test.serverVersions}),
Body: objBody(&unversioned_api.APIVersions{Versions: test.serverVersions}),
},
Client: fake.HTTPClientFunc(func(req *http.Request) (*http.Response, error) {
return &http.Response{StatusCode: 200, Body: objBody(&api.APIVersions{Versions: test.serverVersions})}, nil
return &http.Response{StatusCode: 200, Body: objBody(&unversioned_api.APIVersions{Versions: test.serverVersions})}, nil
}),
}
c := unversioned.NewOrDie(test.config)

View File

@ -24,8 +24,8 @@ import (
"strings"
"testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
)
const (
@ -380,12 +380,12 @@ func TestSetKubernetesDefaultsUserAgent(t *testing.T) {
func TestHelperGetServerAPIVersions(t *testing.T) {
expect := []string{"v1", "v2", "v3"}
APIVersions := api.APIVersions{Versions: expect}
APIVersions := unversioned.APIVersions{Versions: expect}
expect = append(expect, "group1/v1", "group1/v2", "group2/v1", "group2/v2")
APIGroupList := api.APIGroupList{
Groups: []api.APIGroup{
APIGroupList := unversioned.APIGroupList{
Groups: []unversioned.APIGroup{
{
Versions: []api.GroupVersion{
Versions: []unversioned.GroupVersion{
{
GroupVersion: "group1/v1",
},
@ -395,7 +395,7 @@ func TestHelperGetServerAPIVersions(t *testing.T) {
},
},
{
Versions: []api.GroupVersion{
Versions: []unversioned.GroupVersion{
{
GroupVersion: "group2/v1",
},

View File

@ -45,7 +45,7 @@ func TestListNodes(t *testing.T) {
}
func TestListNodesLabels(t *testing.T) {
labelSelectorQueryParamName := api.LabelSelectorQueryParam(testapi.Default.Version())
labelSelectorQueryParamName := unversioned.LabelSelectorQueryParam(testapi.Default.Version())
c := &testClient{
Request: testRequest{
Method: "GET",

View File

@ -22,6 +22,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
)
@ -64,7 +65,7 @@ func TestListPods(t *testing.T) {
func TestListPodsLabels(t *testing.T) {
ns := api.NamespaceDefault
labelSelectorQueryParamName := api.LabelSelectorQueryParam(testapi.Default.Version())
labelSelectorQueryParamName := unversioned.LabelSelectorQueryParam(testapi.Default.Version())
c := &testClient{
Request: testRequest{
Method: "GET",

View File

@ -30,7 +30,6 @@ import (
"time"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/metrics"
@ -372,7 +371,7 @@ func (r *Request) FieldsSelectorParam(s fields.Selector) *Request {
r.err = err
return r
}
return r.setParam(api.FieldSelectorQueryParam(r.apiVersion), s2.String())
return r.setParam(unversioned.FieldSelectorQueryParam(r.apiVersion), s2.String())
}
// LabelsSelectorParam adds the given selector as a query parameter
@ -386,7 +385,7 @@ func (r *Request) LabelsSelectorParam(s labels.Selector) *Request {
if s.Empty() {
return r
}
return r.setParam(api.LabelSelectorQueryParam(r.apiVersion), s.String())
return r.setParam(unversioned.LabelSelectorQueryParam(r.apiVersion), s.String())
}
// UintParam creates a query parameter with the given value.

View File

@ -777,7 +777,7 @@ func TestDoRequestNewWayReader(t *testing.T) {
}
tmpStr := string(reqBodyExpected)
requestURL := testapi.Default.ResourcePathWithPrefix("foo", "bar", "", "baz")
requestURL += "?" + api.LabelSelectorQueryParam(testapi.Default.Version()) + "=name%3Dfoo&timeout=1s"
requestURL += "?" + unversioned.LabelSelectorQueryParam(testapi.Default.Version()) + "=name%3Dfoo&timeout=1s"
fakeHandler.ValidateRequest(t, requestURL, "POST", &tmpStr)
if fakeHandler.RequestReceived.Header["Authorization"] == nil {
t.Errorf("Request is missing authorization header: %#v", *fakeHandler.RequestReceived)
@ -819,7 +819,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
}
tmpStr := string(reqBodyExpected)
requestURL := testapi.Default.ResourcePath("foo", "", "bar/baz")
requestURL += "?" + api.LabelSelectorQueryParam(testapi.Default.Version()) + "=name%3Dfoo&timeout=1s"
requestURL += "?" + unversioned.LabelSelectorQueryParam(testapi.Default.Version()) + "=name%3Dfoo&timeout=1s"
fakeHandler.ValidateRequest(t, requestURL, "POST", &tmpStr)
if fakeHandler.RequestReceived.Header["Authorization"] == nil {
t.Errorf("Request is missing authorization header: %#v", *fakeHandler.RequestReceived)

View File

@ -22,6 +22,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/labels"
)
@ -60,7 +61,7 @@ func TestListServices(t *testing.T) {
func TestListServicesLabels(t *testing.T) {
ns := api.NamespaceDefault
labelSelectorQueryParamName := api.LabelSelectorQueryParam(testapi.Default.Version())
labelSelectorQueryParamName := unversioned.LabelSelectorQueryParam(testapi.Default.Version())
c := &testClient{
Request: testRequest{
Method: "GET",

View File

@ -24,6 +24,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/registered"
"k8s.io/kubernetes/pkg/api/unversioned"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/version"
@ -281,13 +282,13 @@ func (c *Fake) ServerVersion() (*version.Info, error) {
return &versionInfo, nil
}
func (c *Fake) ServerAPIVersions() (*api.APIVersions, error) {
func (c *Fake) ServerAPIVersions() (*unversioned.APIVersions, error) {
action := ActionImpl{}
action.Verb = "get"
action.Resource = "apiversions"
c.Invokes(action, nil)
return &api.APIVersions{Versions: registered.RegisteredVersions}, nil
return &unversioned.APIVersions{Versions: registered.RegisteredVersions}, nil
}
func (c *Fake) ComponentStatuses() client.ComponentStatusInterface {

View File

@ -23,7 +23,7 @@ import (
"github.com/spf13/cobra"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
)
@ -57,7 +57,7 @@ func RunApiVersions(f *cmdutil.Factory, w io.Writer) error {
os.Exit(1)
}
var expAPIVersions *api.APIVersions
var expAPIVersions *unversioned.APIVersions
expAPIVersions, err = client.Experimental().ServerAPIVersions()
fmt.Fprintf(w, "Available Server Api Versions: %#v\n", *apiVersions)

View File

@ -25,6 +25,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/unversioned/fake"
)
@ -416,12 +417,12 @@ func TestDeleteMultipleSelector(t *testing.T) {
Client: fake.HTTPClientFunc(func(req *http.Request) (*http.Response, error) {
switch p, m := req.URL.Path, req.Method; {
case p == "/namespaces/test/pods" && m == "GET":
if req.URL.Query().Get(api.LabelSelectorQueryParam(testapi.Default.Version())) != "a=b" {
if req.URL.Query().Get(unversioned.LabelSelectorQueryParam(testapi.Default.Version())) != "a=b" {
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
}
return &http.Response{StatusCode: 200, Body: objBody(codec, pods)}, nil
case p == "/namespaces/test/services" && m == "GET":
if req.URL.Query().Get(api.LabelSelectorQueryParam(testapi.Default.Version())) != "a=b" {
if req.URL.Query().Get(unversioned.LabelSelectorQueryParam(testapi.Default.Version())) != "a=b" {
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
}
return &http.Response{StatusCode: 200, Body: objBody(codec, svc)}, nil

View File

@ -507,7 +507,7 @@ func TestGetMultipleTypeObjectsWithSelector(t *testing.T) {
tf.Client = &fake.RESTClient{
Codec: codec,
Client: fake.HTTPClientFunc(func(req *http.Request) (*http.Response, error) {
if req.URL.Query().Get(api.LabelSelectorQueryParam(testapi.Default.Version())) != "a=b" {
if req.URL.Query().Get(unversioned.LabelSelectorQueryParam(testapi.Default.Version())) != "a=b" {
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
}
switch req.URL.Path {
@ -633,7 +633,7 @@ func TestWatchSelector(t *testing.T) {
tf.Client = &fake.RESTClient{
Codec: codec,
Client: fake.HTTPClientFunc(func(req *http.Request) (*http.Response, error) {
if req.URL.Query().Get(api.LabelSelectorQueryParam(testapi.Default.Version())) != "a=b" {
if req.URL.Query().Get(unversioned.LabelSelectorQueryParam(testapi.Default.Version())) != "a=b" {
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
}
switch req.URL.Path {

View File

@ -504,7 +504,7 @@ func TestResourceByNameAndEmptySelector(t *testing.T) {
func TestSelector(t *testing.T) {
pods, svc := testData()
labelKey := api.LabelSelectorQueryParam(testapi.Default.Version())
labelKey := unversioned.LabelSelectorQueryParam(testapi.Default.Version())
b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClientWith("", t, map[string]string{
"/namespaces/test/pods?" + labelKey + "=a%3Db": runtime.EncodeOrDie(testapi.Default.Codec(), pods),
"/namespaces/test/services?" + labelKey + "=a%3Db": runtime.EncodeOrDie(testapi.Default.Codec(), svc),
@ -905,7 +905,7 @@ func TestSingularRootScopedObject(t *testing.T) {
func TestListObject(t *testing.T) {
pods, _ := testData()
labelKey := api.LabelSelectorQueryParam(testapi.Default.Version())
labelKey := unversioned.LabelSelectorQueryParam(testapi.Default.Version())
b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClientWith("", t, map[string]string{
"/namespaces/test/pods?" + labelKey + "=a%3Db": runtime.EncodeOrDie(testapi.Default.Codec(), pods),
})).
@ -938,7 +938,7 @@ func TestListObject(t *testing.T) {
func TestListObjectWithDifferentVersions(t *testing.T) {
pods, svc := testData()
labelKey := api.LabelSelectorQueryParam(testapi.Default.Version())
labelKey := unversioned.LabelSelectorQueryParam(testapi.Default.Version())
obj, err := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClientWith("", t, map[string]string{
"/namespaces/test/pods?" + labelKey + "=a%3Db": runtime.EncodeOrDie(testapi.Default.Codec(), pods),
"/namespaces/test/services?" + labelKey + "=a%3Db": runtime.EncodeOrDie(testapi.Default.Codec(), svc),

View File

@ -328,7 +328,7 @@ func TestHelperList(t *testing.T) {
t.Errorf("url doesn't contain name: %#v", req.URL)
return false
}
if req.URL.Query().Get(api.LabelSelectorQueryParam(testapi.Default.Version())) != labels.SelectorFromSet(labels.Set{"foo": "baz"}).String() {
if req.URL.Query().Get(unversioned.LabelSelectorQueryParam(testapi.Default.Version())) != labels.SelectorFromSet(labels.Set{"foo": "baz"}).String() {
t.Errorf("url doesn't contain query parameters: %#v", req.URL)
return false
}

View File

@ -33,6 +33,7 @@ import (
"k8s.io/kubernetes/pkg/api/latest"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
apiutil "k8s.io/kubernetes/pkg/api/util"
"k8s.io/kubernetes/pkg/api/v1"
expapi "k8s.io/kubernetes/pkg/apis/extensions"
@ -619,7 +620,7 @@ func (m *Master) init(c *Config) {
apiserver.InstallServiceErrorHandler(m.handlerContainer, m.newAPIRequestInfoResolver(), apiVersions)
// allGroups records all supported groups at /apis
allGroups := []api.APIGroup{}
allGroups := []unversioned.APIGroup{}
if m.exp {
m.thirdPartyStorage = c.StorageDestinations.APIGroups["extensions"].Default
m.thirdPartyResources = map[string]*thirdpartyresourcedataetcd.REST{}
@ -633,7 +634,7 @@ func (m *Master) init(c *Config) {
if err != nil {
glog.Fatalf("Unable to setup experimental api: %v", err)
}
expAPIVersions := []api.GroupVersion{
expAPIVersions := []unversioned.GroupVersion{
{
GroupVersion: expVersion.Version,
Version: apiutil.GetVersion(expVersion.Version),
@ -643,10 +644,10 @@ func (m *Master) init(c *Config) {
if !found {
glog.Fatalf("Couldn't find storage version of group %v", g.Group)
}
group := api.APIGroup{
group := unversioned.APIGroup{
Name: g.Group,
Versions: expAPIVersions,
PreferredVersion: api.GroupVersion{GroupVersion: storageVersion, Version: apiutil.GetVersion(storageVersion)},
PreferredVersion: unversioned.GroupVersion{GroupVersion: storageVersion, Version: apiutil.GetVersion(storageVersion)},
}
apiserver.AddGroupWebService(m.handlerContainer, c.APIGroupPrefix+"/"+latest.GroupOrDie("extensions").Group+"/", group)
allGroups = append(allGroups, group)
@ -958,13 +959,13 @@ func (m *Master) InstallThirdPartyResource(rsrc *expapi.ThirdPartyResource) erro
glog.Fatalf("Unable to setup thirdparty api: %v", err)
}
path := makeThirdPartyPath(group)
groupVersion := api.GroupVersion{
groupVersion := unversioned.GroupVersion{
GroupVersion: group + "/" + rsrc.Versions[0].Name,
Version: rsrc.Versions[0].Name,
}
apiGroup := api.APIGroup{
apiGroup := unversioned.APIGroup{
Name: group,
Versions: []api.GroupVersion{groupVersion},
Versions: []unversioned.GroupVersion{groupVersion},
}
apiserver.AddGroupWebService(m.handlerContainer, path, apiGroup)
m.addThirdPartyResourceStorage(path, thirdparty.Storage[strings.ToLower(kind)+"s"].(*thirdpartyresourcedataetcd.REST))

View File

@ -292,7 +292,7 @@ func TestDefaultAPIGroupVersion(t *testing.T) {
}
// TestExpapi verifies that the unexported exapi creates
// the an experimental api APIGroupVersion.
// the an experimental unversioned.APIGroupVersion.
func TestExpapi(t *testing.T) {
master, config, assert := setUp(t)
@ -367,20 +367,20 @@ func TestDiscoveryAtAPIS(t *testing.T) {
assert.Equal(http.StatusOK, resp.StatusCode)
groupList := api.APIGroupList{}
groupList := unversioned.APIGroupList{}
assert.NoError(decodeResponse(resp, &groupList))
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
expectGroupName := "extensions"
expectVersions := []api.GroupVersion{
expectVersions := []unversioned.GroupVersion{
{
GroupVersion: testapi.Extensions.GroupAndVersion(),
Version: testapi.Extensions.Version(),
},
}
expectPreferredVersion := api.GroupVersion{
expectPreferredVersion := unversioned.GroupVersion{
GroupVersion: config.StorageVersions["extensions"],
Version: apiutil.GetVersion(config.StorageVersions["extensions"]),
}

View File

@ -37,6 +37,7 @@ import (
"k8s.io/kubernetes/pkg/api"
apierrs "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/kubectl"
@ -726,12 +727,12 @@ func checkOutput(output string, required [][]string) {
}
}
func getAPIVersions(apiEndpoint string) (*api.APIVersions, error) {
func getAPIVersions(apiEndpoint string) (*unversioned.APIVersions, error) {
body, err := curl(apiEndpoint)
if err != nil {
return nil, fmt.Errorf("Failed http.Get of %s: %v", apiEndpoint, err)
}
var apiVersions api.APIVersions
var apiVersions unversioned.APIVersions
if err := json.Unmarshal([]byte(body), &apiVersions); err != nil {
return nil, fmt.Errorf("Failed to parse /api output %s: %v", body, err)
}