Retire obsolete collection identity before replacement agreement
This commit is contained in:
@@ -293,14 +293,16 @@ func resolveStrictCollectionPolicies(
|
||||
) (map[string][]string, collectionPolicyScope, []Diagnostic) {
|
||||
paths := make([]Path, 0, len(claims)+len(declarations))
|
||||
seen := make(map[string]bool, len(claims)+len(declarations))
|
||||
sequencePresent := make(map[string]bool)
|
||||
valuePresent := make(map[string]bool)
|
||||
declarationsByPath := make(map[string][]sequenceDeclarationSpec, len(declarations))
|
||||
for _, claim := range claims {
|
||||
if len(lower.collections) != 0 {
|
||||
valuePresent[claim.path.String()] = true
|
||||
}
|
||||
if claim.kind != document.Sequence {
|
||||
continue
|
||||
}
|
||||
key := claim.path.String()
|
||||
sequencePresent[key] = true
|
||||
if !seen[key] {
|
||||
seen[key] = true
|
||||
paths = append(paths, claim.path.clone())
|
||||
@@ -316,7 +318,10 @@ func resolveStrictCollectionPolicies(
|
||||
}
|
||||
|
||||
identityFieldsByPath := make(map[string][]string)
|
||||
effectiveLower := cloneCollectionPolicyScope(lower)
|
||||
effectiveLower := lower
|
||||
if len(lower.collections) != 0 {
|
||||
effectiveLower, _ = lowerCollectionPoliciesForClaims(lower, claims, declarationsByPath, applicationPolicy)
|
||||
}
|
||||
collectionPolicies := cloneCollectionPolicyScope(effectiveLower)
|
||||
var diagnostics []Diagnostic
|
||||
for _, path := range paths {
|
||||
@@ -331,28 +336,6 @@ func resolveStrictCollectionPolicies(
|
||||
}
|
||||
applicationIdentity, _ := applicationPolicy.identityFieldsAt(path)
|
||||
|
||||
// A replacing value drops the old YAML identity before this tier's
|
||||
// peers are checked. The explicit operation itself remains applicable.
|
||||
selectedMode := sequenceMode(0)
|
||||
for _, declaration := range currentDeclarations {
|
||||
if declaration.modePresent {
|
||||
selectedMode = declaration.mode
|
||||
break
|
||||
}
|
||||
}
|
||||
if selectedMode == 0 && lowerPolicy != nil && lowerPolicy.explicitModePresent {
|
||||
selectedMode = lowerPolicy.explicitMode
|
||||
}
|
||||
if sequencePresent[key] && selectedMode == sequenceModeReplace && lowerPolicy != nil {
|
||||
lowerPolicy.identityFields = nil
|
||||
lowerPolicy.identityPresent = false
|
||||
lowerPolicy.identityLocation = nil
|
||||
lowerPolicy.recordOrder = nil
|
||||
lowerPolicy.recordPolicies = nil
|
||||
effectiveLower.retireCollectionPoliciesAtOrBelow(path)
|
||||
collectionPolicies.retireCollectionPoliciesAtOrBelow(path)
|
||||
}
|
||||
|
||||
resolution, found := resolveCollectionPolicy(path, currentDeclarations, applicationIdentity, lowerPolicy)
|
||||
if len(found) != 0 {
|
||||
diagnostics = append(diagnostics, found...)
|
||||
@@ -363,7 +346,7 @@ func resolveStrictCollectionPolicies(
|
||||
}
|
||||
|
||||
policyForPath := resolution.policy
|
||||
if hasLower && !sequencePresent[key] {
|
||||
if hasLower && !valuePresent[key] {
|
||||
// A declaration without a new value changes policy metadata but
|
||||
// leaves retained record ownership untouched.
|
||||
policyForPath = cloneCollectionPolicy(lowerEntry.policy)
|
||||
|
||||
Reference in New Issue
Block a user