mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
Use global Scheme for API group.
This commit is contained in:
parent
2b938b985c
commit
1d589600bc
@ -164,16 +164,11 @@ func AddFlags(options *Options, fs *pflag.FlagSet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewOptions() (*Options, error) {
|
func NewOptions() (*Options, error) {
|
||||||
scheme, codecs, err := scheme.NewSchemeAndCodecs()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
o := &Options{
|
o := &Options{
|
||||||
config: new(proxyconfig.KubeProxyConfiguration),
|
config: new(proxyconfig.KubeProxyConfiguration),
|
||||||
healthzPort: ports.ProxyHealthzPort,
|
healthzPort: ports.ProxyHealthzPort,
|
||||||
scheme: scheme,
|
scheme: scheme.Scheme,
|
||||||
codecs: *codecs,
|
codecs: scheme.Codecs,
|
||||||
}
|
}
|
||||||
|
|
||||||
return o, nil
|
return o, nil
|
||||||
|
@ -17,24 +17,29 @@ limitations under the License.
|
|||||||
package scheme
|
package scheme
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/runtime/serializer"
|
"k8s.io/apimachinery/pkg/runtime/serializer"
|
||||||
"k8s.io/kubernetes/pkg/proxy/apis/proxyconfig"
|
"k8s.io/kubernetes/pkg/proxy/apis/proxyconfig"
|
||||||
"k8s.io/kubernetes/pkg/proxy/apis/proxyconfig/v1alpha1"
|
"k8s.io/kubernetes/pkg/proxy/apis/proxyconfig/v1alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Utility functions for the Kube-proxy's "kubeproxy.k8s.io" API group
|
var (
|
||||||
|
// Scheme defines methods for serializing and deserializing API objects.
|
||||||
|
Scheme = runtime.NewScheme()
|
||||||
|
// Codecs provides methods for retrieving codecs and serializers for specific
|
||||||
|
// versions and content types.
|
||||||
|
Codecs = serializer.NewCodecFactory(Scheme)
|
||||||
|
)
|
||||||
|
|
||||||
// NewSchemeAndCodecs is a utility funciton that returns a Scheme and CodecFactory
|
func init() {
|
||||||
// that understand the types in the "kubeproxy.k8s.io" API group.
|
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
|
||||||
func NewSchemeAndCodecs() (*runtime.Scheme, *serializer.CodecFactory, error) {
|
AddToScheme(Scheme)
|
||||||
scheme := runtime.NewScheme()
|
}
|
||||||
if err := proxyconfig.AddToScheme(scheme); err != nil {
|
|
||||||
return nil, nil, err
|
// AddToScheme adds the types of this group into the given scheme.
|
||||||
}
|
func AddToScheme(scheme *runtime.Scheme) {
|
||||||
if err := v1alpha1.AddToScheme(scheme); err != nil {
|
v1alpha1.AddToScheme(scheme)
|
||||||
return nil, nil, err
|
proxyconfig.AddToScheme(scheme)
|
||||||
}
|
|
||||||
codecs := serializer.NewCodecFactory(scheme)
|
|
||||||
return scheme, &codecs, nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user