You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -94,79 +94,72 @@ API 服务器将无法成功验证所有尝试改变 data 字段的请求。
94
94
<a name="RawExtension"></a>
95
95
*RawExtension is used to hold extensions in external versions.
96
96
-->
97
+
97
98
<aname="RawExtension"></a>
98
99
**RawExtension 用于以外部版本来保存扩展数据。**
99
100
100
101
<!--
101
102
To use this, make a field which has RawExtension as its type in your external, versioned struct, and Object in your internal struct. You also need to register your various plugin types.
// On the wire, the JSON will look something like this: {
147
-
"kind":"MyAPIObject",
148
-
"apiVersion":"v1",
149
-
"myPlugin": {
150
-
"kind":"PluginA",
151
-
"aOption":"foo",
152
-
},
126
+
// External package:
127
+
-->
128
+
129
+
// 外部包:
130
+
131
+
```go
132
+
type MyAPIObject struct {
133
+
runtime.TypeMeta `json:",inline"`
134
+
MyPlugin runtime.RawExtension `json:"myPlugin"`
135
+
}
136
+
137
+
type PluginA struct {
138
+
AOption string `json:"aOption"`
153
139
}
140
+
```
141
+
142
+
<!--
143
+
// On the wire, the JSON will look something like this:
154
144
-->
155
-
在网络上,JSON 看起来像这样:
156
-
```json
157
-
{
158
-
"kind":"MyAPIObject",
159
-
"apiVersion":"v1",
160
-
"myPlugin": {
161
-
"kind":"PluginA",
162
-
"aOption":"foo",
163
-
},
164
-
}
165
-
```
145
+
146
+
// 在网络上,JSON 看起来像这样:
147
+
148
+
```json
149
+
{
150
+
"kind":"MyAPIObject",
151
+
"apiVersion":"v1",
152
+
"myPlugin": {
153
+
"kind":"PluginA",
154
+
"aOption":"foo",
155
+
},
156
+
}
157
+
```
166
158
167
159
<!--
168
160
So what happens? Decode first uses json or yaml to unmarshal the serialized data into your external MyAPIObject. That causes the raw JSON to be stored, but not unpacked. The next step is to copy (using pkg/conversion) into the internal struct. The runtime package's DefaultScheme has conversion functions installed which will unpack the JSON stored in RawExtension, turning it into the correct object type, and storing it in the Object. (TODO: In the case where the object is of an unknown type, a runtime.Unknown object will be created and stored.)*
169
161
-->
162
+
170
163
那么会发生什么?
171
164
解码首先使用 json 或 yaml 将序列化数据解组到你的外部 MyAPIObject 中。
172
165
这会导致原始 JSON 被存储下来,但不会被解包。
@@ -275,14 +268,12 @@ GET /apis/apps/v1/namespaces/{namespace}/controllerrevisions/{name}
275
268
<!--
276
269
#### Response
277
270
278
-
279
271
200 (<a href="{{< ref "../workload-resources/controller-revision-v1#ControllerRevision" >}}">ControllerRevision</a>): OK
280
272
281
273
401: Unauthorized
282
274
-->
283
275
#### 响应
284
276
285
-
286
277
200 (<a href="{{< ref "../workload-resources/controller-revision-v1#ControllerRevision" >}}">ControllerRevision</a>): OK
287
278
288
279
401: Unauthorized
@@ -530,7 +521,6 @@ GET /apis/apps/v1/controllerrevisions
530
521
<!--
531
522
#### Response
532
523
533
-
534
524
200 (<a href="{{< ref "../workload-resources/controller-revision-v1#ControllerRevisionList" >}}">ControllerRevisionList</a>): OK
0 commit comments