File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed
core/src/main/java/org/testcontainers Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -62,11 +62,13 @@ public class DockerClientFactory {
6262
6363 public static final String SESSION_ID = UUID .randomUUID ().toString ();
6464
65+ public static final String TESTCONTAINERS_VERSION =
66+ DockerClientFactory .class .getPackage ().getImplementationVersion ();
67+
6568 public static final Map <String , String > DEFAULT_LABELS = markerLabels ();
6669
6770 static Map <String , String > markerLabels () {
68- String implementationVersion = DockerClientFactory .class .getPackage ().getImplementationVersion ();
69- String testcontainersVersion = implementationVersion == null ? "unspecified" : implementationVersion ;
71+ String testcontainersVersion = TESTCONTAINERS_VERSION == null ? "unspecified" : TESTCONTAINERS_VERSION ;
7072
7173 Map <String , String > labels = new HashMap <>();
7274 labels .put (TESTCONTAINERS_LABEL , "true" );
Original file line number Diff line number Diff line change 3939import java .security .UnrecoverableKeyException ;
4040import java .time .Duration ;
4141import java .util .ArrayList ;
42- import java .util .Collections ;
4342import java .util .Comparator ;
43+ import java .util .HashMap ;
4444import java .util .HashSet ;
4545import java .util .List ;
46+ import java .util .Map ;
4647import java .util .Objects ;
4748import java .util .Optional ;
4849import java .util .Set ;
@@ -408,14 +409,15 @@ public static DockerClient getClientForConfig(TransportConfig transportConfig) {
408409 if (configBuilder .build ().getApiVersion () == RemoteApiVersion .UNKNOWN_VERSION ) {
409410 configBuilder .withApiVersion (RemoteApiVersion .VERSION_1_32 );
410411 }
412+ Map <String , String > headers = new HashMap <>();
413+ headers .put ("x-tc-sid" , DockerClientFactory .SESSION_ID );
414+ headers .put ("User-Agent" , String .format ("tc-java/%s" , DockerClientFactory .TESTCONTAINERS_VERSION ));
415+
411416 return DockerClientImpl .getInstance (
412417 new AuthDelegatingDockerClientConfig (
413418 configBuilder .withDockerHost (transportConfig .getDockerHost ().toString ()).build ()
414419 ),
415- new HeadersAddingDockerHttpClient (
416- dockerHttpClient ,
417- Collections .singletonMap ("x-tc-sid" , DockerClientFactory .SESSION_ID )
418- )
420+ new HeadersAddingDockerHttpClient (dockerHttpClient , headers )
419421 );
420422 }
421423
You can’t perform that action at this time.
0 commit comments