package apply import "context" // The build the artifact store's holder keeps on a build node (novox/hq design 47, *The artifact store's holder takes its // own new build even when its seat is the one broken*): the holder's program cannot be fetched from the store it serves, so // its done build names the node that keeps it and the node-engine fetches it from there, through the build seat's verb. // How is the caller's (a hook on the apply's context, as the files' link is); what apply does is use the bytes in place of // the source's fetch, check them against the declared digest as every fetch is, and gate the module when they cannot be had. // KeptFetch gives the bytes of the artifact a module's done build kept on a build node, by the artifact's digest // ("sha256:" and 64 hex digits, as a declaration names it). kept is false when the module's build kept no such artifact: // the artifact is then fetched from its source, as before. An error says the artifact is kept and could not be had. type KeptFetch func(ctx context.Context, module, digest string) (body []byte, kept bool, err error) type keptFetchKey struct{} // WithKept is ctx carrying how a kept artifact is fetched. func WithKept(ctx context.Context, f KeptFetch) context.Context { if f == nil { return ctx } return context.WithValue(ctx, keptFetchKey{}, f) } func keptFetchFrom(ctx context.Context) KeptFetch { f, _ := ctx.Value(keptFetchKey{}).(KeptFetch) return f }