Judge a revision that changes only the bus's user list as no move, and say so beside it (issue 1945; the review's A2)
The user list is a file in a directory the bus's container mounts, so it read as moving data and held every new credential for a person's yes, against ADR 0539 clause 7; mesh-sdk's UserListOnly lets the assigner write such a revision at once.
This commit is contained in:
@@ -67,10 +67,45 @@ func judgeMove(ctx context.Context, at composedPlace, key string, to sdkdelivery
|
||||
out.Words = fmt.Sprintf("the composition %s runs on %s (%s) is gone", to.Module, at.node, short(strings.TrimPrefix(have.Composed, "sha256:")))
|
||||
return out, nil
|
||||
}
|
||||
if onlyTheUserList(from, to) {
|
||||
// Only the bus's user list (ADR 0539 clause 7): a file change and a reload of the bus, no move of it, written
|
||||
// into its want at once.
|
||||
out.Judgement, out.UserListOnly, out.Words = sdkdelivery.JudgedNeither, true, "only the bus's user list changes"
|
||||
return out, nil
|
||||
}
|
||||
out.Judgement, out.Words = judged(from, to)
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// busUsersSuffix ends the id of the bus module's user list as the composer writes it: `<module>.bus-users`.
|
||||
const busUsersSuffix = ".bus-users"
|
||||
|
||||
// onlyTheUserList says two compositions of a module differ, and only in its file of the bus's user list.
|
||||
func onlyTheUserList(from, to sdkdelivery.Composed) bool {
|
||||
if from.Data != to.Data {
|
||||
return false
|
||||
}
|
||||
before, after := resourcesByID(from), resourcesByID(to)
|
||||
if len(before) != len(after) {
|
||||
return false
|
||||
}
|
||||
changed := false
|
||||
for id, now := range after {
|
||||
was, ok := before[id]
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
if bytes.Equal(was.raw, now.raw) {
|
||||
continue
|
||||
}
|
||||
if !strings.HasSuffix(id, busUsersSuffix) || now.kind != string(sdkdecl.TypeFile) {
|
||||
return false
|
||||
}
|
||||
changed = true
|
||||
}
|
||||
return changed
|
||||
}
|
||||
|
||||
// composedByDigest finds, in the node's bucket, the composition of module at fingerprint fp whose digest is digest: the
|
||||
// key's current value or one of the revisions it keeps.
|
||||
func composedByDigest(ctx context.Context, at composedPlace, module, fp, digest string) (sdkdelivery.Composed, bool, error) {
|
||||
|
||||
Reference in New Issue
Block a user