1
0
mirror of https://github.com/rancher/types.git synced 2025-05-07 22:56:19 +00:00

Mapper for workload annotations

This commit is contained in:
Alena Prokharchyk 2018-03-01 16:56:09 -08:00
parent 773c8f572a
commit ce5bd28bf3
2 changed files with 26 additions and 0 deletions
apis/project.cattle.io/v3/schema
mapper

View File

@ -668,6 +668,7 @@ func NewWorkloadTypeMapper() types.Mapper {
&m.Move{From: "metadata/annotations", To: "annotations", NoDeleteFromField: true},
&m.Drop{Field: "metadata"},
mapper.ContainerPorts{},
mapper.WorkloadAnnotations{},
&m.AnnotationField{Field: "publicEndpoints", List: true},
}
}

25
mapper/workload.go Normal file
View File

@ -0,0 +1,25 @@
package mapper
import (
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/convert"
"github.com/rancher/norman/types/values"
)
type WorkloadAnnotations struct {
}
func (n WorkloadAnnotations) FromInternal(data map[string]interface{}) {
v, ok := values.RemoveValue(data, "workloadAnnotations", "field.cattle.io/publicEndpoints")
if ok {
annotations := convert.ToMapInterface(data["annotations"])
annotations["field.cattle.io/publicEndpoints"] = v
}
}
func (n WorkloadAnnotations) ToInternal(data map[string]interface{}) {
}
func (n WorkloadAnnotations) ModifySchema(schema *types.Schema, schemas *types.Schemas) error {
return nil
}