blob: 35bb5dde19c252e894f7c4542576e8ff5bab2887 [file] [log] [blame]
Zack Williamse940c7a2019-08-21 14:25:39 -07001/*
2Copyright 2014 The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package latest
18
19import (
20 "k8s.io/apimachinery/pkg/runtime"
21 "k8s.io/apimachinery/pkg/runtime/schema"
22 "k8s.io/apimachinery/pkg/runtime/serializer/json"
23 "k8s.io/apimachinery/pkg/runtime/serializer/versioning"
24 utilruntime "k8s.io/apimachinery/pkg/util/runtime"
25 "k8s.io/client-go/tools/clientcmd/api"
26 "k8s.io/client-go/tools/clientcmd/api/v1"
27)
28
29// Version is the string that represents the current external default version.
30const Version = "v1"
31
32var ExternalVersion = schema.GroupVersion{Group: "", Version: "v1"}
33
34// OldestVersion is the string that represents the oldest server version supported,
35// for client code that wants to hardcode the lowest common denominator.
36const OldestVersion = "v1"
37
38// Versions is the list of versions that are recognized in code. The order provided
39// may be assumed to be least feature rich to most feature rich, and clients may
40// choose to prefer the latter items in the list over the former items when presented
41// with a set of versions to choose.
42var Versions = []string{"v1"}
43
44var (
45 Codec runtime.Codec
46 Scheme *runtime.Scheme
47)
48
49func init() {
50 Scheme = runtime.NewScheme()
51 utilruntime.Must(api.AddToScheme(Scheme))
52 utilruntime.Must(v1.AddToScheme(Scheme))
53 yamlSerializer := json.NewYAMLSerializer(json.DefaultMetaFactory, Scheme, Scheme)
54 Codec = versioning.NewDefaultingCodecForScheme(
55 Scheme,
56 yamlSerializer,
57 yamlSerializer,
58 schema.GroupVersion{Version: Version},
59 runtime.InternalGroupVersioner,
60 )
61}