Skip to content

Commit

Permalink
remove unused function negotiate() and writeYAML()
Browse files Browse the repository at this point in the history
Kubernetes-commit: 5f908c226c9df144dfc0e1665381b8ec534a60a4
  • Loading branch information
hanxiaoshuai authored and k8s-publishing-bot committed Feb 23, 2018
1 parent 3ff739d commit 9aafd9d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 50 deletions.
24 changes: 0 additions & 24 deletions pkg/admission/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
26 changes: 0 additions & 26 deletions pkg/endpoints/handlers/negotiation/negotiate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9aafd9d

Please sign in to comment.