File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5
5
6
6
## Unreleased
7
7
8
+ ### Changed
9
+
10
+ - Added logging of exact image hash used during build
11
+
8
12
## [ 0.7.1] - 2020-05-20
9
13
10
14
### Changed
Original file line number Diff line number Diff line change @@ -28,11 +28,15 @@ impl SandboxImage {
28
28
/// This will access the network to download the image from the registry. If pulling fails an
29
29
/// error will be returned instead.
30
30
pub fn remote ( name : & str ) -> Result < Self , Error > {
31
- let image = SandboxImage { name : name. into ( ) } ;
31
+ let mut image = SandboxImage { name : name. into ( ) } ;
32
32
info ! ( "pulling image {} from Docker Hub" , name) ;
33
33
Command :: new_workspaceless ( "docker" )
34
34
. args ( & [ "pull" , & name] )
35
35
. run ( ) ?;
36
+ if let Some ( name_with_hash) = image. get_name_with_hash ( ) {
37
+ image. name = name_with_hash;
38
+ info ! ( "pulled image {}" , image. name) ;
39
+ }
36
40
image. ensure_exists_locally ( ) ?;
37
41
Ok ( image)
38
42
}
@@ -45,6 +49,22 @@ impl SandboxImage {
45
49
. run ( ) ?;
46
50
Ok ( ( ) )
47
51
}
52
+
53
+ fn get_name_with_hash ( & self ) -> Option < String > {
54
+ Command :: new_workspaceless ( "docker" )
55
+ . args ( & [
56
+ "inspect" ,
57
+ & self . name ,
58
+ "--format" ,
59
+ "{{index .RepoDigests 0}}" ,
60
+ ] )
61
+ . log_output ( false )
62
+ . run_capture ( )
63
+ . ok ( ) ?
64
+ . stdout_lines ( )
65
+ . first ( )
66
+ . cloned ( )
67
+ }
48
68
}
49
69
50
70
/// Whether to mount a path in the sandbox with write permissions or not.
You can’t perform that action at this time.
0 commit comments