forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scheme.go
32 lines (26 loc) · 1.16 KB
/
scheme.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package util
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
appsv1 "github.com/openshift/api/apps/v1"
"github.com/openshift/origin/pkg/api/legacy"
appsv1helpers "github.com/openshift/origin/pkg/apps/apis/apps/v1"
)
var (
// for decoding, we want to be tolerant of groupified and non-groupified
annotationDecodingScheme = runtime.NewScheme()
annotationDecoder runtime.Decoder
// for encoding, we want to be strict on groupified
annotationEncodingScheme = runtime.NewScheme()
annotationEncoder runtime.Encoder
)
func init() {
legacy.InstallInternalLegacyApps(annotationDecodingScheme)
utilruntime.Must(appsv1helpers.Install(annotationDecodingScheme))
annotationDecoderCodecFactory := serializer.NewCodecFactory(annotationDecodingScheme)
annotationDecoder = annotationDecoderCodecFactory.UniversalDecoder(appsv1.GroupVersion)
utilruntime.Must(appsv1helpers.Install(annotationEncodingScheme))
annotationEncoderCodecFactory := serializer.NewCodecFactory(annotationEncodingScheme)
annotationEncoder = annotationEncoderCodecFactory.LegacyCodec(appsv1.GroupVersion)
}