func API2Resource(apiInfo Resource) (resource.Resource, error) {
	var res resource.Resource

	rtype, err := resource.ParseType(apiInfo.Type)
	if err != nil {
		return res, errgo.Mask(err, errgo.Any)
	}

	fp, err := deserializeFingerprint(apiInfo.Fingerprint)
	if err != nil {
		return res, errgo.Mask(err, errgo.Any)
	}

	// Charmstore doesn't set Origin, so we just default it to OriginStore.

	res = resource.Resource{
		Meta: resource.Meta{
			Name:        apiInfo.Name,
			Type:        rtype,
			Path:        apiInfo.Path,
			Description: apiInfo.Description,
		},
		Origin:      resource.OriginStore,
		Revision:    apiInfo.Revision,
		Fingerprint: fp,
		Size:        apiInfo.Size,
	}

	if err := res.Validate(); err != nil {
		return res, errgo.Mask(err, errgo.Any)
	}
	return res, nil
}
// API2Resource converts an API Resource struct into
// a charm resource.
API2Resource converts an API Resource struct into
a charm resource.
// API2Resource converts an API Resource struct into // a charm resource .
func API2Resource(apiInfo Resource) (resource.Resource, error) {
	var res resource.Resource
	rtype, err := resource.ParseType(apiInfo.Type)
	if err != nil {
		return res, errgo.Mask(err, errgo.Any)
	}
	fp, err := deserializeFingerprint(apiInfo.Fingerprint)
	if err != nil {
		return res, errgo.Mask(err, errgo.Any)
	}
	res = resource.Resource{
		Meta: resource.Meta{
			Name:        apiInfo.Name,
			Type:        rtype,
			Path:        apiInfo.Path,
			Description: apiInfo.Description,
		},
		Origin:      resource.OriginStore,
		Revision:    apiInfo.Revision,
		Fingerprint: fp,
		Size:        apiInfo.Size,
	}
	if err := res.Validate(); err != nil {
		return res, errgo.Mask(err, errgo.Any)
	}
	return res, nil
}
func API2Resource ( apiInfo Resource ) ( resource . Resource , error ) { var res resource . Resource rtype , err := resource . ParseType ( apiInfo . Type ) if err != nil { return res , errgo . Mask ( err , errgo . Any ) } fp , err := deserializeFingerprint ( apiInfo . Fingerprint ) if err != nil { return res , errgo . Mask ( err , errgo . Any ) } res = resource . Resource { Meta : resource . Meta { Name : apiInfo . Name , Type : rtype , Path : apiInfo . Path , Description : apiInfo . Description , } , Origin : resource . OriginStore , Revision : apiInfo . Revision , Fingerprint : fp , Size : apiInfo . Size , } if err := res . Validate ( ) ; err != nil { return res , errgo . Mask ( err , errgo . Any ) } return res , nil }
API2Resource converts an API Resource struct into
a charm resource.
API2Resource converts an API Resource struct into a charm resource .
// Charmstore doesn't set Origin, so we just default it to OriginStore.