client: Add functions to handle Metadata and Results requests

Includes basic tests to check for errors, but not content.
This commit is contained in:
Brian C. Lane 2020-05-22 15:55:32 -07:00 committed by Tom Gundersen
parent 6b5ab26072
commit 49ca489efa
2 changed files with 76 additions and 0 deletions

View file

@ -186,3 +186,27 @@ func WriteComposeLogV0(socket *http.Client, w io.Writer, uuid string) (*APIRespo
return nil, err
}
// WriteComposeMetadataV0 requests the metadata for a compose and writes it to an io.Writer
func WriteComposeMetadataV0(socket *http.Client, w io.Writer, uuid string) (*APIResponse, error) {
body, resp, err := GetRawBody(socket, "GET", "/api/v0/compose/metadata/"+uuid)
if resp != nil || err != nil {
return resp, err
}
_, err = io.Copy(w, body)
body.Close()
return nil, err
}
// WriteComposeResultsV0 requests the results for a compose and writes it to an io.Writer
func WriteComposeResultsV0(socket *http.Client, w io.Writer, uuid string) (*APIResponse, error) {
body, resp, err := GetRawBody(socket, "GET", "/api/v0/compose/metadata/"+uuid)
if resp != nil || err != nil {
return resp, err
}
_, err = io.Copy(w, body)
body.Close()
return nil, err
}