Skip to content

Commit

Permalink
Image relocation
Browse files Browse the repository at this point in the history
  • Loading branch information
glyn committed Apr 10, 2019
1 parent 48dd2f9 commit 758427e
Show file tree
Hide file tree
Showing 7 changed files with 517 additions and 31 deletions.
61 changes: 38 additions & 23 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@
[[constraint]]
name = "github.com/docker/go"
version = "1.5.1-1"

[[constraint]]
branch = "master"
name = "github.com/pivotal/image-relocation"
25 changes: 17 additions & 8 deletions cmd/duffle/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,9 @@ func (b *buildCmd) run() (err error) {
}

func (b *buildCmd) writeBundle(bf *bundle.Bundle) (string, error) {
data, err := json.MarshalCanonical(bf)
data, digest, err := marshalBundle(bf)
if err != nil {
return "", err
}
data = append(data, '\n') //TODO: why?

digest, err := digest.OfBuffer(data)
if err != nil {
return "", fmt.Errorf("cannot compute digest from bundle: %v", err)
return "", fmt.Errorf("cannot marshal bundle: %v", err)
}

if b.outputFile != "" {
Expand All @@ -169,6 +163,21 @@ func (b *buildCmd) writeBundle(bf *bundle.Bundle) (string, error) {
return digest, ioutil.WriteFile(filepath.Join(b.home.Bundles(), digest), data, 0644)
}

func marshalBundle(bf *bundle.Bundle) ([]byte, string, error) {
data, err := json.MarshalCanonical(bf)
if err != nil {
return nil, "", err
}
data = append(data, '\n') //TODO: why?

digest, err := digest.OfBuffer(data)
if err != nil {
return nil, "", fmt.Errorf("cannot compute digest from bundle: %v", err)
}

return data, digest, nil
}

func defaultDockerTLS() bool {
return os.Getenv(dockerTLSEnvVar) != ""
}
Expand Down
Loading

0 comments on commit 758427e

Please sign in to comment.