rename ImagePushReport to ImagePushStream

The Report will be used in a future change as a new return value for the
internal Push API.

Note: this change is only breaking internal APIs while user-facing
external ones remain unchanges.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2023-04-20 13:29:07 +02:00
parent 85d383bb35
commit 00fdfa0636
3 changed files with 9 additions and 9 deletions

View File

@ -122,18 +122,18 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
enc := json.NewEncoder(w)
enc.SetEscapeHTML(true)
for {
var report entities.ImagePushReport
var stream entities.ImagePushStream
select {
case s := <-writer.Chan():
report.Stream = string(s)
if err := enc.Encode(report); err != nil {
stream.Stream = string(s)
if err := enc.Encode(stream); err != nil {
logrus.Warnf("Failed to encode json: %v", err)
}
flush()
case <-pushCtx.Done():
if pushError != nil {
report.Error = pushError.Error()
if err := enc.Encode(report); err != nil {
stream.Error = pushError.Error()
if err := enc.Encode(stream); err != nil {
logrus.Warnf("Failed to encode json: %v", err)
}
}

View File

@ -69,7 +69,7 @@ func Push(ctx context.Context, source string, destination string, options *PushO
dec := json.NewDecoder(response.Body)
LOOP:
for {
var report entities.ImagePushReport
var report entities.ImagePushStream
if err := dec.Decode(&report); err != nil {
if errors.Is(err, io.EOF) {
break

View File

@ -247,9 +247,9 @@ type ImagePushOptions struct {
OciEncryptLayers *[]int
}
// ImagePushReport is the response from pushing an image.
// Currently only used in the remote API.
type ImagePushReport struct {
// ImagePushStream is the response from pushing an image. Only used in the
// remote API.
type ImagePushStream struct {
// Stream used to provide push progress
Stream string `json:"stream,omitempty"`
// Error contains text of errors from pushing