Zack Williams | e940c7a | 2019-08-21 14:25:39 -0700 | [diff] [blame] | 1 | /* |
| 2 | Copyright 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 | |
| 18 | // This file was autogenerated by go-to-protobuf. Do not edit it manually! |
| 19 | |
| 20 | syntax = 'proto2'; |
| 21 | |
| 22 | package k8s.io.apimachinery.pkg.runtime; |
| 23 | |
| 24 | // Package-wide variables from generator "generated". |
| 25 | option go_package = "runtime"; |
| 26 | |
| 27 | // RawExtension is used to hold extensions in external versions. |
David Bainbridge | 8697152 | 2019-09-26 22:09:39 +0000 | [diff] [blame] | 28 | // |
Zack Williams | e940c7a | 2019-08-21 14:25:39 -0700 | [diff] [blame] | 29 | // To use this, make a field which has RawExtension as its type in your external, versioned |
| 30 | // struct, and Object in your internal struct. You also need to register your |
| 31 | // various plugin types. |
David Bainbridge | 8697152 | 2019-09-26 22:09:39 +0000 | [diff] [blame] | 32 | // |
Zack Williams | e940c7a | 2019-08-21 14:25:39 -0700 | [diff] [blame] | 33 | // // Internal package: |
| 34 | // type MyAPIObject struct { |
| 35 | // runtime.TypeMeta `json:",inline"` |
| 36 | // MyPlugin runtime.Object `json:"myPlugin"` |
| 37 | // } |
| 38 | // type PluginA struct { |
| 39 | // AOption string `json:"aOption"` |
| 40 | // } |
David Bainbridge | 8697152 | 2019-09-26 22:09:39 +0000 | [diff] [blame] | 41 | // |
Zack Williams | e940c7a | 2019-08-21 14:25:39 -0700 | [diff] [blame] | 42 | // // External package: |
| 43 | // type MyAPIObject struct { |
| 44 | // runtime.TypeMeta `json:",inline"` |
| 45 | // MyPlugin runtime.RawExtension `json:"myPlugin"` |
| 46 | // } |
| 47 | // type PluginA struct { |
| 48 | // AOption string `json:"aOption"` |
| 49 | // } |
David Bainbridge | 8697152 | 2019-09-26 22:09:39 +0000 | [diff] [blame] | 50 | // |
Zack Williams | e940c7a | 2019-08-21 14:25:39 -0700 | [diff] [blame] | 51 | // // On the wire, the JSON will look something like this: |
| 52 | // { |
| 53 | // "kind":"MyAPIObject", |
| 54 | // "apiVersion":"v1", |
| 55 | // "myPlugin": { |
| 56 | // "kind":"PluginA", |
| 57 | // "aOption":"foo", |
| 58 | // }, |
| 59 | // } |
David Bainbridge | 8697152 | 2019-09-26 22:09:39 +0000 | [diff] [blame] | 60 | // |
Zack Williams | e940c7a | 2019-08-21 14:25:39 -0700 | [diff] [blame] | 61 | // So what happens? Decode first uses json or yaml to unmarshal the serialized data into |
| 62 | // your external MyAPIObject. That causes the raw JSON to be stored, but not unpacked. |
| 63 | // The next step is to copy (using pkg/conversion) into the internal struct. The runtime |
| 64 | // package's DefaultScheme has conversion functions installed which will unpack the |
| 65 | // JSON stored in RawExtension, turning it into the correct object type, and storing it |
| 66 | // in the Object. (TODO: In the case where the object is of an unknown type, a |
| 67 | // runtime.Unknown object will be created and stored.) |
David Bainbridge | 8697152 | 2019-09-26 22:09:39 +0000 | [diff] [blame] | 68 | // |
Zack Williams | e940c7a | 2019-08-21 14:25:39 -0700 | [diff] [blame] | 69 | // +k8s:deepcopy-gen=true |
| 70 | // +protobuf=true |
| 71 | // +k8s:openapi-gen=true |
| 72 | message RawExtension { |
| 73 | // Raw is the underlying serialization of this object. |
David Bainbridge | 8697152 | 2019-09-26 22:09:39 +0000 | [diff] [blame] | 74 | // |
Zack Williams | e940c7a | 2019-08-21 14:25:39 -0700 | [diff] [blame] | 75 | // TODO: Determine how to detect ContentType and ContentEncoding of 'Raw' data. |
| 76 | optional bytes raw = 1; |
| 77 | } |
| 78 | |
| 79 | // TypeMeta is shared by all top level objects. The proper way to use it is to inline it in your type, |
| 80 | // like this: |
| 81 | // type MyAwesomeAPIObject struct { |
| 82 | // runtime.TypeMeta `json:",inline"` |
| 83 | // ... // other fields |
| 84 | // } |
| 85 | // func (obj *MyAwesomeAPIObject) SetGroupVersionKind(gvk *metav1.GroupVersionKind) { metav1.UpdateTypeMeta(obj,gvk) }; GroupVersionKind() *GroupVersionKind |
David Bainbridge | 8697152 | 2019-09-26 22:09:39 +0000 | [diff] [blame] | 86 | // |
Zack Williams | e940c7a | 2019-08-21 14:25:39 -0700 | [diff] [blame] | 87 | // TypeMeta is provided here for convenience. You may use it directly from this package or define |
| 88 | // your own with the same fields. |
David Bainbridge | 8697152 | 2019-09-26 22:09:39 +0000 | [diff] [blame] | 89 | // |
Zack Williams | e940c7a | 2019-08-21 14:25:39 -0700 | [diff] [blame] | 90 | // +k8s:deepcopy-gen=false |
| 91 | // +protobuf=true |
| 92 | // +k8s:openapi-gen=true |
| 93 | message TypeMeta { |
| 94 | // +optional |
| 95 | optional string apiVersion = 1; |
| 96 | |
| 97 | // +optional |
| 98 | optional string kind = 2; |
| 99 | } |
| 100 | |
| 101 | // Unknown allows api objects with unknown types to be passed-through. This can be used |
| 102 | // to deal with the API objects from a plug-in. Unknown objects still have functioning |
| 103 | // TypeMeta features-- kind, version, etc. |
| 104 | // TODO: Make this object have easy access to field based accessors and settors for |
| 105 | // metadata and field mutatation. |
David Bainbridge | 8697152 | 2019-09-26 22:09:39 +0000 | [diff] [blame] | 106 | // |
Zack Williams | e940c7a | 2019-08-21 14:25:39 -0700 | [diff] [blame] | 107 | // +k8s:deepcopy-gen=true |
| 108 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 109 | // +protobuf=true |
| 110 | // +k8s:openapi-gen=true |
| 111 | message Unknown { |
| 112 | optional TypeMeta typeMeta = 1; |
| 113 | |
| 114 | // Raw will hold the complete serialized object which couldn't be matched |
| 115 | // with a registered type. Most likely, nothing should be done with this |
| 116 | // except for passing it through the system. |
| 117 | optional bytes raw = 2; |
| 118 | |
| 119 | // ContentEncoding is encoding used to encode 'Raw' data. |
| 120 | // Unspecified means no encoding. |
| 121 | optional string contentEncoding = 3; |
| 122 | |
| 123 | // ContentType is serialization method used to serialize 'Raw'. |
| 124 | // Unspecified means ContentTypeJSON. |
| 125 | optional string contentType = 4; |
| 126 | } |
| 127 | |