mirror of
https://github.com/rancher/steve.git
synced 2025-08-23 08:29:35 +00:00
Fix the sample formatter code.
This commit is contained in:
parent
b3bd0b85d2
commit
18ff2ebb7a
@ -436,14 +436,13 @@ then add the template to the schema factory:
|
|||||||
schemaFactory.AddTemplate(template)
|
schemaFactory.AddTemplate(template)
|
||||||
```
|
```
|
||||||
|
|
||||||
As another example, if you wanted to add custom field to all objects in a
|
As another example, if you wanted to add a custom field to all objects in a
|
||||||
collection response, you can add a schema template with a collection formatter
|
collection response, you can add a schema template with a collection formatter
|
||||||
to omit the ID or the group and kind:
|
to omit the ID or the group and kind:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
template := schema.Template{
|
template := schema.Template{
|
||||||
Customize: func(schema *types.APISchema) {
|
Customize: func(schema *types.APISchema) {
|
||||||
schema.CollectionFormatter = func(apiOp *types.APIRequest, collection *types.GenericCollection) {
|
|
||||||
schema.CollectionFormatter = func(apiOp *types.APIRequest, collection *types.GenericCollection) {
|
schema.CollectionFormatter = func(apiOp *types.APIRequest, collection *types.GenericCollection) {
|
||||||
for _, d := range collection.Data {
|
for _, d := range collection.Data {
|
||||||
obj := d.APIObject.Object.(*unstructured.Unstructured)
|
obj := d.APIObject.Object.(*unstructured.Unstructured)
|
||||||
@ -451,7 +450,6 @@ template := schema.Template{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user