Skip to content
This repository was archived by the owner on May 3, 2022. It is now read-only.

Commit 59432c8

Browse files
committed
Image relocation
See `duffle relocate -h` for documentation. Adds the originalImage field to images in both the image map and invocation images on the assumption that cnabio/cnab-spec#157 will be implemented. Fixes #668
1 parent 3ed3dbe commit 59432c8

File tree

8 files changed

+562
-37
lines changed

8 files changed

+562
-37
lines changed

Gopkg.lock

Lines changed: 38 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,7 @@
5353
[[constraint]]
5454
name = "github.com/docker/go"
5555
version = "1.5.1-1"
56+
57+
[[constraint]]
58+
branch = "master"
59+
name = "github.com/pivotal/image-relocation"

cmd/duffle/build.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,9 @@ func (b *buildCmd) run() (err error) {
149149
}
150150

151151
func (b *buildCmd) writeBundle(bf *bundle.Bundle) (string, error) {
152-
data, err := json.MarshalCanonical(bf)
152+
data, digest, err := marshalBundle(bf)
153153
if err != nil {
154-
return "", err
155-
}
156-
data = append(data, '\n') //TODO: why?
157-
158-
digest, err := digest.OfBuffer(data)
159-
if err != nil {
160-
return "", fmt.Errorf("cannot compute digest from bundle: %v", err)
154+
return "", fmt.Errorf("cannot marshal bundle: %v", err)
161155
}
162156

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

166+
func marshalBundle(bf *bundle.Bundle) ([]byte, string, error) {
167+
data, err := json.MarshalCanonical(bf)
168+
if err != nil {
169+
return nil, "", err
170+
}
171+
data = append(data, '\n') //TODO: why?
172+
173+
digest, err := digest.OfBuffer(data)
174+
if err != nil {
175+
return nil, "", fmt.Errorf("cannot compute digest from bundle: %v", err)
176+
}
177+
178+
return data, digest, nil
179+
}
180+
172181
func defaultDockerTLS() bool {
173182
return os.Getenv(dockerTLSEnvVar) != ""
174183
}

0 commit comments

Comments
 (0)