2
2
3
3
import java .util .List ;
4
4
5
+ import org .slf4j .Logger ;
6
+ import org .slf4j .LoggerFactory ;
7
+
5
8
import com .github .dockerjava .api .model .AuthConfig ;
6
9
import com .github .dockerjava .core .DockerClientConfig ;
7
10
import com .github .dockerjava .core .DockerClientConfigDelegate ;
11
14
12
15
class AuthDelegatingDockerClientConfig extends DockerClientConfigDelegate {
13
16
17
+ private static final Logger log = LoggerFactory .getLogger (AuthDelegatingDockerClientConfig .class );
18
+
14
19
private List <RegistryAuthConfig > registryAuthInfo ;
15
20
16
21
public AuthDelegatingDockerClientConfig (DockerClientConfig delegate ) {
@@ -23,20 +28,26 @@ public void setRegistryAuthConfigs(List<RegistryAuthConfig> registryAuthInfo) {
23
28
24
29
@ Override
25
30
public AuthConfig effectiveAuthConfig (String imageName ) {
31
+ log .debug ("Resolving authentication configuration for image " +imageName );
26
32
AuthConfig fallbackAuthConfig ;
27
33
try {
28
34
fallbackAuthConfig = super .effectiveAuthConfig (imageName );
35
+ log .debug ("fallback config retrieved" );
29
36
} catch (Exception e ) {
30
37
fallbackAuthConfig = new AuthConfig ();
38
+ log .debug ("no fallback config available" );
31
39
}
32
40
33
41
// try and obtain more accurate auth config using our resolution
34
42
final ImageReference parsed = new ImageReference (imageName );
35
43
String address = parsed .getPort ()!=null ? parsed .getHost ()+":" +parsed .getPort () : parsed .getHost ();
44
+
45
+ log .debug ("Checking configuration for auth config for address " +address );
36
46
37
47
if (registryAuthInfo !=null ) {
38
48
for (RegistryAuthConfig rac : registryAuthInfo ){
39
49
if (address .equals (rac .getRegistryAddress ())){
50
+ log .debug ("found match, configuring" );
40
51
return new AuthConfig ()
41
52
.withAuth (rac .getAuth ())
42
53
.withEmail (rac .getEmail ())
@@ -49,6 +60,7 @@ public AuthConfig effectiveAuthConfig(String imageName) {
49
60
}
50
61
}
51
62
63
+ log .debug ("no match, using fallback if available" );
52
64
return fallbackAuthConfig ;
53
65
}
54
66
}
0 commit comments