diff --git a/models/meshmodel/core/v1alpha1/component_capabilities_db.go b/models/meshmodel/core/v1alpha1/component_capabilities_db.go index b00f8683..fb407cd6 100644 --- a/models/meshmodel/core/v1alpha1/component_capabilities_db.go +++ b/models/meshmodel/core/v1alpha1/component_capabilities_db.go @@ -25,18 +25,23 @@ type ComponentCapabilityDB struct { Capability } +// ComponentCapabilityFromCCDB produces a client facing instance of ComponentCapability from a database representation of ComponentCapability. +// Use this function to interconvert any time the ComponentCapability is fetched from the database and is to be returned to client. func ComponentCapabilityFromCCDB(cdb ComponentCapabilityDB) (c ComponentCapability) { c.Capability = cdb.Capability c.TypeMeta = cdb.TypeMeta c.Spec = cdb.Spec m := make(map[string]interface{}) - json.Unmarshal(cdb.Metadata, &m) + _ = json.Unmarshal(cdb.Metadata, &m) c.Metadata = m schematic := make(map[string]interface{}) - json.Unmarshal(cdb.Schematic, &schematic) + _ = json.Unmarshal(cdb.Schematic, &schematic) c.Schematic = schematic return } + +// ComponentCapabilityDBFromCC produces a database compatible instance of ComponentCapability from a client representation of ComponentCapability. +// Use this function to interconvert any time the ComponentCapability is created by some client and is to be saved to the database. func ComponentCapabilityDBFromCC(c ComponentCapability) (cdb ComponentCapabilityDB) { cdb.Capability = c.Capability cdb.TypeMeta = c.TypeMeta