mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Drop openapi hack
This commit is contained in:
parent
f34329f4f1
commit
f0382329a5
1
main.go
1
main.go
@ -3,7 +3,6 @@
|
||||
//go:generate go run pkg/codegen/main.go
|
||||
//go:generate go fmt pkg/deploy/zz_generated_bindata.go
|
||||
//go:generate go fmt pkg/static/zz_generated_bindata.go
|
||||
//go:generate go fmt pkg/openapi/zz_generated_bindata.go
|
||||
|
||||
package main
|
||||
|
||||
|
@ -57,7 +57,7 @@ func (in *Addon) DeepCopyObject() runtime.Object {
|
||||
func (in *AddonList) DeepCopyInto(out *AddonList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]Addon, len(*in))
|
||||
@ -154,7 +154,7 @@ func (in *ListenerConfig) DeepCopyObject() runtime.Object {
|
||||
func (in *ListenerConfigList) DeepCopyInto(out *ListenerConfigList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]ListenerConfig, len(*in))
|
||||
|
@ -64,24 +64,6 @@ func main() {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
bc = &bindata.Config{
|
||||
Input: []bindata.InputConfig{
|
||||
{
|
||||
Path: "vendor/k8s.io/kubernetes/openapi.json",
|
||||
},
|
||||
{
|
||||
Path: "vendor/k8s.io/kubernetes/openapi.pb",
|
||||
},
|
||||
},
|
||||
Package: "openapi",
|
||||
NoMetadata: true,
|
||||
Prefix: "vendor/k8s.io/kubernetes/",
|
||||
Output: "pkg/openapi/zz_generated_bindata.go",
|
||||
}
|
||||
if err := bindata.Translate(bc); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
controllergen.Run(args.Options{
|
||||
OutputPackage: "github.com/rancher/k3s/pkg/generated",
|
||||
Boilerplate: "scripts/boilerplate.go.txt",
|
||||
|
@ -41,7 +41,7 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
||||
}
|
||||
}
|
||||
|
||||
cs := &Clientset{}
|
||||
cs := &Clientset{tracker: o}
|
||||
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
|
||||
cs.AddReactor("*", "*", testing.ObjectReaction(o))
|
||||
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
||||
@ -63,12 +63,17 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
||||
type Clientset struct {
|
||||
testing.Fake
|
||||
discovery *fakediscovery.FakeDiscovery
|
||||
tracker testing.ObjectTracker
|
||||
}
|
||||
|
||||
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
|
||||
return c.discovery
|
||||
}
|
||||
|
||||
func (c *Clientset) Tracker() testing.ObjectTracker {
|
||||
return c.tracker
|
||||
}
|
||||
|
||||
var _ clientset.Interface = &Clientset{}
|
||||
|
||||
// K3sV1 retrieves the K3sV1Client
|
||||
|
@ -21,7 +21,6 @@ package v1
|
||||
import (
|
||||
v1 "github.com/rancher/k3s/pkg/apis/k3s.cattle.io/v1"
|
||||
"github.com/rancher/k3s/pkg/generated/clientset/versioned/scheme"
|
||||
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
@ -76,7 +75,7 @@ func setConfigDefaults(config *rest.Config) error {
|
||||
gv := v1.SchemeGroupVersion
|
||||
config.GroupVersion = &gv
|
||||
config.APIPath = "/apis"
|
||||
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs}
|
||||
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
|
||||
|
||||
if config.UserAgent == "" {
|
||||
config.UserAgent = rest.DefaultKubernetesUserAgent()
|
||||
|
File diff suppressed because one or more lines are too long
@ -19,7 +19,6 @@ import (
|
||||
certutil "github.com/rancher/dynamiclistener/cert"
|
||||
"github.com/rancher/k3s/pkg/daemons/config"
|
||||
"github.com/rancher/k3s/pkg/daemons/control"
|
||||
"github.com/rancher/k3s/pkg/openapi"
|
||||
"github.com/sirupsen/logrus"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
)
|
||||
@ -54,7 +53,6 @@ func router(serverConfig *config.Control, tunnel http.Handler, cacertsGetter CAC
|
||||
router.NotFoundHandler = authed
|
||||
router.PathPrefix(staticURL).Handler(serveStatic(staticURL, staticDir))
|
||||
router.Path("/cacerts").Handler(cacerts(cacertsGetter))
|
||||
router.Path("/openapi/v2").Handler(serveOpenapi())
|
||||
router.Path("/ping").Handler(ping())
|
||||
|
||||
return router
|
||||
@ -220,28 +218,6 @@ func configHandler(server *config.Control) http.Handler {
|
||||
})
|
||||
}
|
||||
|
||||
func serveOpenapi() http.Handler {
|
||||
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
|
||||
suffix := "json"
|
||||
contentType := jsonMediaType
|
||||
if req.Header.Get("Accept") == pbMediaType {
|
||||
suffix = "pb"
|
||||
contentType = binaryMediaType
|
||||
}
|
||||
|
||||
data, err := openapi.Asset(openapiPrefix + suffix)
|
||||
if err != nil {
|
||||
resp.WriteHeader(http.StatusInternalServerError)
|
||||
resp.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
resp.Header().Set("Content-Type", contentType)
|
||||
resp.Header().Set("Content-Length", strconv.Itoa(len(data)))
|
||||
resp.Write(data)
|
||||
})
|
||||
}
|
||||
|
||||
func ping() http.Handler {
|
||||
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
|
||||
data := []byte("pong")
|
||||
|
Loading…
Reference in New Issue
Block a user