MCPcopy Create free account
hub / github.com/deepflowio/deepflow / getContentFromAdditionalResource

Function getContentFromAdditionalResource

server/controller/cloud/cloud.go:601–619  ·  view source on GitHub ↗

getContentFromAdditionalResource gets domain_additional_resource by uuid, get the field content if it exists, otherwise get the field compressed_content. old content field: content new centent field: compressed_content

(domainUUID string, db *gorm.DB)

Source from the content-addressed store, hash-verified

599// old content field: content
600// new centent field: compressed_content
601func getContentFromAdditionalResource(domainUUID string, db *gorm.DB) (*metadbmodel.DomainAdditionalResource, error) {
602 var dbItems []metadbmodel.DomainAdditionalResource
603 result := db.Select("content").Where(map[string]interface{}{"domain": domainUUID}).Where("content != ''").Find(&dbItems)
604 if result.Error != nil {
605 return nil, result.Error
606 }
607
608 if result.RowsAffected == 0 {
609 result = db.Select("compressed_content").Where(map[string]interface{}{"domain": domainUUID}).Find(&dbItems)
610 if result.Error != nil {
611 return nil, result.Error
612 }
613 if result.RowsAffected == 0 {
614 return nil, nil
615 }
616 }
617
618 return &dbItems[0], nil
619}
620
621func (c *Cloud) appendCloudTags(resource model.Resource, additionalResource model.AdditionalResource) model.Resource {
622 chostCloudTags := additionalResource.CHostCloudTags

Callers 1

Calls 1

SelectMethod · 0.45

Tested by

no test coverage detected