latest.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. utilruntime "k8s.io/apimachinery/pkg/util/runtime"
  20. "k8s.io/client-go/tools/clientcmd/api"
  21. "k8s.io/client-go/tools/clientcmd/api/v1"
  22. )
  23. // Version is the string that represents the current external default version.
  24. const Version = "v1"
  25. var ExternalVersion = schema.GroupVersion{Group: "", Version: "v1"}
  26. // OldestVersion is the string that represents the oldest server version supported,
  27. // for client code that wants to hardcode the lowest common denominator.
  28. const OldestVersion = "v1"
  29. // Versions is the list of versions that are recognized in code. The order provided
  30. // may be assumed to be least feature rich to most feature rich, and clients may
  31. // choose to prefer the latter items in the list over the former items when presented
  32. // with a set of versions to choose.
  33. var Versions = []string{"v1"}
  34. var (
  35. Codec runtime.Codec
  36. Scheme *runtime.Scheme
  37. )
  38. func init() {
  39. Scheme = runtime.NewScheme()
  40. utilruntime.Must(api.AddToScheme(Scheme))
  41. utilruntime.Must(v1.AddToScheme(Scheme))
  42. yamlSerializer := json.NewYAMLSerializer(json.DefaultMetaFactory, Scheme, Scheme)
  43. Codec = versioning.NewDefaultingCodecForScheme(
  44. Scheme,
  45. yamlSerializer,
  46. yamlSerializer,
  47. schema.GroupVersion{Version: Version},
  48. runtime.InternalGroupVersioner,
  49. )
  50. }