package steprun import ( "fmt" "git.novox.be/novox/mesh-sdk/go/buscalls" ) // OutputsStore is the local name of the object store a build seat's holder keeps a run's answer in when it is over what // step-ended carries inline (design 47 G A-254), as the holder's manifest `requires` asks for it with the template objects. const OutputsStore = "outputs" // OutputObjects is the object store of OutputsStore as a holder uses it (mesh-sdk busstate.ObjectsOf(OutputsStore)). type OutputObjects interface { Put(name string, data []byte, description string) (buscalls.ObjectInfo, error) Get(name string) (buscalls.ObjectData, error) } // KeepOutputIn is a holder's Puller.KeepOutput over its store of outputs. func KeepOutputIn(o OutputObjects) func(object string, body []byte) error { return func(object string, body []byte) error { if o == nil { return fmt.Errorf("this module keeps no %s store", OutputsStore) } _, err := o.Put(object, body, "a run's answer, named by its step-ended") return err } } // ReadOutputFrom is a holder's read of a kept answer for OutputTool over its store of outputs. func ReadOutputFrom(o OutputObjects) func(object string) ([]byte, error) { return func(object string) ([]byte, error) { if o == nil { return nil, fmt.Errorf("this module keeps no %s store", OutputsStore) } got, err := o.Get(object) if err != nil { return nil, fmt.Errorf("the answer %s in the %s store: %w", object, OutputsStore, err) } return got.Data, nil } }