isosegment/classify.go
func classify(desired []cfclient.IsolationSegment, current []cfclient.IsolationSegment) classification {
	currentSegments := make(map[string]*cfclient.IsolationSegment)
	for i := range current {
		currentSegments[current[i].Name] = &current[i]
	}
	desiredSegments := make(map[string]*cfclient.IsolationSegment)
	for i := range desired {
		desiredSegments[desired[i].Name] = &desired[i]
	}

	var missing []cfclient.IsolationSegment
	for name, seg := range desiredSegments {
		if _, ok := currentSegments[name]; !ok {
			missing = append(missing, *seg)
		}
	}

	var extra []cfclient.IsolationSegment
	for name, seg := range currentSegments {
		if _, ok := desiredSegments[name]; !ok {
			extra = append(extra, *seg)
		}
	}

	return classification{missing, extra}
}
func classify(desired []cfclient.IsolationSegment, current []cfclient.IsolationSegment) classification {
	currentSegments := make(map[string]*cfclient.IsolationSegment)
	for i := range current {
		currentSegments[current[i].Name] = &current[i]
	}
	desiredSegments := make(map[string]*cfclient.IsolationSegment)
	for i := range desired {
		desiredSegments[desired[i].Name] = &desired[i]
	}

	var missing []cfclient.IsolationSegment
	for name, seg := range desiredSegments {
		if _, ok := currentSegments[name]; !ok {
			missing = append(missing, *seg)
		}
	}

	var extra []cfclient.IsolationSegment
	for name, seg := range currentSegments {
		if _, ok := desiredSegments[name]; !ok {
			extra = append(extra, *seg)
		}
	}

	return classification{missing, extra}
}
func classify ( desired [ ] cfclient . IsolationSegment , current [ ] cfclient . IsolationSegment ) classification { currentSegments := make ( map [ string ] * cfclient . IsolationSegment ) for i := range current { currentSegments [ current [ i ] . Name ] = & current [ i ] } desiredSegments := make ( map [ string ] * cfclient . IsolationSegment ) for i := range desired { desiredSegments [ desired [ i ] . Name ] = & desired [ i ] } var missing [ ] cfclient . IsolationSegment for name , seg := range desiredSegments { if _ , ok := currentSegments [ name ] ; ! ok { missing = append ( missing , * seg ) } } var extra [ ] cfclient . IsolationSegment for name , seg := range currentSegments { if _ , ok := desiredSegments [ name ] ; ! ok { extra = append ( extra , * seg ) } } return classification { missing , extra } }
// classify accepts a list of segments that should meet some property and a list
// of segments that currently do meet that property, and returns a classification.
classify accepts a list of segments that should meet some property and a list of segments that currently do meet that property and returns a classification .