Skip to content

Commit 4887961

Browse files
Maintain old API for backwards compatibility. (#1940)
Turns out rules_k8s also depended on the ReadImage function. If anyone else is depending on this, we can maintain backwards compatibility by keeping the same function signature and having it wrap Reader.ReadImage().
1 parent 40cdf2d commit 4887961

4 files changed

Lines changed: 11 additions & 7 deletions

File tree

container/go/cmd/digester/digester.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ func main() {
4949
if err != nil {
5050
log.Fatalf("Unable to determine parts of the image from the specified arguments: %v", err)
5151
}
52-
r := compat.Reader{Parts: imgParts}
53-
img, err := r.ReadImage()
52+
img, err := compat.ReadImage(imgParts)
5453
if err != nil {
5554
log.Fatalf("Error reading image: %v", err)
5655
}

container/go/cmd/flattener/flattener.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ func main() {
5252
if err != nil {
5353
log.Fatalf("Unable to determine parts of the image from the specified arguments: %v", err)
5454
}
55-
r := compat.Reader{Parts: imgParts}
56-
img, err := r.ReadImage()
55+
img, err := compat.ReadImage(imgParts)
5756
if err != nil {
5857
log.Fatalf("Error reading image: %v", err)
5958
}

container/go/cmd/pusher/pusher.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ func main() {
9999
if err != nil {
100100
log.Fatalf("Unable to determine parts of the image from the specified arguments: %v", err)
101101
}
102-
r := compat.Reader{Parts: imgParts}
103-
img, err := r.ReadImage()
102+
img, err := compat.ReadImage(imgParts)
104103
if err != nil {
105104
log.Fatalf("Error reading image: %v", err)
106105
}

container/go/pkg/compat/reader.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func (r *Reader) loadLayers() error {
296296
return nil
297297
}
298298

299-
// ReadImage loads a v1.Image from the given ImageParts
299+
// ReadImage loads a v1.Image from the ImageParts section in the reader.
300300
func (r *Reader) ReadImage() (v1.Image, error) {
301301
// Special case: if we only have a tarball, we can instantiate the image
302302
// directly from that. Otherwise, we'll process the image layers
@@ -343,3 +343,10 @@ func (r *Reader) ReadImage() (v1.Image, error) {
343343
}
344344
return img, nil
345345
}
346+
347+
// ReadImage loads a v1.Image from the given ImageParts
348+
func ReadImage(parts ImageParts) (v1.Image, error) {
349+
r := Reader{Parts: parts}
350+
img, err := r.ReadImage()
351+
return img, err
352+
}

0 commit comments

Comments
 (0)