func GetShareAceAdjustments()

in src/terraform/providers/terraform-provider-avere/cifs.go [355:396]


func GetShareAceAdjustments(existingShareAces map[string]*ShareAce, targetShareAces map[string]*ShareAce) ([]*ShareAce, []*ShareAce) {
	shareAcesToDelete := make([]*ShareAce, 0, len(existingShareAces))
	shareAcesToCreate := make([]*ShareAce, 0, len(targetShareAces))

	normalizedTargetShareAces := NormalizeShareAces(targetShareAces)
	for k, v := range existingShareAces {
		var ace *ShareAce
		var ok bool
		if ace, ok = normalizedTargetShareAces[k]; !ok {
			// try to remove the domain
			key2 := removeDomain(k)
			if ace, ok = normalizedTargetShareAces[key2]; !ok {
				ace = nil
			}
			// try to use the sid as a key
			key3 := v.Sid
			if ace, ok = normalizedTargetShareAces[key3]; !ok {
				ace = nil
			}
		}
		if ace == nil || !(ace.Type == v.Type && ace.Permission == v.Permission) {
			shareAcesToDelete = append(shareAcesToDelete, v)
		}
	}

	normalizedExistingShareAces := NormalizeShareAces(existingShareAces)
	for k, v := range targetShareAces {
		var ace *ShareAce
		var ok bool
		if ace, ok = normalizedExistingShareAces[k]; !ok {
			key2 := removeDomain(k)
			if ace, ok = normalizedExistingShareAces[key2]; ok {
				ace = nil
			}
		}
		if ace == nil || !(ace.Type == v.Type && ace.Permission == v.Permission) {
			shareAcesToCreate = append(shareAcesToCreate, v)
		}
	}

	return shareAcesToDelete, shareAcesToCreate
}