From 5f908c226c9df144dfc0e1665381b8ec534a60a4 Mon Sep 17 00:00:00 2001 From: hangaoshuai Date: Fri, 23 Feb 2018 14:53:51 +0800 Subject: [PATCH] remove unused function negotiate() and writeYAML() --- .../k8s.io/apiserver/pkg/admission/config.go | 24 ----------------- .../handlers/negotiation/negotiate.go | 26 ------------------- 2 files changed, 50 deletions(-) diff --git a/staging/src/k8s.io/apiserver/pkg/admission/config.go b/staging/src/k8s.io/apiserver/pkg/admission/config.go index 07c2c90f83f..f59d0608bce 100644 --- a/staging/src/k8s.io/apiserver/pkg/admission/config.go +++ b/staging/src/k8s.io/apiserver/pkg/admission/config.go @@ -29,7 +29,6 @@ import ( "github.com/golang/glog" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apiserver/pkg/apis/apiserver" @@ -177,26 +176,3 @@ func (p configProvider) ConfigFor(pluginName string) (io.Reader, error) { // there is no registered config that matches on plugin name. return nil, nil } - -// writeYAML writes the specified object to a byte array as yaml. -func writeYAML(obj runtime.Object, scheme *runtime.Scheme) ([]byte, error) { - gvks, _, err := scheme.ObjectKinds(obj) - if err != nil { - return nil, err - } - gvs := []schema.GroupVersion{} - for _, gvk := range gvks { - gvs = append(gvs, gvk.GroupVersion()) - } - codecs := serializer.NewCodecFactory(scheme) - json, err := runtime.Encode(codecs.LegacyCodec(gvs...), obj) - if err != nil { - return nil, err - } - - content, err := yaml.JSONToYAML(json) - if err != nil { - return nil, err - } - return content, err -} diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/negotiation/negotiate.go b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/negotiation/negotiate.go index 226c0efe931..f9bb47babca 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/negotiation/negotiate.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/negotiation/negotiate.go @@ -119,32 +119,6 @@ func isPrettyPrint(req *http.Request) bool { return false } -// negotiate the most appropriate content type given the accept header and a list of -// alternatives. -func negotiate(header string, alternatives []string) (goautoneg.Accept, bool) { - alternates := make([][]string, 0, len(alternatives)) - for _, alternate := range alternatives { - alternates = append(alternates, strings.SplitN(alternate, "/", 2)) - } - for _, clause := range goautoneg.ParseAccept(header) { - for _, alternate := range alternates { - if clause.Type == alternate[0] && clause.SubType == alternate[1] { - return clause, true - } - if clause.Type == alternate[0] && clause.SubType == "*" { - clause.SubType = alternate[1] - return clause, true - } - if clause.Type == "*" && clause.SubType == "*" { - clause.Type = alternate[0] - clause.SubType = alternate[1] - return clause, true - } - } - } - return goautoneg.Accept{}, false -} - // EndpointRestrictions is an interface that allows content-type negotiation // to verify server support for specific options type EndpointRestrictions interface {