Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
224dba9a
Commit
224dba9a
authored
May 26, 2017
by
Antoine Pelisse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
openapi: Fetch protobuf rather than Json
This is much faster.
parent
81ce94ae
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
192 additions
and
150 deletions
+192
-150
BUILD
pkg/kubectl/cmd/util/BUILD
+2
-2
cached_discovery.go
pkg/kubectl/cmd/util/cached_discovery.go
+2
-2
cached_discovery_test.go
pkg/kubectl/cmd/util/cached_discovery_test.go
+3
-3
BUILD
pkg/kubectl/cmd/util/openapi/BUILD
+5
-1
openapi.go
pkg/kubectl/cmd/util/openapi/openapi.go
+75
-49
openapi_cache.go
pkg/kubectl/cmd/util/openapi/openapi_cache.go
+1
-2
openapi_cache_test.go
pkg/kubectl/cmd/util/openapi/openapi_cache_test.go
+15
-9
Godeps.json
...ing/src/k8s.io/apiextensions-apiserver/Godeps/Godeps.json
+0
-8
Godeps.json
staging/src/k8s.io/apiserver/Godeps/Godeps.json
+0
-8
Godeps.json
staging/src/k8s.io/client-go/Godeps/Godeps.json
+28
-8
BUILD
staging/src/k8s.io/client-go/discovery/BUILD
+4
-3
discovery_client.go
staging/src/k8s.io/client-go/discovery/discovery_client.go
+9
-10
discovery_client_test.go
...g/src/k8s.io/client-go/discovery/discovery_client_test.go
+40
-23
BUILD
staging/src/k8s.io/client-go/discovery/fake/BUILD
+1
-1
discovery.go
staging/src/k8s.io/client-go/discovery/fake/discovery.go
+4
-2
restmapper_test.go
staging/src/k8s.io/client-go/discovery/restmapper_test.go
+3
-3
Godeps.json
staging/src/k8s.io/kube-aggregator/Godeps/Godeps.json
+0
-8
Godeps.json
staging/src/k8s.io/sample-apiserver/Godeps/Godeps.json
+0
-8
No files found.
pkg/kubectl/cmd/util/BUILD
View file @
224dba9a
...
@@ -46,8 +46,8 @@ go_library(
...
@@ -46,8 +46,8 @@ go_library(
"//pkg/version:go_default_library",
"//pkg/version:go_default_library",
"//vendor/github.com/emicklei/go-restful-swagger12:go_default_library",
"//vendor/github.com/emicklei/go-restful-swagger12:go_default_library",
"//vendor/github.com/evanphx/json-patch:go_default_library",
"//vendor/github.com/evanphx/json-patch:go_default_library",
"//vendor/github.com/go-openapi/spec:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/googleapis/gnostic/OpenAPIv2:go_default_library",
"//vendor/github.com/spf13/cobra:go_default_library",
"//vendor/github.com/spf13/cobra:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
...
@@ -108,7 +108,7 @@ go_test(
...
@@ -108,7 +108,7 @@ go_test(
"//pkg/kubectl/resource:go_default_library",
"//pkg/kubectl/resource:go_default_library",
"//pkg/util/exec:go_default_library",
"//pkg/util/exec:go_default_library",
"//vendor/github.com/emicklei/go-restful-swagger12:go_default_library",
"//vendor/github.com/emicklei/go-restful-swagger12:go_default_library",
"//vendor/github.com/go
-openapi/spec
:go_default_library",
"//vendor/github.com/go
ogleapis/gnostic/OpenAPIv2
:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
...
...
pkg/kubectl/cmd/util/cached_discovery.go
View file @
224dba9a
...
@@ -25,8 +25,8 @@ import (
...
@@ -25,8 +25,8 @@ import (
"time"
"time"
"github.com/emicklei/go-restful-swagger12"
"github.com/emicklei/go-restful-swagger12"
"github.com/go-openapi/spec"
"github.com/golang/glog"
"github.com/golang/glog"
"github.com/googleapis/gnostic/OpenAPIv2"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
...
@@ -237,7 +237,7 @@ func (d *CachedDiscoveryClient) SwaggerSchema(version schema.GroupVersion) (*swa
...
@@ -237,7 +237,7 @@ func (d *CachedDiscoveryClient) SwaggerSchema(version schema.GroupVersion) (*swa
return
d
.
delegate
.
SwaggerSchema
(
version
)
return
d
.
delegate
.
SwaggerSchema
(
version
)
}
}
func
(
d
*
CachedDiscoveryClient
)
OpenAPISchema
()
(
*
spec
.
Swagger
,
error
)
{
func
(
d
*
CachedDiscoveryClient
)
OpenAPISchema
()
(
*
openapi_v2
.
Document
,
error
)
{
return
d
.
delegate
.
OpenAPISchema
()
return
d
.
delegate
.
OpenAPISchema
()
}
}
...
...
pkg/kubectl/cmd/util/cached_discovery_test.go
View file @
224dba9a
...
@@ -23,7 +23,7 @@ import (
...
@@ -23,7 +23,7 @@ import (
"time"
"time"
"github.com/emicklei/go-restful-swagger12"
"github.com/emicklei/go-restful-swagger12"
"github.com/go
-openapi/spec
"
"github.com/go
ogleapis/gnostic/OpenAPIv2
"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
...
@@ -171,7 +171,7 @@ func (c *fakeDiscoveryClient) SwaggerSchema(version schema.GroupVersion) (*swagg
...
@@ -171,7 +171,7 @@ func (c *fakeDiscoveryClient) SwaggerSchema(version schema.GroupVersion) (*swagg
return
&
swagger
.
ApiDeclaration
{},
nil
return
&
swagger
.
ApiDeclaration
{},
nil
}
}
func
(
c
*
fakeDiscoveryClient
)
OpenAPISchema
()
(
*
spec
.
Swagger
,
error
)
{
func
(
c
*
fakeDiscoveryClient
)
OpenAPISchema
()
(
*
openapi_v2
.
Document
,
error
)
{
c
.
openAPICalls
=
c
.
openAPICalls
+
1
c
.
openAPICalls
=
c
.
openAPICalls
+
1
return
&
spec
.
Swagger
{},
nil
return
&
openapi_v2
.
Document
{},
nil
}
}
pkg/kubectl/cmd/util/openapi/BUILD
View file @
224dba9a
...
@@ -22,6 +22,8 @@ go_library(
...
@@ -22,6 +22,8 @@ go_library(
"//pkg/version:go_default_library",
"//pkg/version:go_default_library",
"//vendor/github.com/go-openapi/spec:go_default_library",
"//vendor/github.com/go-openapi/spec:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/googleapis/gnostic/OpenAPIv2:go_default_library",
"//vendor/gopkg.in/yaml.v2:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/client-go/discovery:go_default_library",
"//vendor/k8s.io/client-go/discovery:go_default_library",
...
@@ -41,12 +43,14 @@ go_test(
...
@@ -41,12 +43,14 @@ go_test(
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//pkg/kubectl/cmd/util/openapi:go_default_library",
"//pkg/kubectl/cmd/util/openapi:go_default_library",
"//vendor/github.com/go-openapi/loads:go_default_library",
"//vendor/github.com/go-openapi/spec:go_default_library",
"//vendor/github.com/go-openapi/spec:go_default_library",
"//vendor/github.com/googleapis/gnostic/OpenAPIv2:go_default_library",
"//vendor/github.com/googleapis/gnostic/compiler:go_default_library",
"//vendor/github.com/onsi/ginkgo:go_default_library",
"//vendor/github.com/onsi/ginkgo:go_default_library",
"//vendor/github.com/onsi/ginkgo/config:go_default_library",
"//vendor/github.com/onsi/ginkgo/config:go_default_library",
"//vendor/github.com/onsi/ginkgo/types:go_default_library",
"//vendor/github.com/onsi/ginkgo/types:go_default_library",
"//vendor/github.com/onsi/gomega:go_default_library",
"//vendor/github.com/onsi/gomega:go_default_library",
"//vendor/gopkg.in/yaml.v2:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
],
],
)
)
...
...
pkg/kubectl/cmd/util/openapi/openapi.go
View file @
224dba9a
This diff is collapsed.
Click to expand it.
pkg/kubectl/cmd/util/openapi/openapi_cache.go
View file @
224dba9a
...
@@ -187,7 +187,6 @@ func linkFiles(old, new string) error {
...
@@ -187,7 +187,6 @@ func linkFiles(old, new string) error {
// registerBinaryEncodingTypes registers the types so they can be binary encoded by gob
// registerBinaryEncodingTypes registers the types so they can be binary encoded by gob
func
registerBinaryEncodingTypes
()
{
func
registerBinaryEncodingTypes
()
{
gob
.
Register
(
map
[
string
]
interface
{}{})
gob
.
Register
(
map
[
interface
{}
]
interface
{}{})
gob
.
Register
([]
interface
{}{})
gob
.
Register
([]
interface
{}{})
gob
.
Register
(
Resources
{})
}
}
pkg/kubectl/cmd/util/openapi/openapi_cache_test.go
View file @
224dba9a
...
@@ -23,8 +23,10 @@ import (
...
@@ -23,8 +23,10 @@ import (
"path/filepath"
"path/filepath"
"sync"
"sync"
"github.com/go-openapi/loads"
"gopkg.in/yaml.v2"
"github.com/go-openapi/spec"
"github.com/googleapis/gnostic/OpenAPIv2"
"github.com/googleapis/gnostic/compiler"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
.
"github.com/onsi/gomega"
...
@@ -220,7 +222,7 @@ type fakeOpenAPIClient struct {
...
@@ -220,7 +222,7 @@ type fakeOpenAPIClient struct {
err
error
err
error
}
}
func
(
f
*
fakeOpenAPIClient
)
OpenAPISchema
()
(
*
spec
.
Swagger
,
error
)
{
func
(
f
*
fakeOpenAPIClient
)
OpenAPISchema
()
(
*
openapi_v2
.
Document
,
error
)
{
f
.
calls
=
f
.
calls
+
1
f
.
calls
=
f
.
calls
+
1
if
f
.
err
!=
nil
{
if
f
.
err
!=
nil
{
...
@@ -235,11 +237,11 @@ var data apiData
...
@@ -235,11 +237,11 @@ var data apiData
type
apiData
struct
{
type
apiData
struct
{
sync
.
Once
sync
.
Once
data
*
spec
.
Swagger
data
*
openapi_v2
.
Document
err
error
err
error
}
}
func
(
d
*
apiData
)
OpenAPISchema
()
(
*
spec
.
Swagger
,
error
)
{
func
(
d
*
apiData
)
OpenAPISchema
()
(
*
openapi_v2
.
Document
,
error
)
{
d
.
Do
(
func
()
{
d
.
Do
(
func
()
{
// Get the path to the swagger.json file
// Get the path to the swagger.json file
wd
,
err
:=
os
.
Getwd
()
wd
,
err
:=
os
.
Getwd
()
...
@@ -261,14 +263,18 @@ func (d *apiData) OpenAPISchema() (*spec.Swagger, error) {
...
@@ -261,14 +263,18 @@ func (d *apiData) OpenAPISchema() (*spec.Swagger, error) {
d
.
err
=
err
d
.
err
=
err
return
return
}
}
// Load the openapi document
spec
,
err
:=
ioutil
.
ReadFile
(
specpath
)
doc
,
err
:=
loads
.
Spec
(
specpath
)
if
err
!=
nil
{
if
err
!=
nil
{
d
.
err
=
err
d
.
err
=
err
return
return
}
}
var
info
yaml
.
MapSlice
d
.
data
=
doc
.
Spec
()
err
=
yaml
.
Unmarshal
(
spec
,
&
info
)
if
err
!=
nil
{
d
.
err
=
err
return
}
d
.
data
,
d
.
err
=
openapi_v2
.
NewDocument
(
info
,
compiler
.
NewContext
(
"$root"
,
nil
))
})
})
return
d
.
data
,
d
.
err
return
d
.
data
,
d
.
err
}
}
staging/src/k8s.io/apiextensions-apiserver/Godeps/Godeps.json
View file @
224dba9a
...
@@ -107,10 +107,6 @@
...
@@ -107,10 +107,6 @@
"Rev"
:
"73d445a93680fa1a78ae23a5839bad48f32ba1ee"
"Rev"
:
"73d445a93680fa1a78ae23a5839bad48f32ba1ee"
},
},
{
{
"ImportPath"
:
"github.com/go-openapi/analysis"
,
"Rev"
:
"b44dc874b601d9e4e2f6e19140e794ba24bead3b"
},
{
"ImportPath"
:
"github.com/go-openapi/jsonpointer"
,
"ImportPath"
:
"github.com/go-openapi/jsonpointer"
,
"Rev"
:
"46af16f9f7b149af66e5d1bd010e3574dc06de98"
"Rev"
:
"46af16f9f7b149af66e5d1bd010e3574dc06de98"
},
},
...
@@ -119,10 +115,6 @@
...
@@ -119,10 +115,6 @@
"Rev"
:
"13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272"
"Rev"
:
"13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272"
},
},
{
{
"ImportPath"
:
"github.com/go-openapi/loads"
,
"Rev"
:
"18441dfa706d924a39a030ee2c3b1d8d81917b38"
},
{
"ImportPath"
:
"github.com/go-openapi/spec"
,
"ImportPath"
:
"github.com/go-openapi/spec"
,
"Rev"
:
"6aced65f8501fe1217321abf0749d354824ba2ff"
"Rev"
:
"6aced65f8501fe1217321abf0749d354824ba2ff"
},
},
...
...
staging/src/k8s.io/apiserver/Godeps/Godeps.json
View file @
224dba9a
...
@@ -327,10 +327,6 @@
...
@@ -327,10 +327,6 @@
"Rev"
:
"73d445a93680fa1a78ae23a5839bad48f32ba1ee"
"Rev"
:
"73d445a93680fa1a78ae23a5839bad48f32ba1ee"
},
},
{
{
"ImportPath"
:
"github.com/go-openapi/analysis"
,
"Rev"
:
"b44dc874b601d9e4e2f6e19140e794ba24bead3b"
},
{
"ImportPath"
:
"github.com/go-openapi/jsonpointer"
,
"ImportPath"
:
"github.com/go-openapi/jsonpointer"
,
"Rev"
:
"46af16f9f7b149af66e5d1bd010e3574dc06de98"
"Rev"
:
"46af16f9f7b149af66e5d1bd010e3574dc06de98"
},
},
...
@@ -339,10 +335,6 @@
...
@@ -339,10 +335,6 @@
"Rev"
:
"13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272"
"Rev"
:
"13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272"
},
},
{
{
"ImportPath"
:
"github.com/go-openapi/loads"
,
"Rev"
:
"18441dfa706d924a39a030ee2c3b1d8d81917b38"
},
{
"ImportPath"
:
"github.com/go-openapi/spec"
,
"ImportPath"
:
"github.com/go-openapi/spec"
,
"Rev"
:
"6aced65f8501fe1217321abf0749d354824ba2ff"
"Rev"
:
"6aced65f8501fe1217321abf0749d354824ba2ff"
},
},
...
...
staging/src/k8s.io/client-go/Godeps/Godeps.json
View file @
224dba9a
...
@@ -99,10 +99,6 @@
...
@@ -99,10 +99,6 @@
"Rev"
:
"73d445a93680fa1a78ae23a5839bad48f32ba1ee"
"Rev"
:
"73d445a93680fa1a78ae23a5839bad48f32ba1ee"
},
},
{
{
"ImportPath"
:
"github.com/go-openapi/analysis"
,
"Rev"
:
"b44dc874b601d9e4e2f6e19140e794ba24bead3b"
},
{
"ImportPath"
:
"github.com/go-openapi/jsonpointer"
,
"ImportPath"
:
"github.com/go-openapi/jsonpointer"
,
"Rev"
:
"46af16f9f7b149af66e5d1bd010e3574dc06de98"
"Rev"
:
"46af16f9f7b149af66e5d1bd010e3574dc06de98"
},
},
...
@@ -111,10 +107,6 @@
...
@@ -111,10 +107,6 @@
"Rev"
:
"13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272"
"Rev"
:
"13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272"
},
},
{
{
"ImportPath"
:
"github.com/go-openapi/loads"
,
"Rev"
:
"18441dfa706d924a39a030ee2c3b1d8d81917b38"
},
{
"ImportPath"
:
"github.com/go-openapi/spec"
,
"ImportPath"
:
"github.com/go-openapi/spec"
,
"Rev"
:
"6aced65f8501fe1217321abf0749d354824ba2ff"
"Rev"
:
"6aced65f8501fe1217321abf0749d354824ba2ff"
},
},
...
@@ -143,10 +135,38 @@
...
@@ -143,10 +135,38 @@
"Rev"
:
"4bd1920723d7b7c925de087aa32e2187708897f7"
"Rev"
:
"4bd1920723d7b7c925de087aa32e2187708897f7"
},
},
{
{
"ImportPath"
:
"github.com/golang/protobuf/ptypes"
,
"Rev"
:
"4bd1920723d7b7c925de087aa32e2187708897f7"
},
{
"ImportPath"
:
"github.com/golang/protobuf/ptypes/any"
,
"Rev"
:
"4bd1920723d7b7c925de087aa32e2187708897f7"
},
{
"ImportPath"
:
"github.com/golang/protobuf/ptypes/duration"
,
"Rev"
:
"4bd1920723d7b7c925de087aa32e2187708897f7"
},
{
"ImportPath"
:
"github.com/golang/protobuf/ptypes/timestamp"
,
"Rev"
:
"4bd1920723d7b7c925de087aa32e2187708897f7"
},
{
"ImportPath"
:
"github.com/google/gofuzz"
,
"ImportPath"
:
"github.com/google/gofuzz"
,
"Rev"
:
"44d81051d367757e1c7c6a5a86423ece9afcf63c"
"Rev"
:
"44d81051d367757e1c7c6a5a86423ece9afcf63c"
},
},
{
{
"ImportPath"
:
"github.com/googleapis/gnostic/OpenAPIv2"
,
"Rev"
:
"68f4ded48ba9414dab2ae69b3f0d69971da73aa5"
},
{
"ImportPath"
:
"github.com/googleapis/gnostic/compiler"
,
"Rev"
:
"68f4ded48ba9414dab2ae69b3f0d69971da73aa5"
},
{
"ImportPath"
:
"github.com/googleapis/gnostic/extensions"
,
"Rev"
:
"68f4ded48ba9414dab2ae69b3f0d69971da73aa5"
},
{
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"Rev"
:
"a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4"
"Rev"
:
"a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4"
},
},
...
...
staging/src/k8s.io/client-go/discovery/BUILD
View file @
224dba9a
...
@@ -19,9 +19,9 @@ go_library(
...
@@ -19,9 +19,9 @@ go_library(
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//vendor/github.com/emicklei/go-restful-swagger12:go_default_library",
"//vendor/github.com/emicklei/go-restful-swagger12:go_default_library",
"//vendor/github.com/go-openapi/loads:go_default_library",
"//vendor/github.com/go-openapi/spec:go_default_library",
"//vendor/github.com/golang/glog: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/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors: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/api/meta:go_default_library",
...
@@ -46,7 +46,8 @@ go_test(
...
@@ -46,7 +46,8 @@ go_test(
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//vendor/github.com/emicklei/go-restful-swagger12:go_default_library",
"//vendor/github.com/emicklei/go-restful-swagger12:go_default_library",
"//vendor/github.com/go-openapi/spec: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",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/k8s.io/api/core/v1: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/errors:go_default_library",
...
...
staging/src/k8s.io/client-go/discovery/discovery_client.go
View file @
224dba9a
...
@@ -24,9 +24,9 @@ import (
...
@@ -24,9 +24,9 @@ import (
"strings"
"strings"
"github.com/emicklei/go-restful-swagger12"
"github.com/emicklei/go-restful-swagger12"
"github.com/golang/protobuf/proto"
"github.com/googleapis/gnostic/OpenAPIv2"
"github.com/go-openapi/loads"
"github.com/go-openapi/spec"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
@@ -97,7 +97,7 @@ type SwaggerSchemaInterface interface {
...
@@ -97,7 +97,7 @@ type SwaggerSchemaInterface interface {
// OpenAPISchemaInterface has a method to retrieve the open API schema.
// OpenAPISchemaInterface has a method to retrieve the open API schema.
type
OpenAPISchemaInterface
interface
{
type
OpenAPISchemaInterface
interface
{
// OpenAPISchema retrieves and parses the swagger API schema the server supports.
// OpenAPISchema retrieves and parses the swagger API schema the server supports.
OpenAPISchema
()
(
*
spec
.
Swagger
,
error
)
OpenAPISchema
()
(
*
openapi_v2
.
Document
,
error
)
}
}
// DiscoveryClient implements the functions that discover server-supported API groups,
// DiscoveryClient implements the functions that discover server-supported API groups,
...
@@ -375,19 +375,18 @@ func (d *DiscoveryClient) SwaggerSchema(version schema.GroupVersion) (*swagger.A
...
@@ -375,19 +375,18 @@ func (d *DiscoveryClient) SwaggerSchema(version schema.GroupVersion) (*swagger.A
return
&
schema
,
nil
return
&
schema
,
nil
}
}
// OpenAPISchema fetches the open api schema using a rest client and parses the json.
// OpenAPISchema fetches the open api schema using a rest client and parses the proto.
// Warning: this is very expensive (~1.2s)
func
(
d
*
DiscoveryClient
)
OpenAPISchema
()
(
*
openapi_v2
.
Document
,
error
)
{
func
(
d
*
DiscoveryClient
)
OpenAPISchema
()
(
*
spec
.
Swagger
,
error
)
{
data
,
err
:=
d
.
restClient
.
Get
()
.
AbsPath
(
"/swagger-2.0.0.pb-v1"
)
.
Do
()
.
Raw
()
data
,
err
:=
d
.
restClient
.
Get
()
.
AbsPath
(
"/swagger.json"
)
.
Do
()
.
Raw
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
msg
:=
json
.
RawMessage
(
data
)
document
:=
&
openapi_v2
.
Document
{}
doc
,
err
:=
loads
.
Analyzed
(
msg
,
""
)
err
=
proto
.
Unmarshal
(
data
,
document
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
doc
.
Spec
(),
err
return
doc
ument
,
nil
}
}
// withRetries retries the given recovery function in case the groups supported by the server change after ServerGroup() returns.
// withRetries retries the given recovery function in case the groups supported by the server change after ServerGroup() returns.
...
...
staging/src/k8s.io/client-go/discovery/discovery_client_test.go
View file @
224dba9a
...
@@ -19,14 +19,16 @@ package discovery_test
...
@@ -19,14 +19,16 @@ package discovery_test
import
(
import
(
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"mime"
"net/http"
"net/http"
"net/http/httptest"
"net/http/httptest"
"reflect"
"reflect"
"testing"
"testing"
"github.com/emicklei/go-restful-swagger12"
"github.com/emicklei/go-restful-swagger12"
"github.com/gogo/protobuf/proto"
"github.com/googleapis/gnostic/OpenAPIv2"
"github.com/go-openapi/spec"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
...
@@ -327,30 +329,44 @@ func TestGetSwaggerSchemaFail(t *testing.T) {
...
@@ -327,30 +329,44 @@ func TestGetSwaggerSchemaFail(t *testing.T) {
}
}
}
}
var
returnedOpenAPI
=
spec
.
Swagger
{
var
returnedOpenAPI
=
openapi_v2
.
Document
{
SwaggerProps
:
spec
.
SwaggerProps
{
Definitions
:
&
openapi_v2
.
Definitions
{
Definitions
:
spec
.
Definitions
{
AdditionalProperties
:
[]
*
openapi_v2
.
NamedSchema
{
"fake.type.1"
:
spec
.
Schema
{
{
SchemaProps
:
spec
.
SchemaProps
{
Name
:
"fake.type.1"
,
Properties
:
map
[
string
]
spec
.
Schema
{
Value
:
&
openapi_v2
.
Schema
{
"count"
:
{
Properties
:
&
openapi_v2
.
Properties
{
SchemaProps
:
spec
.
SchemaProps
{
AdditionalProperties
:
[]
*
openapi_v2
.
NamedSchema
{
Type
:
[]
string
{
"integer"
},
{
Name
:
"count"
,
Value
:
&
openapi_v2
.
Schema
{
Type
:
&
openapi_v2
.
TypeItem
{
Value
:
[]
string
{
"integer"
},
},
},
},
},
},
},
},
},
},
},
{
Name
:
"fake.type.2"
,
Value
:
&
openapi_v2
.
Schema
{
Properties
:
&
openapi_v2
.
Properties
{
AdditionalProperties
:
[]
*
openapi_v2
.
NamedSchema
{
{
Name
:
"count"
,
Value
:
&
openapi_v2
.
Schema
{
Type
:
&
openapi_v2
.
TypeItem
{
Value
:
[]
string
{
"array"
},
},
Items
:
&
openapi_v2
.
ItemsItem
{
Schema
:
[]
*
openapi_v2
.
Schema
{
{
Type
:
&
openapi_v2
.
TypeItem
{
Value
:
[]
string
{
"string"
},
},
},
},
},
"fake.type.2"
:
spec
.
Schema
{
SchemaProps
:
spec
.
SchemaProps
{
Properties
:
map
[
string
]
spec
.
Schema
{
"count"
:
{
SchemaProps
:
spec
.
SchemaProps
{
Type
:
[]
string
{
"array"
},
Items
:
&
spec
.
SchemaOrArray
{
Schema
:
&
spec
.
Schema
{
SchemaProps
:
spec
.
SchemaProps
{
Type
:
[]
string
{
"string"
},
},
},
},
},
},
},
...
@@ -366,19 +382,20 @@ var returnedOpenAPI = spec.Swagger{
...
@@ -366,19 +382,20 @@ var returnedOpenAPI = spec.Swagger{
func
openapiSchemaFakeServer
()
(
*
httptest
.
Server
,
error
)
{
func
openapiSchemaFakeServer
()
(
*
httptest
.
Server
,
error
)
{
var
sErr
error
var
sErr
error
server
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
server
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
if
req
.
URL
.
Path
!=
"/swagger
.json
"
{
if
req
.
URL
.
Path
!=
"/swagger
-2.0.0.pb-v1
"
{
sErr
=
fmt
.
Errorf
(
"Unexpected url %v"
,
req
.
URL
)
sErr
=
fmt
.
Errorf
(
"Unexpected url %v"
,
req
.
URL
)
}
}
if
req
.
Method
!=
"GET"
{
if
req
.
Method
!=
"GET"
{
sErr
=
fmt
.
Errorf
(
"Unexpected method %v"
,
req
.
Method
)
sErr
=
fmt
.
Errorf
(
"Unexpected method %v"
,
req
.
Method
)
}
}
output
,
err
:=
json
.
Marshal
(
returnedOpenAPI
)
mime
.
AddExtensionType
(
".pb-v1"
,
"application/com.github.googleapis.gnostic.OpenAPIv2@68f4ded+protobuf"
)
output
,
err
:=
proto
.
Marshal
(
&
returnedOpenAPI
)
if
err
!=
nil
{
if
err
!=
nil
{
sErr
=
err
sErr
=
err
return
return
}
}
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
w
.
WriteHeader
(
http
.
StatusOK
)
w
.
WriteHeader
(
http
.
StatusOK
)
w
.
Write
(
output
)
w
.
Write
(
output
)
}))
}))
...
...
staging/src/k8s.io/client-go/discovery/fake/BUILD
View file @
224dba9a
...
@@ -13,7 +13,7 @@ go_library(
...
@@ -13,7 +13,7 @@ go_library(
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//vendor/github.com/emicklei/go-restful-swagger12:go_default_library",
"//vendor/github.com/emicklei/go-restful-swagger12:go_default_library",
"//vendor/github.com/go
-openapi/spec
:go_default_library",
"//vendor/github.com/go
ogleapis/gnostic/OpenAPIv2
:go_default_library",
"//vendor/k8s.io/api/core/v1: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/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
...
...
staging/src/k8s.io/client-go/discovery/fake/discovery.go
View file @
224dba9a
...
@@ -20,8 +20,8 @@ import (
...
@@ -20,8 +20,8 @@ import (
"fmt"
"fmt"
"github.com/emicklei/go-restful-swagger12"
"github.com/emicklei/go-restful-swagger12"
"github.com/googleapis/gnostic/OpenAPIv2"
"github.com/go-openapi/spec"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
...
@@ -93,7 +93,9 @@ func (c *FakeDiscovery) SwaggerSchema(version schema.GroupVersion) (*swagger.Api
...
@@ -93,7 +93,9 @@ func (c *FakeDiscovery) SwaggerSchema(version schema.GroupVersion) (*swagger.Api
return
&
swagger
.
ApiDeclaration
{},
nil
return
&
swagger
.
ApiDeclaration
{},
nil
}
}
func
(
c
*
FakeDiscovery
)
OpenAPISchema
()
(
*
spec
.
Swagger
,
error
)
{
return
&
spec
.
Swagger
{},
nil
}
func
(
c
*
FakeDiscovery
)
OpenAPISchema
()
(
*
openapi_v2
.
Document
,
error
)
{
return
&
openapi_v2
.
Document
{},
nil
}
func
(
c
*
FakeDiscovery
)
RESTClient
()
restclient
.
Interface
{
func
(
c
*
FakeDiscovery
)
RESTClient
()
restclient
.
Interface
{
return
nil
return
nil
...
...
staging/src/k8s.io/client-go/discovery/restmapper_test.go
View file @
224dba9a
...
@@ -29,7 +29,7 @@ import (
...
@@ -29,7 +29,7 @@ import (
"k8s.io/client-go/rest/fake"
"k8s.io/client-go/rest/fake"
"github.com/emicklei/go-restful-swagger12"
"github.com/emicklei/go-restful-swagger12"
"github.com/go
-openapi/spec
"
"github.com/go
ogleapis/gnostic/OpenAPIv2
"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
)
)
...
@@ -348,6 +348,6 @@ func (c *fakeCachedDiscoveryInterface) SwaggerSchema(version schema.GroupVersion
...
@@ -348,6 +348,6 @@ func (c *fakeCachedDiscoveryInterface) SwaggerSchema(version schema.GroupVersion
return
&
swagger
.
ApiDeclaration
{},
nil
return
&
swagger
.
ApiDeclaration
{},
nil
}
}
func
(
c
*
fakeCachedDiscoveryInterface
)
OpenAPISchema
()
(
*
spec
.
Swagger
,
error
)
{
func
(
c
*
fakeCachedDiscoveryInterface
)
OpenAPISchema
()
(
*
openapi_v2
.
Document
,
error
)
{
return
&
spec
.
Swagger
{},
nil
return
&
openapi_v2
.
Document
{},
nil
}
}
staging/src/k8s.io/kube-aggregator/Godeps/Godeps.json
View file @
224dba9a
...
@@ -115,10 +115,6 @@
...
@@ -115,10 +115,6 @@
"Rev"
:
"73d445a93680fa1a78ae23a5839bad48f32ba1ee"
"Rev"
:
"73d445a93680fa1a78ae23a5839bad48f32ba1ee"
},
},
{
{
"ImportPath"
:
"github.com/go-openapi/analysis"
,
"Rev"
:
"b44dc874b601d9e4e2f6e19140e794ba24bead3b"
},
{
"ImportPath"
:
"github.com/go-openapi/jsonpointer"
,
"ImportPath"
:
"github.com/go-openapi/jsonpointer"
,
"Rev"
:
"46af16f9f7b149af66e5d1bd010e3574dc06de98"
"Rev"
:
"46af16f9f7b149af66e5d1bd010e3574dc06de98"
},
},
...
@@ -127,10 +123,6 @@
...
@@ -127,10 +123,6 @@
"Rev"
:
"13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272"
"Rev"
:
"13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272"
},
},
{
{
"ImportPath"
:
"github.com/go-openapi/loads"
,
"Rev"
:
"18441dfa706d924a39a030ee2c3b1d8d81917b38"
},
{
"ImportPath"
:
"github.com/go-openapi/spec"
,
"ImportPath"
:
"github.com/go-openapi/spec"
,
"Rev"
:
"6aced65f8501fe1217321abf0749d354824ba2ff"
"Rev"
:
"6aced65f8501fe1217321abf0749d354824ba2ff"
},
},
...
...
staging/src/k8s.io/sample-apiserver/Godeps/Godeps.json
View file @
224dba9a
...
@@ -107,10 +107,6 @@
...
@@ -107,10 +107,6 @@
"Rev"
:
"73d445a93680fa1a78ae23a5839bad48f32ba1ee"
"Rev"
:
"73d445a93680fa1a78ae23a5839bad48f32ba1ee"
},
},
{
{
"ImportPath"
:
"github.com/go-openapi/analysis"
,
"Rev"
:
"b44dc874b601d9e4e2f6e19140e794ba24bead3b"
},
{
"ImportPath"
:
"github.com/go-openapi/jsonpointer"
,
"ImportPath"
:
"github.com/go-openapi/jsonpointer"
,
"Rev"
:
"46af16f9f7b149af66e5d1bd010e3574dc06de98"
"Rev"
:
"46af16f9f7b149af66e5d1bd010e3574dc06de98"
},
},
...
@@ -119,10 +115,6 @@
...
@@ -119,10 +115,6 @@
"Rev"
:
"13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272"
"Rev"
:
"13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272"
},
},
{
{
"ImportPath"
:
"github.com/go-openapi/loads"
,
"Rev"
:
"18441dfa706d924a39a030ee2c3b1d8d81917b38"
},
{
"ImportPath"
:
"github.com/go-openapi/spec"
,
"ImportPath"
:
"github.com/go-openapi/spec"
,
"Rev"
:
"6aced65f8501fe1217321abf0749d354824ba2ff"
"Rev"
:
"6aced65f8501fe1217321abf0749d354824ba2ff"
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment