Skip to content

Commit

Permalink
Merge pull request #239 from buildpacks/skip-validation
Browse files Browse the repository at this point in the history
Skip validating inspect ID after save
  • Loading branch information
natalieparellano authored Jan 18, 2024
2 parents ba4f65e + 096f3c8 commit e94a1b7
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions local/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (i *Image) doSaveAs(name string) (types.ImageInspect, error) {
}()

tw := tar.NewWriter(pw)
configHash, err := i.addImageToTar(tw, repoName)
_, err = i.addImageToTar(tw, repoName)
if err != nil {
return types.ImageInspect{}, err
}
Expand All @@ -136,9 +136,6 @@ func (i *Image) doSaveAs(name string) (types.ImageInspect, error) {
}
return types.ImageInspect{}, err
}
if err = i.validateInspect(inspect, configHash); err != nil {
return types.ImageInspect{}, err
}

return inspect, nil
}
Expand Down Expand Up @@ -276,22 +273,6 @@ func (i *Image) addImageToTar(tw *tar.Writer, repoName string) (string, error) {
return configHash, addTextToTar(tw, "manifest.json", manifest)
}

func (i *Image) validateInspect(inspect types.ImageInspect, givenConfigHash string) error {
foundConfig, err := v1Config(inspect, i.createdAt, i.history)
if err != nil {
return fmt.Errorf("failed to get config file from inspect: %w", err)
}
foundConfigFile, err := json.Marshal(foundConfig)
if err != nil {
return fmt.Errorf("failed to marshal config file: %w", err)
}
foundID := fmt.Sprintf("%x", sha256.Sum256(foundConfigFile))
if foundID != givenConfigHash {
return fmt.Errorf("expected config hash %q; got %q", givenConfigHash, foundID)
}
return nil
}

// helpers

func checkResponseError(r io.Reader) error {
Expand Down

0 comments on commit e94a1b7

Please sign in to comment.