diff --git a/apis/project.cattle.io/v3/schema/schema.go b/apis/project.cattle.io/v3/schema/schema.go index 01399e01..fd087452 100644 --- a/apis/project.cattle.io/v3/schema/schema.go +++ b/apis/project.cattle.io/v3/schema/schema.go @@ -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}, } } diff --git a/mapper/workload.go b/mapper/workload.go new file mode 100644 index 00000000..ecf69eee --- /dev/null +++ b/mapper/workload.go @@ -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 +}