Skip to content

Commit fd0fb08

Browse files
Improve error message when a release input is invalid
The error message when an image-reference points to a non-existent image can be shortened and made more succinct since it is very common. Clean up the output of new to be easier to scan.
1 parent 0d827d3 commit fd0fb08

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

pkg/oc/cli/admin/release/image_mapper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func NewTransformFromImageStreamFile(path string, input *imageapi.ImageStream, a
131131
continue
132132
}
133133
if len(tag.From.Name) == 0 {
134-
return nil, fmt.Errorf("Image file %q did not specify a valid target location for tag %q - no from.name for the tag", path, tag.Name)
134+
return nil, fmt.Errorf("no from.name for the tag %s", tag.Name)
135135
}
136136
ref := ImageReference{SourceRepository: tag.From.Name}
137137
for _, inputTag := range input.Spec.Tags {
@@ -145,7 +145,7 @@ func NewTransformFromImageStreamFile(path string, input *imageapi.ImageStream, a
145145
klog.V(2).Infof("Image file %q referenced an image %q that is not part of the input images, skipping", path, tag.From.Name)
146146
continue
147147
}
148-
return nil, fmt.Errorf("image file %q referenced image %q that is not part of the input images", path, tag.Name)
148+
return nil, fmt.Errorf("no input image tag named %q", tag.Name)
149149
}
150150
references[tag.Name] = ref
151151
}

pkg/oc/cli/admin/release/new.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ func (o *NewOptions) Run() error {
724724
case len(operators) == 0:
725725
fmt.Fprintf(o.ErrOut, "warning: No operator metadata was found, no operators will be part of the release.\n")
726726
default:
727-
fmt.Fprintf(o.Out, "Built release image from %d operators\n", len(operators))
727+
fmt.Fprintf(o.ErrOut, "info: Built release image from %d operators\n", len(operators))
728728
}
729729

730730
return nil
@@ -871,7 +871,7 @@ func (o *NewOptions) extractManifests(is *imageapi.ImageStream, name string, met
871871
return err
872872
}
873873
o.cleanupFns = append(o.cleanupFns, func() { os.RemoveAll(dir) })
874-
fmt.Fprintf(o.ErrOut, "info: Manifests will be extracted to %s\n", dir)
874+
klog.V(2).Infof("Manifests will be extracted to %s\n", dir)
875875
}
876876

877877
verifier := imagemanifest.NewVerifier()
@@ -959,9 +959,9 @@ func (o *NewOptions) extractManifests(is *imageapi.ImageStream, name string, met
959959
return false, err
960960
}
961961
if custom {
962-
fmt.Fprintf(o.Out, "Loading override manifests from %s: %s ...\n", tag.Name, m.ImageRef.Exact())
962+
fmt.Fprintf(o.ErrOut, "info: Loading override %s %s\n", m.ImageRef.Exact(), tag.Name)
963963
} else {
964-
fmt.Fprintf(o.Out, "Loading manifests from %s: %s ...\n", tag.Name, m.ImageRef.ID)
964+
fmt.Fprintf(o.ErrOut, "info: Loading %s %s\n", m.ImageRef.ID, tag.Name)
965965
}
966966
return true, nil
967967
},
@@ -1291,7 +1291,7 @@ func writePayload(w io.Writer, is *imageapi.ImageStream, cm *CincinnatiMetadata,
12911291
klog.V(2).Infof("Perform image replacement based on inclusion of %s", path)
12921292
transform, err = NewTransformFromImageStreamFile(path, is, allowMissingImages)
12931293
if err != nil {
1294-
return fmt.Errorf("operator %q failed to map images: %s", name, err)
1294+
return fmt.Errorf("operator %q contained an invalid image-references file: %s", name, err)
12951295
}
12961296
}
12971297

@@ -1511,7 +1511,7 @@ func pruneUnreferencedImageStreams(out io.Writer, is *imageapi.ImageStream, meta
15111511
updated = append(updated, tag)
15121512
}
15131513
if len(updated) != len(is.Spec.Tags) {
1514-
fmt.Fprintf(out, "info: Included %d referenced images into the payload\n", len(updated))
1514+
fmt.Fprintf(out, "info: Included %d images in the release\n", len(updated))
15151515
is.Spec.Tags = updated
15161516
}
15171517
return nil

0 commit comments

Comments
 (0)