1 /* 2 Copyright 2014 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package latest 18 19 import ( 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. 30 const Version = "v1" 31 32 var 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. 36 const 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. 42 var Versions = []string{"v1"} 43 44 var ( 45 Codec runtime.Codec 46 Scheme *runtime.Scheme 47 ) 48 49 func 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 } 62