Skip to content

Commit

Permalink
remove allElementsExist, use direct count comparison for requireAllDe…
Browse files Browse the repository at this point in the history
…mandsAndIgnoreOthers
  • Loading branch information
Nohac committed Jun 3, 2024
1 parent 80b7e30 commit b3f23ba
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions pkg/scalers/azure_pipelines_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,22 +497,12 @@ func getCanAgentDemandFulfilJob(jr JobRequest, metadata *azurePipelinesMetadata)

if metadata.requireAllDemands {
return countDemands == len(demandsInJob) && countDemands == len(demandsInScaler)
}
if metadata.requireAllDemandsAndIgnoreOthers {
return allElementsExist(demandsInScaler, demandsInJob)
} else if metadata.requireAllDemandsAndIgnoreOthers {
return countDemands == len(demandsInScaler)
}
return countDemands == len(demandsInJob)
}

func allElementsExist(a, b []string) bool {
for _, elem := range a {
if !contains(b, elem) {
return false
}
}
return true
}

// Determine if the Job and Parent Agent Template have matching capabilities
func getCanAgentParentFulfilJob(jr JobRequest, metadata *azurePipelinesMetadata) bool {
matchedAgents := jr.MatchedAgents
Expand Down

0 comments on commit b3f23ba

Please sign in to comment.