package selfcompose import ( "context" "strings" ) // KeptBuildOf is the node that keeps the build a module is wanted at, and its fingerprint, for the artifact store's // holder (design 47 G section 271, 526, A-50): the want's `kept-on` and nothing else names it, the builder's builds being // no read of the node-engine's (section 421). kept is false when the module has no want, its want names no keeping node, // or its `parts` do not name the digest ("sha256:" and 64 hex digits, or bare): the artifact is then fetched from the store. func (c *Composer) KeptBuildOf(_ context.Context, module, digest string) (node, fp string, kept bool, err error) { c.mu.Lock() w, ok := c.wants[module] c.mu.Unlock() if !ok || w.Fp == "" || w.KeptOn == "" { return "", "", false, nil } if len(w.Parts) > 0 { named := false for _, d := range w.Parts { if strings.TrimPrefix(d, "sha256:") == strings.TrimPrefix(digest, "sha256:") { named = true } } if !named { return "", "", false, nil } } return w.KeptOn, w.Fp, true, nil }