latest.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. Copyright 2014 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package latest
  14. import (
  15. "k8s.io/apimachinery/pkg/runtime"
  16. "k8s.io/apimachinery/pkg/runtime/schema"
  17. "k8s.io/apimachinery/pkg/runtime/serializer/json"
  18. "k8s.io/apimachinery/pkg/runtime/serializer/versioning"
  19. "k8s.io/apimachinery/pkg/runtime/serializer/yaml"
  20. schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
  21. // Init the api v1 package
  22. _ "k8s.io/kubernetes/pkg/scheduler/api/v1"
  23. )
  24. // Version is the string that represents the current external default version.
  25. const Version = "v1"
  26. // OldestVersion is the string that represents the oldest server version supported.
  27. const OldestVersion = "v1"
  28. // Versions is the list of versions that are recognized in code. The order provided
  29. // may be assumed to be least feature rich to most feature rich, and clients may
  30. // choose to prefer the latter items in the list over the former items when presented
  31. // with a set of versions to choose.
  32. var Versions = []string{"v1"}
  33. // Codec is the default codec for serializing input that should use
  34. // the latest supported version. It supports JSON by default.
  35. var Codec runtime.Codec
  36. func init() {
  37. jsonSerializer := json.NewSerializer(json.DefaultMetaFactory, schedulerapi.Scheme, schedulerapi.Scheme, true)
  38. serializer := yaml.NewDecodingSerializer(jsonSerializer)
  39. Codec = versioning.NewDefaultingCodecForScheme(
  40. schedulerapi.Scheme,
  41. serializer,
  42. serializer,
  43. schema.GroupVersion{Version: Version},
  44. runtime.InternalGroupVersioner,
  45. )
  46. }