Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Adapt to skopeo 0.1.29 (#684)
Browse files Browse the repository at this point in the history
  • Loading branch information
andresmgot authored Apr 10, 2018
1 parent 30da457 commit c79d01c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/function-image-builder/layer-builder/layer_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"io"
"io/ioutil"
"log"
"os"
"path"
"strings"
Expand Down Expand Up @@ -70,7 +71,7 @@ func getLayer(file string) (*Layer, error) {
}

func saveNewDescription(content []byte, dir, contentChecksum string) error {
dLayerFile := path.Join(dir, fmt.Sprintf("%s.tar", contentChecksum))
dLayerFile := path.Join(dir, contentChecksum)
return copyReader(bytes.NewReader(content), dLayerFile)
}

Expand All @@ -93,10 +94,12 @@ func AddTarToLayer(imageDir, tarFile string) error {
if err != nil {
return err
}
err = copyFile(tarFile, path.Join(imageDir, fmt.Sprintf("%s.tar", tarLayer.Sha256)))
destFile := path.Join(imageDir, tarLayer.Sha256)
err = copyFile(tarFile, destFile)
if err != nil {
return fmt.Errorf("Failed to copy tar file: %v", err)
}
log.Printf("Copied source %s to %s", tarFile, destFile)

// Parse manifest
manifestPath := path.Join(imageDir, "manifest.json")
Expand All @@ -109,9 +112,10 @@ func AddTarToLayer(imageDir, tarFile string) error {
if err != nil {
return fmt.Errorf("Failed to parse image manifest: %v", err)
}
log.Printf("Parsed manifest")

// Update description
descriptionPath := path.Join(imageDir, fmt.Sprintf("%s.tar", strings.Replace(m.Config.Digest, "sha256:", "", -1)))
descriptionPath := path.Join(imageDir, strings.Replace(m.Config.Digest, "sha256:", "", -1))
descriptionFile, err := os.Open(descriptionPath)
if err != nil {
return err
Expand All @@ -132,6 +136,7 @@ func AddTarToLayer(imageDir, tarFile string) error {
if err != nil {
return err
}
log.Printf("Added layer to description at %s", descriptionLayer.Sha256)

// Update manifest
m.UpdateConfig(descriptionLayer)
Expand All @@ -144,6 +149,7 @@ func AddTarToLayer(imageDir, tarFile string) error {
if err != nil {
return err
}
log.Printf("Updated manifest")

return nil
}

0 comments on commit c79d01c

Please sign in to comment.