github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/core/resources/serialization.go (about) 1 // Copyright 2016 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package resources 5 6 import ( 7 "github.com/juju/charm/v12/resource" 8 "github.com/juju/errors" 9 ) 10 11 // DeserializeFingerprint converts the serialized fingerprint back into 12 // a Fingerprint. "zero" values are treated appropriately. 13 func DeserializeFingerprint(fpSum []byte) (resource.Fingerprint, error) { 14 var fp resource.Fingerprint 15 if len(fpSum) != 0 { 16 var err error 17 fp, err = resource.NewFingerprint(fpSum) 18 if err != nil { 19 return fp, errors.Trace(err) 20 } 21 } 22 return fp, nil 23 }