H2 composition-diff: the node-engine seat's read verb composition-diff
The node-engine serves seat verbs and has no tools bundle, so the composed values read by resource are a read verb beside composition: given a module and a revision or digest, the entries that differ between the running composition and the other, per resource, environment entries by name, a secret masked. Packages generated again by seatgen (seatgen -check clean). Builds: design 47 H2 §813 (3); H-A-349 DQ-12b
This commit is contained in:
@@ -23,6 +23,7 @@ const (
|
||||
VerbActs = "acts"
|
||||
VerbPackages = "packages"
|
||||
VerbComposition = "composition"
|
||||
VerbCompositionDiff = "composition-diff"
|
||||
VerbCompose = "compose"
|
||||
VerbComposeCandidate = "compose-candidate"
|
||||
VerbManifestReads = "manifest-reads"
|
||||
@@ -49,7 +50,7 @@ const (
|
||||
|
||||
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
||||
func Verbs() []string {
|
||||
return []string{VerbHandOver, VerbAccessAct, VerbJudgeDirectories, VerbSetuidSearch, VerbRootFree, VerbActs, VerbPackages, VerbComposition, VerbCompose, VerbComposeCandidate, VerbManifestReads, VerbApplyOrder, VerbSeatList, VerbSeatListAgain, VerbFirstViews, VerbFirstViewAgain, VerbEntryAgain, VerbProcessBuilds, VerbConverged}
|
||||
return []string{VerbHandOver, VerbAccessAct, VerbJudgeDirectories, VerbSetuidSearch, VerbRootFree, VerbActs, VerbPackages, VerbComposition, VerbCompositionDiff, VerbCompose, VerbComposeCandidate, VerbManifestReads, VerbApplyOrder, VerbSeatList, VerbSeatListAgain, VerbFirstViews, VerbFirstViewAgain, VerbEntryAgain, VerbProcessBuilds, VerbConverged}
|
||||
}
|
||||
|
||||
// Events is every event published on the seat's subject: a new copy each call.
|
||||
@@ -625,6 +626,26 @@ type Composed struct {
|
||||
V int64 `json:"v"`
|
||||
}
|
||||
|
||||
// CompositionDiffEntry is one entry that differs between the running composition and the other.
|
||||
type CompositionDiffEntry struct {
|
||||
// the value is a secret, so neither value is given
|
||||
Masked bool `json:"masked,omitempty"`
|
||||
// the entry: an environment entry by its name, else the part of the resource that differs
|
||||
Name string `json:"name"`
|
||||
// its value in the other composition; absent where the other lacks it or the value is a secret
|
||||
Other string `json:"other,omitempty"`
|
||||
// its value in the running composition; absent where the running one lacks it or the value is a secret
|
||||
Running string `json:"running,omitempty"`
|
||||
}
|
||||
|
||||
// CompositionDiffResource is one resource with the entries of it that differ.
|
||||
type CompositionDiffResource struct {
|
||||
// the entries of the resource that differ
|
||||
Entries []CompositionDiffEntry `json:"entries"`
|
||||
// the resource, as the composition names it
|
||||
Resource string `json:"resource"`
|
||||
}
|
||||
|
||||
// DeclaredGroup is a group.
|
||||
type DeclaredGroup struct {
|
||||
Gid int64 `json:"gid"`
|
||||
@@ -1338,6 +1359,29 @@ type CompositionAnswer struct {
|
||||
WithheldUnknown string `json:"withheld-unknown,omitempty"`
|
||||
}
|
||||
|
||||
// CompositionDiffInput is what composition-diff takes.
|
||||
type CompositionDiffInput struct {
|
||||
// the digest (sha256:…) of the composition to compare with; give it or revision
|
||||
Digest string `json:"digest,omitempty"`
|
||||
// the module, as placed on this machine; node for the node's own
|
||||
Module string `json:"module"`
|
||||
// the revision of the module's composition key to compare with, from the revisions the bucket keeps; give it or digest
|
||||
Revision int64 `json:"revision,omitempty"`
|
||||
}
|
||||
|
||||
// CompositionDiffAnswer is what composition-diff answers.
|
||||
type CompositionDiffAnswer struct {
|
||||
// the module
|
||||
Module string `json:"module"`
|
||||
// the node
|
||||
Node string `json:"node"`
|
||||
Other *Revision `json:"other,omitempty"`
|
||||
// each resource with an entry that differs; empty when none differs
|
||||
Resources []CompositionDiffResource `json:"resources"`
|
||||
// the digest of the composition that runs; absent when nothing runs
|
||||
Running string `json:"running,omitempty"`
|
||||
}
|
||||
|
||||
// ComposeInput is what compose takes.
|
||||
type ComposeInput struct {
|
||||
// a module placed on this machine whose apply is also tried again (optional)
|
||||
|
||||
@@ -135,6 +135,12 @@ func TestFixtures(t *testing.T) {
|
||||
decode: func(b []byte) (any, error) { var v ConvergedAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "composition names the filter part kept because allowed did not answer", subject: "", given: "{\"composition\":{\"key\":\"\"},\"judged\":{\"judgement\":\"\",\"waits_for_yes\":false,\"words\":\"\"},\"module\":\"nftables\",\"node\":\"desk\",\"started\":true,\"withheld-parts\":[{\"part\":\"node-packet-filter.allowed\",\"why\":\"asked of the seat node-packet-filter's verb allowed on desk, which did not answer within 10s\"}]}", wire: "{\"composition\":{\"key\":\"\"},\"judged\":{\"judgement\":\"\",\"waits_for_yes\":false,\"words\":\"\"},\"module\":\"nftables\",\"node\":\"desk\",\"started\":true,\"withheld-parts\":[{\"part\":\"node-packet-filter.allowed\",\"why\":\"asked of the seat node-packet-filter's verb allowed on desk, which did not answer within 10s\"}]}",
|
||||
decode: func(b []byte) (any, error) { var v CompositionAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "composition-diff asks a module against a digest", subject: "", given: "{\"digest\":\"sha256:aa\",\"module\":\"plex\"}", wire: "{\"digest\":\"sha256:aa\",\"module\":\"plex\"}",
|
||||
decode: func(b []byte) (any, error) { var v CompositionDiffInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "composition-diff answers the entries that differ per resource, a secret masked", subject: "", given: "{\"module\":\"plex\",\"node\":\"ace\",\"other\":{\"digest\":\"sha256:aa\",\"key\":\"plex\",\"revision\":12},\"resources\":[{\"entries\":[{\"name\":\"PLEX_LOG_LEVEL\",\"other\":\"debug\",\"running\":\"info\"},{\"masked\":true,\"name\":\"PLEX_TOKEN\"}],\"resource\":\"service:plex\"}],\"running\":\"sha256:bb\"}", wire: "{\"module\":\"plex\",\"node\":\"ace\",\"other\":{\"digest\":\"sha256:aa\",\"key\":\"plex\",\"revision\":12},\"resources\":[{\"entries\":[{\"name\":\"PLEX_LOG_LEVEL\",\"other\":\"debug\",\"running\":\"info\"},{\"masked\":true,\"name\":\"PLEX_TOKEN\"}],\"resource\":\"service:plex\"}],\"running\":\"sha256:bb\"}",
|
||||
decode: func(b []byte) (any, error) { var v CompositionDiffAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "composition-diff answers no resource when none differs", subject: "", given: "{\"module\":\"plex\",\"node\":\"ace\",\"resources\":[],\"running\":\"sha256:aa\"}", wire: "{\"module\":\"plex\",\"node\":\"ace\",\"resources\":[],\"running\":\"sha256:aa\"}",
|
||||
decode: func(b []byte) (any, error) { var v CompositionDiffAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
}
|
||||
for _, c := range cases {
|
||||
v, err := c.decode([]byte(c.given))
|
||||
|
||||
Reference in New Issue
Block a user