Update go dependencies
This commit is contained in:
parent
a858c549d9
commit
f3bde94d68
643 changed files with 14296 additions and 19354 deletions
5
vendor/k8s.io/client-go/discovery/BUILD
generated
vendored
5
vendor/k8s.io/client-go/discovery/BUILD
generated
vendored
|
|
@ -14,11 +14,12 @@ go_library(
|
|||
"restmapper.go",
|
||||
"unstructured.go",
|
||||
],
|
||||
importpath = "k8s.io/client-go/discovery",
|
||||
deps = [
|
||||
"//vendor/github.com/emicklei/go-restful-swagger12:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/github.com/golang/protobuf/proto:go_default_library",
|
||||
"//vendor/github.com/googleapis/gnostic/OpenAPIv2:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
|
|
@ -39,8 +40,8 @@ go_test(
|
|||
"helper_blackbox_test.go",
|
||||
"restmapper_test.go",
|
||||
],
|
||||
importpath = "k8s.io/client-go/discovery_test",
|
||||
deps = [
|
||||
"//vendor/github.com/emicklei/go-restful-swagger12:go_default_library",
|
||||
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
|
||||
"//vendor/github.com/googleapis/gnostic/OpenAPIv2:go_default_library",
|
||||
"//vendor/github.com/stretchr/testify/assert:go_default_library",
|
||||
|
|
|
|||
44
vendor/k8s.io/client-go/discovery/discovery_client.go
generated
vendored
44
vendor/k8s.io/client-go/discovery/discovery_client.go
generated
vendored
|
|
@ -23,9 +23,11 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/emicklei/go-restful-swagger12"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/googleapis/gnostic/OpenAPIv2"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
|
@ -46,6 +48,7 @@ type DiscoveryInterface interface {
|
|||
ServerGroupsInterface
|
||||
ServerResourcesInterface
|
||||
ServerVersionInterface
|
||||
SwaggerSchemaInterface
|
||||
OpenAPISchemaInterface
|
||||
}
|
||||
|
||||
|
|
@ -89,6 +92,12 @@ type ServerVersionInterface interface {
|
|||
ServerVersion() (*version.Info, error)
|
||||
}
|
||||
|
||||
// SwaggerSchemaInterface has a method to retrieve the swagger schema.
|
||||
type SwaggerSchemaInterface interface {
|
||||
// SwaggerSchema retrieves and parses the swagger API schema the server supports.
|
||||
SwaggerSchema(version schema.GroupVersion) (*swagger.ApiDeclaration, error)
|
||||
}
|
||||
|
||||
// OpenAPISchemaInterface has a method to retrieve the open API schema.
|
||||
type OpenAPISchemaInterface interface {
|
||||
// OpenAPISchema retrieves and parses the swagger API schema the server supports.
|
||||
|
|
@ -327,6 +336,41 @@ func (d *DiscoveryClient) ServerVersion() (*version.Info, error) {
|
|||
return &info, nil
|
||||
}
|
||||
|
||||
// SwaggerSchema retrieves and parses the swagger API schema the server supports.
|
||||
// TODO: Replace usages with Open API. Tracked in https://github.com/kubernetes/kubernetes/issues/44589
|
||||
func (d *DiscoveryClient) SwaggerSchema(version schema.GroupVersion) (*swagger.ApiDeclaration, error) {
|
||||
if version.Empty() {
|
||||
return nil, fmt.Errorf("groupVersion cannot be empty")
|
||||
}
|
||||
|
||||
groupList, err := d.ServerGroups()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
groupVersions := metav1.ExtractGroupVersions(groupList)
|
||||
// This check also takes care the case that kubectl is newer than the running endpoint
|
||||
if stringDoesntExistIn(version.String(), groupVersions) {
|
||||
return nil, fmt.Errorf("API version: %v is not supported by the server. Use one of: %v", version, groupVersions)
|
||||
}
|
||||
var path string
|
||||
if len(d.LegacyPrefix) > 0 && version == v1.SchemeGroupVersion {
|
||||
path = "/swaggerapi" + d.LegacyPrefix + "/" + version.Version
|
||||
} else {
|
||||
path = "/swaggerapi/apis/" + version.Group + "/" + version.Version
|
||||
}
|
||||
|
||||
body, err := d.restClient.Get().AbsPath(path).Do().Raw()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var schema swagger.ApiDeclaration
|
||||
err = json.Unmarshal(body, &schema)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("got '%s': %v", string(body), err)
|
||||
}
|
||||
return &schema, nil
|
||||
}
|
||||
|
||||
// OpenAPISchema fetches the open api schema using a rest client and parses the proto.
|
||||
func (d *DiscoveryClient) OpenAPISchema() (*openapi_v2.Document, error) {
|
||||
data, err := d.restClient.Get().AbsPath("/swagger-2.0.0.pb-v1").Do().Raw()
|
||||
|
|
|
|||
64
vendor/k8s.io/client-go/discovery/discovery_client_test.go
generated
vendored
64
vendor/k8s.io/client-go/discovery/discovery_client_test.go
generated
vendored
|
|
@ -25,9 +25,11 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/emicklei/go-restful-swagger12"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/googleapis/gnostic/OpenAPIv2"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
|
|
@ -265,6 +267,68 @@ func TestGetServerResources(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func swaggerSchemaFakeServer() (*httptest.Server, error) {
|
||||
request := 1
|
||||
var sErr error
|
||||
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
var resp interface{}
|
||||
if request == 1 {
|
||||
resp = metav1.APIVersions{Versions: []string{"v1", "v2", "v3"}}
|
||||
request++
|
||||
} else {
|
||||
resp = swagger.ApiDeclaration{}
|
||||
}
|
||||
output, err := json.Marshal(resp)
|
||||
if err != nil {
|
||||
sErr = err
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write(output)
|
||||
}))
|
||||
return server, sErr
|
||||
}
|
||||
|
||||
func TestGetSwaggerSchema(t *testing.T) {
|
||||
expect := swagger.ApiDeclaration{}
|
||||
|
||||
server, err := swaggerSchemaFakeServer()
|
||||
if err != nil {
|
||||
t.Errorf("unexpected encoding error: %v", err)
|
||||
}
|
||||
defer server.Close()
|
||||
|
||||
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||
got, err := client.SwaggerSchema(v1.SchemeGroupVersion)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected encoding error: %v", err)
|
||||
}
|
||||
if e, a := expect, *got; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("expected %v, got %v", e, a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSwaggerSchemaFail(t *testing.T) {
|
||||
expErr := "API version: api.group/v4 is not supported by the server. Use one of: [v1 v2 v3]"
|
||||
|
||||
server, err := swaggerSchemaFakeServer()
|
||||
if err != nil {
|
||||
t.Errorf("unexpected encoding error: %v", err)
|
||||
}
|
||||
defer server.Close()
|
||||
|
||||
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||
got, err := client.SwaggerSchema(schema.GroupVersion{Group: "api.group", Version: "v4"})
|
||||
if got != nil {
|
||||
t.Fatalf("unexpected response: %v", got)
|
||||
}
|
||||
if err.Error() != expErr {
|
||||
t.Errorf("expected an error, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
var returnedOpenAPI = openapi_v2.Document{
|
||||
Definitions: &openapi_v2.Definitions{
|
||||
AdditionalProperties: []*openapi_v2.NamedSchema{
|
||||
|
|
|
|||
4
vendor/k8s.io/client-go/discovery/fake/BUILD
generated
vendored
4
vendor/k8s.io/client-go/discovery/fake/BUILD
generated
vendored
|
|
@ -9,9 +9,10 @@ load(
|
|||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["discovery.go"],
|
||||
importpath = "k8s.io/client-go/discovery/fake",
|
||||
deps = [
|
||||
"//vendor/github.com/emicklei/go-restful-swagger12:go_default_library",
|
||||
"//vendor/github.com/googleapis/gnostic/OpenAPIv2:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/version:go_default_library",
|
||||
|
|
@ -37,7 +38,6 @@ filegroup(
|
|||
go_test(
|
||||
name = "go_default_xtest",
|
||||
srcs = ["discovery_test.go"],
|
||||
importpath = "k8s.io/client-go/discovery/fake_test",
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/version:go_default_library",
|
||||
"//vendor/k8s.io/client-go/discovery/fake:go_default_library",
|
||||
|
|
|
|||
15
vendor/k8s.io/client-go/discovery/fake/discovery.go
generated
vendored
15
vendor/k8s.io/client-go/discovery/fake/discovery.go
generated
vendored
|
|
@ -19,8 +19,10 @@ package fake
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/emicklei/go-restful-swagger12"
|
||||
"github.com/googleapis/gnostic/OpenAPIv2"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/version"
|
||||
|
|
@ -85,6 +87,19 @@ func (c *FakeDiscovery) ServerVersion() (*version.Info, error) {
|
|||
return &versionInfo, nil
|
||||
}
|
||||
|
||||
func (c *FakeDiscovery) SwaggerSchema(version schema.GroupVersion) (*swagger.ApiDeclaration, error) {
|
||||
action := testing.ActionImpl{}
|
||||
action.Verb = "get"
|
||||
if version == v1.SchemeGroupVersion {
|
||||
action.Resource = schema.GroupVersionResource{Resource: "/swaggerapi/api/" + version.Version}
|
||||
} else {
|
||||
action.Resource = schema.GroupVersionResource{Resource: "/swaggerapi/apis/" + version.Group + "/" + version.Version}
|
||||
}
|
||||
|
||||
c.Invokes(action, nil)
|
||||
return &swagger.ApiDeclaration{}, nil
|
||||
}
|
||||
|
||||
func (c *FakeDiscovery) OpenAPISchema() (*openapi_v2.Document, error) {
|
||||
return &openapi_v2.Document{}, nil
|
||||
}
|
||||
|
|
|
|||
5
vendor/k8s.io/client-go/discovery/restmapper_test.go
generated
vendored
5
vendor/k8s.io/client-go/discovery/restmapper_test.go
generated
vendored
|
|
@ -28,6 +28,7 @@ import (
|
|||
restclient "k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/rest/fake"
|
||||
|
||||
"github.com/emicklei/go-restful-swagger12"
|
||||
"github.com/googleapis/gnostic/OpenAPIv2"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
|
@ -379,6 +380,10 @@ func (c *fakeCachedDiscoveryInterface) ServerVersion() (*version.Info, error) {
|
|||
return &version.Info{}, nil
|
||||
}
|
||||
|
||||
func (c *fakeCachedDiscoveryInterface) SwaggerSchema(version schema.GroupVersion) (*swagger.ApiDeclaration, error) {
|
||||
return &swagger.ApiDeclaration{}, nil
|
||||
}
|
||||
|
||||
func (c *fakeCachedDiscoveryInterface) OpenAPISchema() (*openapi_v2.Document, error) {
|
||||
return &openapi_v2.Document{}, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue