Skip to content

Commit

Permalink
Update go-containerregistry that reverts API breaking change (#1137)
Browse files Browse the repository at this point in the history
* Update go-containerregistry that reverts API breaking change

* Change function name
  • Loading branch information
smukherj1 authored Sep 9, 2019
1 parent 8f0b744 commit c3f19ac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions container/go/cmd/join_layers/join_layers.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ var (
stampInfoFiles utils.ArrayStringFlags
)

// parseRefToFilename converts a list of key=value where 'key' is the name of
// parseTagToFilename converts a list of key=value where 'key' is the name of
// the tagged image and 'value' is the path to a file into a map from key to
// value.
func parseRefToFilename(tags []string, stamper *compat.Stamper) (map[name.Reference]string, error) {
result := make(map[name.Reference]string)
func parseTagToFilename(tags []string, stamper *compat.Stamper) (map[name.Tag]string, error) {
result := make(map[name.Tag]string)
for _, t := range tags {
split := strings.Split(t, "=")
if len(split) != 2 {
return nil, errors.Errorf("%q was not specified in the expected key=value format because it split into %q with unexpected number of elements by '=', got %d, want 2", t, split, len(split))
}
img, configFile := split[0], split[1]
stamped := stamper.Stamp(img)
r, err := name.ParseReference(stamped, name.WeakValidation)
t, err := name.NewTag(stamped, name.WeakValidation)
if err != nil {
return nil, errors.Wrapf(err, "unable to parse stamped image name %q as a fully qualified image reference", stamped)
}
result[r] = configFile
result[t] = configFile
}
return result, nil
}
Expand All @@ -76,16 +76,16 @@ func loadImageTarballs(imageTarballs []string) ([]v1.Image, error) {
// the images defined by the given tag to config & manifest maps with the
// layers defined by the given LayerParts deriving from images in the given
// tarballs.
func writeOutput(outputTarball string, refToConfigs, refToBaseManifests map[name.Reference]string, imageTarballs []string, layerParts []compat.LayerParts) error {
refToImg := make(map[name.Reference]v1.Image)
func writeOutput(outputTarball string, tagToConfigs, tagToBaseManifests map[name.Tag]string, imageTarballs []string, layerParts []compat.LayerParts) error {
tagToImg := make(map[name.Tag]v1.Image)
images, err := loadImageTarballs(imageTarballs)
if err != nil {
return errors.Wrap(err, "unable to load images from the given tarballs")
}
for ref, configFile := range refToConfigs {
for tag, configFile := range tagToConfigs {
// Manifest file may not have been specified and this is ok as it's
// only required if the base images has foreign layers.
manifestFile := refToBaseManifests[ref]
manifestFile := tagToBaseManifests[tag]
parts := compat.ImageParts{
Config: configFile,
BaseManifest: manifestFile,
Expand All @@ -94,11 +94,11 @@ func writeOutput(outputTarball string, refToConfigs, refToBaseManifests map[name
}
img, err := compat.ReadImage(parts)
if err != nil {
return errors.Wrapf(err, "unable to load image %v corresponding to config %s", ref, configFile)
return errors.Wrapf(err, "unable to load image %v corresponding to config %s", tag, configFile)
}
refToImg[ref] = img
tagToImg[tag] = img
}
return tarball.MultiWriteToFile(outputTarball, refToImg)
return tarball.MultiWriteToFile(outputTarball, tagToImg)
}

func main() {
Expand All @@ -113,11 +113,11 @@ func main() {
if err != nil {
log.Fatalf("Unable to initialize stamper: %v", err)
}
refToConfig, err := parseRefToFilename(tags, stamper)
tagToConfig, err := parseTagToFilename(tags, stamper)
if err != nil {
log.Fatalf("Unable to process values passed using the flag --tag: %v", err)
}
refToBaseManifest, err := parseRefToFilename(basemanifests, stamper)
tagToBaseManifest, err := parseTagToFilename(basemanifests, stamper)
if err != nil {
log.Fatalf("Unable to process values passed using the flag --manifest: %v", err)
}
Expand All @@ -129,7 +129,7 @@ func main() {
}
layerParts = append(layerParts, layer)
}
if err := writeOutput(*outputTarball, refToConfig, refToBaseManifest, sourceImages, layerParts); err != nil {
if err := writeOutput(*outputTarball, tagToConfig, tagToBaseManifest, sourceImages, layerParts); err != nil {
log.Fatalf("Failed to generate output at %s: %v", *outputTarball, err)
}
}
2 changes: 1 addition & 1 deletion repositories/go_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def go_deps():
if "com_github_google_go_containerregistry" not in excludes:
go_repository(
name = "com_github_google_go_containerregistry",
commit = "0632dd120f814738b238b5c1368396a4af5c3bb3",
commit = "a8228cdaedffd366395d5a0b3022cd2142fddadb",
importpath = "github.com/google/go-containerregistry",
)
if "com_github_pkg_errors" not in excludes:
Expand Down

0 comments on commit c3f19ac

Please sign in to comment.