@@ -6,6 +6,7 @@ use bollard::{
6
6
} ;
7
7
use futures:: { StreamExt , TryStreamExt } ;
8
8
use itertools:: Itertools ;
9
+ use minijinja:: render;
9
10
use tokio;
10
11
use tracing:: { debug, error, info, trace, warn} ;
11
12
@@ -26,7 +27,13 @@ pub async fn check(profile_name: &str) -> Result<()> {
26
27
27
28
// build test image string
28
29
// registry.example.com/somerepo/testimage:pleaseignore
29
- let test_image = format ! ( "{}/credstestimage" , registry_config. domain) ;
30
+ let test_image = render ! (
31
+ & registry_config. tag_format,
32
+ domain => registry_config. domain,
33
+ challenge => "accesscheck" ,
34
+ container => "testimage" ,
35
+ profile => profile_name
36
+ ) ;
30
37
debug ! ( "will push test image to {}" , test_image) ;
31
38
32
39
// push alpine image with build credentials
@@ -66,16 +73,16 @@ async fn check_build_credentials(client: &Docker, test_image: &str) -> Result<()
66
73
67
74
let registry_config = & get_config ( ) ?. registry ;
68
75
69
- // rename alpine image as test image
70
- let tag_opts = TagImageOptions {
71
- repo : test_image ,
72
- tag : "latest" ,
73
- } ;
76
+ // rename alpine image as test imag
77
+ let ( repo , tag ) = test_image
78
+ . rsplit_once ( ':' )
79
+ . unwrap_or ( ( test_image , "latest" ) ) ;
80
+ let tag_opts = TagImageOptions { repo , tag } ;
74
81
client. tag_image ( "alpine" , Some ( tag_opts) ) . await ?;
75
82
76
83
// now push test iamge to configured repo
77
- debug ! ( "pushing alpine to target registry" ) ;
78
- let options = PushImageOptions { tag : "latest" } ;
84
+ debug ! ( "pushing alpine to target registry as {}:{}" , repo , tag ) ;
85
+ let options = PushImageOptions { tag } ;
79
86
let build_creds = DockerCredentials {
80
87
username : Some ( registry_config. build . user . clone ( ) ) ,
81
88
password : Some ( registry_config. build . pass . clone ( ) ) ,
@@ -84,7 +91,7 @@ async fn check_build_credentials(client: &Docker, test_image: &str) -> Result<()
84
91
} ;
85
92
86
93
client
87
- . push_image ( test_image , Some ( options) , Some ( build_creds) )
94
+ . push_image ( repo , Some ( options) , Some ( build_creds) )
88
95
. try_collect :: < Vec < _ > > ( )
89
96
. await ?;
90
97
@@ -100,8 +107,11 @@ async fn check_cluster_credentials(client: &Docker, test_image: &str) -> Result<
100
107
let registry_config = & get_config ( ) ?. registry ;
101
108
102
109
// pull just-pushed alpine image from repo
110
+ let ( repo, tag) = test_image
111
+ . rsplit_once ( ':' )
112
+ . unwrap_or ( ( test_image, "latest" ) ) ;
103
113
let alpine_test_image = CreateImageOptions {
104
- from_image : test_image ,
114
+ from_image : [ repo , tag ] . join ( ":" ) ,
105
115
..Default :: default ( )
106
116
} ;
107
117
let cluster_creds = DockerCredentials {
0 commit comments