mirror of
				https://github.com/linuxkit/linuxkit.git
				synced 2025-10-31 03:04:47 +00:00 
			
		
		
		
	Generated largely from the specified config; small parts taken from `docker image inspect`, such as the command line. Renamed some of the yaml keys to match the OCI spec rather than Docker Compose as we decided they are more readable, no more underscores. Add some extra functionality - tmpfs specification - fully general mount specification - no new privileges can be specified now For nostalgic reasons, using engine-api to talk to the docker cli as we only need an old API version, and it is nice and easy to vendor... Signed-off-by: Justin Cormack <justin.cormack@docker.com>
		
			
				
	
	
		
			45 lines
		
	
	
		
			1014 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1014 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package digest
 | |
| 
 | |
| import (
 | |
| 	"hash"
 | |
| 	"io"
 | |
| )
 | |
| 
 | |
| // Verifier presents a general verification interface to be used with message
 | |
| // digests and other byte stream verifications. Users instantiate a Verifier
 | |
| // from one of the various methods, write the data under test to it then check
 | |
| // the result with the Verified method.
 | |
| type Verifier interface {
 | |
| 	io.Writer
 | |
| 
 | |
| 	// Verified will return true if the content written to Verifier matches
 | |
| 	// the digest.
 | |
| 	Verified() bool
 | |
| }
 | |
| 
 | |
| // NewDigestVerifier returns a verifier that compares the written bytes
 | |
| // against a passed in digest.
 | |
| func NewDigestVerifier(d Digest) (Verifier, error) {
 | |
| 	if err := d.Validate(); err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 
 | |
| 	return hashVerifier{
 | |
| 		hash:   d.Algorithm().Hash(),
 | |
| 		digest: d,
 | |
| 	}, nil
 | |
| }
 | |
| 
 | |
| type hashVerifier struct {
 | |
| 	digest Digest
 | |
| 	hash   hash.Hash
 | |
| }
 | |
| 
 | |
| func (hv hashVerifier) Write(p []byte) (n int, err error) {
 | |
| 	return hv.hash.Write(p)
 | |
| }
 | |
| 
 | |
| func (hv hashVerifier) Verified() bool {
 | |
| 	return hv.digest == NewDigest(hv.digest.Algorithm(), hv.hash)
 | |
| }
 |