mirror of https://github.com/k3s-io/k3s
Merge pull request #60280 from hanxiaoshuai/cleanup0223
Automatic merge from submit-queue (batch tested with PRs 60470, 59149, 56075, 60280, 60504). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. remove unused function negotiate() and writeYAML() **What this PR does / why we need it**: remove unused function negotiate() and writeYAML() in k8s.io/apiserver/pkg **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ```pull/6/head
commit
e2cbda006a
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue