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 := json.NewEncoder(w)
enc.SetEscapeHTML(true) enc.SetEscapeHTML(true)
for { for {
var report entities.ImagePushReport var stream entities.ImagePushStream
select { select {
case s := <-writer.Chan(): case s := <-writer.Chan():
report.Stream = string(s) stream.Stream = string(s)
if err := enc.Encode(report); err != nil { if err := enc.Encode(stream); err != nil {
logrus.Warnf("Failed to encode json: %v", err) logrus.Warnf("Failed to encode json: %v", err)
} }
flush() flush()
case <-pushCtx.Done(): case <-pushCtx.Done():
if pushError != nil { if pushError != nil {
report.Error = pushError.Error() stream.Error = pushError.Error()
if err := enc.Encode(report); err != nil { if err := enc.Encode(stream); err != nil {
logrus.Warnf("Failed to encode json: %v", err) 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) dec := json.NewDecoder(response.Body)
LOOP: LOOP:
for { for {
var report entities.ImagePushReport var report entities.ImagePushStream
if err := dec.Decode(&report); err != nil { if err := dec.Decode(&report); err != nil {
if errors.Is(err, io.EOF) { if errors.Is(err, io.EOF) {
break break

View File

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