Skip to content

Commit

Permalink
Maintain old API for backwards compatibility. (#1940)
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
aptenodytes-forsteri authored Nov 10, 2021
1 parent 40cdf2d commit 4887961
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
3 changes: 1 addition & 2 deletions container/go/cmd/digester/digester.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ func main() {
if err != nil {
log.Fatalf("Unable to determine parts of the image from the specified arguments: %v", err)
}
r := compat.Reader{Parts: imgParts}
img, err := r.ReadImage()
img, err := compat.ReadImage(imgParts)
if err != nil {
log.Fatalf("Error reading image: %v", err)
}
Expand Down
3 changes: 1 addition & 2 deletions container/go/cmd/flattener/flattener.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ func main() {
if err != nil {
log.Fatalf("Unable to determine parts of the image from the specified arguments: %v", err)
}
r := compat.Reader{Parts: imgParts}
img, err := r.ReadImage()
img, err := compat.ReadImage(imgParts)
if err != nil {
log.Fatalf("Error reading image: %v", err)
}
Expand Down
3 changes: 1 addition & 2 deletions container/go/cmd/pusher/pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ func main() {
if err != nil {
log.Fatalf("Unable to determine parts of the image from the specified arguments: %v", err)
}
r := compat.Reader{Parts: imgParts}
img, err := r.ReadImage()
img, err := compat.ReadImage(imgParts)
if err != nil {
log.Fatalf("Error reading image: %v", err)
}
Expand Down
9 changes: 8 additions & 1 deletion container/go/pkg/compat/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func (r *Reader) loadLayers() error {
return nil
}

// ReadImage loads a v1.Image from the given ImageParts
// ReadImage loads a v1.Image from the ImageParts section in the reader.
func (r *Reader) ReadImage() (v1.Image, error) {
// Special case: if we only have a tarball, we can instantiate the image
// directly from that. Otherwise, we'll process the image layers
Expand Down Expand Up @@ -343,3 +343,10 @@ func (r *Reader) ReadImage() (v1.Image, error) {
}
return img, nil
}

// ReadImage loads a v1.Image from the given ImageParts
func ReadImage(parts ImageParts) (v1.Image, error) {
r := Reader{Parts: parts}
img, err := r.ReadImage()
return img, err
}

0 comments on commit 4887961

Please sign in to comment.