Example #1
0
File: filter.go Project: pulcy/j2
// createUnitNameFilter creates a predicate that return true if a given
// unit name belongs to the configured job and task-group selection.
func (d *Deployment) createUnitNamePredicate() func(string) bool {
	if d.groupSelection.IncludeAll() {
		// Select everything in the job
		return func(unitName string) bool {
			if !d.scalingGroupSelection.IncludeAll() {
				if !jobs.IsUnitForScalingGroup(unitName, d.job.Name, uint(d.scalingGroupSelection)) {
					return false
				}
			}
			return jobs.IsUnitForJob(unitName, d.job.Name)
		}
	}

	// Select everything in one of the groups
	return func(unitName string) bool {
		if !d.scalingGroupSelection.IncludeAll() {
			if !jobs.IsUnitForScalingGroup(unitName, d.job.Name, uint(d.scalingGroupSelection)) {
				return false
			}
		}
		for _, g := range d.groupSelection {
			if jobs.IsUnitForTaskGroup(unitName, d.job.Name, g) {
				return true
			}
		}
		return false
	}
}
Example #2
0
File: fleet.go Project: pulcy/j2
// excludeUnitsOfJob creates a copy of the given unit names list, excluding those unit names that
// belong to the given job.
func excludeUnitsOfJob(jobName jobs.JobName, unitNames []string) []string {
	result := []string{}
	for _, unitName := range unitNames {
		if !jobs.IsUnitForJob(unitName, jobName) {
			result = append(result, unitName)
		}
	}
	return result
}