Remove BPA from Makefile
[icn.git] / cmd / bpa-operator / vendor / k8s.io / apimachinery / pkg / runtime / serializer / protobuf_extension.go
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 serializer
18
19 import (
20         "k8s.io/apimachinery/pkg/runtime"
21         "k8s.io/apimachinery/pkg/runtime/serializer/protobuf"
22 )
23
24 const (
25         // contentTypeProtobuf is the protobuf type exposed for Kubernetes. It is private to prevent others from
26         // depending on it unintentionally.
27         // TODO: potentially move to pkg/api (since it's part of the Kube public API) and pass it in to the
28         //   CodecFactory on initialization.
29         contentTypeProtobuf = "application/vnd.kubernetes.protobuf"
30 )
31
32 func protobufSerializer(scheme *runtime.Scheme) (serializerType, bool) {
33         serializer := protobuf.NewSerializer(scheme, scheme, contentTypeProtobuf)
34         raw := protobuf.NewRawSerializer(scheme, scheme, contentTypeProtobuf)
35         return serializerType{
36                 AcceptContentTypes: []string{contentTypeProtobuf},
37                 ContentType:        contentTypeProtobuf,
38                 FileExtensions:     []string{"pb"},
39                 Serializer:         serializer,
40
41                 Framer:           protobuf.LengthDelimitedFramer,
42                 StreamSerializer: raw,
43         }, true
44 }
45
46 func init() {
47         serializerExtensions = append(serializerExtensions, protobufSerializer)
48 }