get.porter.sh/porter@v1.3.0/pkg/storage/result.go (about) 1 package storage 2 3 import ( 4 "time" 5 6 "get.porter.sh/porter/pkg/cnab" 7 ) 8 9 var _ Document = Result{} 10 11 type Result struct { 12 // SchemaVersion of the document. 13 SchemaVersion cnab.SchemaVersion `json:"schemaVersion"` 14 15 // ID of the result. 16 ID string `json:"_id"` 17 18 // Created timestamp of the result. 19 Created time.Time `json:"created"` 20 21 // Namespace of the installation. 22 Namespace string `json:"namespace"` 23 24 // Installation name that owns this result. 25 Installation string `json:"installation"` 26 27 // RunID of the run that generated this result. 28 RunID string `json:"runId"` 29 30 // Message communicates the outcome of the operation. 31 Message string `json:"message,omitempty"` 32 33 // Status of the operation, for example StatusSucceeded. 34 Status string `json:"status"` 35 36 // OutputMetadata generated by the operation, mapping from the output names to 37 // metadata about the output. 38 OutputMetadata cnab.OutputMetadata `json:"outputs"` 39 40 // Custom extension data applicable to a given runtime. 41 Custom interface{} `json:"custom,omitempty"` 42 } 43 44 func (r Result) DefaultDocumentFilter() map[string]interface{} { 45 return map[string]interface{}{"_id": r.ID} 46 } 47 48 func NewResult() Result { 49 return Result{ 50 SchemaVersion: DefaultInstallationSchemaVersion, 51 ID: cnab.NewULID(), 52 Created: time.Now(), 53 } 54 } 55 56 func (r Result) NewOutput(name string, data []byte) Output { 57 return Output{ 58 SchemaVersion: DefaultInstallationSchemaVersion, 59 Name: name, 60 Namespace: r.Namespace, 61 Installation: r.Installation, 62 RunID: r.RunID, 63 ResultID: r.ID, 64 Value: data, 65 } 66 }