forked from openshift/library-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scheme.go
30 lines (24 loc) · 1.07 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
package appsserialization
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"
)
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() {
utilruntime.Must(appsv1.Install(annotationDecodingScheme))
utilruntime.Must(appsv1.DeprecatedInstallWithoutGroup(annotationDecodingScheme))
annotationDecoderCodecFactory := serializer.NewCodecFactory(annotationDecodingScheme)
annotationDecoder = annotationDecoderCodecFactory.UniversalDecoder(appsv1.GroupVersion)
utilruntime.Must(appsv1.Install(annotationEncodingScheme))
annotationEncoderCodecFactory := serializer.NewCodecFactory(annotationEncodingScheme)
annotationEncoder = annotationEncoderCodecFactory.LegacyCodec(appsv1.GroupVersion)
}