diff --git a/apis/project.cattle.io/v3/schema/schema.go b/apis/project.cattle.io/v3/schema/schema.go index 303af498..d2f59f18 100644 --- a/apis/project.cattle.io/v3/schema/schema.go +++ b/apis/project.cattle.io/v3/schema/schema.go @@ -669,6 +669,9 @@ func volumeTypes(schemas *types.Schemas) *types.Schemas { "name", }}, ). + AddMapperForType(&Version, v1.PersistentVolumeClaim{}, + mapper.PersistVolumeClaim{}, + ). MustImport(&Version, v1.PersistentVolumeClaimVolumeSource{}, struct { ClaimName string `norman:"type=reference[persistentVolumeClaim]"` }{}). diff --git a/mapper/persistvolumeclaim.go b/mapper/persistvolumeclaim.go new file mode 100644 index 00000000..1e4f2d15 --- /dev/null +++ b/mapper/persistvolumeclaim.go @@ -0,0 +1,22 @@ +package mapper + +import ( + "github.com/rancher/norman/types" + "github.com/rancher/norman/types/values" +) + +type PersistVolumeClaim struct { +} + +func (p PersistVolumeClaim) FromInternal(data map[string]interface{}) { +} + +func (p PersistVolumeClaim) ToInternal(data map[string]interface{}) { + if v, ok := values.GetValue(data, "storageClassId"); ok && v == nil { + values.PutValue(data, "", "storageClassId") + } +} + +func (p PersistVolumeClaim) ModifySchema(schema *types.Schema, schemas *types.Schemas) error { + return nil +}