github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/buildplanner/response/build.go (about) 1 package response 2 3 import ( 4 "encoding/json" 5 6 "github.com/go-openapi/strfmt" 7 ) 8 9 type ArtifactResponse struct { 10 NodeID strfmt.UUID `json:"nodeId"` 11 Errors []string `json:"errors"` 12 Status string `json:"status"` 13 DisplayName string `json:"displayName"` 14 LogURL string `json:"logURL"` 15 } 16 17 type BuildResponse struct { 18 Type string `json:"__typename"` 19 Artifacts []ArtifactResponse `json:"artifacts"` 20 Status string `json:"status"` 21 *Error 22 *PlanningError 23 RawMessage json.RawMessage 24 } 25 26 // UnmarshalJSON lets us record both the raw json message as well as unmarshal the parts we care about 27 // because without this function only the RawMessage itself would be set, the rest of the field would be empty. 28 // This is effectively working around a silly json library limitation. 29 func (b *BuildResponse) UnmarshalJSON(data []byte) error { 30 type Alias BuildResponse 31 aux := &struct { 32 *Alias 33 }{ 34 Alias: (*Alias)(b), 35 } 36 if err := json.Unmarshal(data, &aux); err != nil { 37 return err 38 } 39 b.RawMessage = data 40 return nil 41 }