forked from cnabio/duffle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(*): add digest to invocation image on build
resolves cnabio#690
- Loading branch information
Michelle Noorali
committed
Apr 1, 2019
1 parent
9551a6d
commit 3afcf87
Showing
7 changed files
with
73 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package digester | ||
|
||
import ( | ||
"golang.org/x/net/context" | ||
|
||
"github.com/docker/docker/client" | ||
"github.com/opencontainers/go-digest" | ||
) | ||
|
||
type Digester struct { | ||
Client client.ImageAPIClient | ||
Image string | ||
Context context.Context | ||
} | ||
|
||
func NewDigester(client client.ImageAPIClient, image string, ctx context.Context) *Digester { | ||
return &Digester{ | ||
Client: client, | ||
Image: image, | ||
Context: ctx, | ||
} | ||
} | ||
|
||
// Digest returns the digest of the image tar | ||
func (d *Digester) Digest() (string, error) { | ||
reader, err := d.Client.ImageSave(d.Context, []string{d.Image}) | ||
computedDigest, err := digest.Canonical.FromReader(reader) | ||
if err != nil { | ||
return "", err | ||
} | ||
defer reader.Close() | ||
|
||
return computedDigest.String(), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters