github.com/sleungcy-sap/cli@v7.1.0+incompatible/actor/v7pushaction/resource_match.go (about)

     1  package v7pushaction
     2  
     3  import "code.cloudfoundry.org/cli/actor/sharedaction"
     4  
     5  // MatchResources returns back a list of matched and unmatched resources for the provided resources.
     6  func (actor Actor) MatchResources(resources []sharedaction.V3Resource) ([]sharedaction.V3Resource, []sharedaction.V3Resource, Warnings, error) {
     7  	matches, warnings, err := actor.V7Actor.ResourceMatch(resources)
     8  
     9  	mapChecksumToResource := map[string]sharedaction.V3Resource{}
    10  	for _, resource := range matches {
    11  		mapChecksumToResource[resource.Checksum.Value] = resource
    12  	}
    13  
    14  	var unmatches []sharedaction.V3Resource
    15  	for _, resource := range resources {
    16  		if _, ok := mapChecksumToResource[resource.Checksum.Value]; !ok {
    17  			unmatches = append(unmatches, resource)
    18  		}
    19  	}
    20  
    21  	return matches, unmatches, Warnings(warnings), err
    22  }