1717import com .google .common .collect .ImmutableSet ;
1818import org .testcontainers .containers .Network ;
1919
20+ import java .util .Locale ;
21+ import java .util .Map ;
2022import java .util .Optional ;
2123
2224import static io .trino .testing .containers .Minio .MINIO_REGION ;
@@ -36,16 +38,16 @@ public IcebergRestCatalogBackendContainer(
3638 "iceberg-rest" ,
3739 ImmutableSet .of (8181 ),
3840 ImmutableMap .of (),
39- ImmutableMap .of (
40- "CATALOG_INCLUDE__CREDENTIALS " , "true" ,
41- "CATALOG_WAREHOUSE " , warehouseLocation ,
42- "CATALOG_IO__IMPL " , "org.apache.iceberg.aws.s3.S3FileIO" ,
43- "AWS_REGION " , MINIO_REGION ,
44- "CATALOG_S3_ACCESS__KEY__ID " , minioAccessKey ,
45- "CATALOG_S3_SECRET__ACCESS__KEY " , minioSecretKey ,
46- "CATALOG_S3_SESSION__TOKEN " , minioSessionToken ,
47- "CATALOG_S3_ENDPOINT " , "http://minio:4566 " ,
48- "CATALOG_S3_PATH__STYLE__ACCESS " , "true" ),
41+ toCatalogEnvVars ( ImmutableMap .of (
42+ "include-credentials " , "true" ,
43+ "warehouse " , warehouseLocation ,
44+ "io-impl " , "org.apache.iceberg.aws.s3.S3FileIO" ,
45+ "s3.access-key-id " , minioAccessKey ,
46+ "s3.secret-access-key " , minioSecretKey ,
47+ "s3.session-token " , minioSessionToken ,
48+ "s3.endpoint " , "http://minio:4566" ,
49+ "s3.path-style-access " , "true " ,
50+ "client.region " , MINIO_REGION ) ),
4951 network ,
5052 5 );
5153 }
@@ -54,4 +56,18 @@ public String getRestCatalogEndpoint()
5456 {
5557 return getMappedHostAndPortForExposedPort (8181 ).toString ();
5658 }
59+
60+ private static Map <String , String > toCatalogEnvVars (Map <String , String > catalogProperties )
61+ {
62+ ImmutableMap .Builder <String , String > envVarProperties = ImmutableMap .builder ();
63+ catalogProperties .forEach ((key , value ) -> {
64+ String envVarKey = "CATALOG_" +
65+ key .toUpperCase (Locale .ROOT )
66+ .replaceAll ("-" , "__" )
67+ .replaceAll ("\\ ." , "_" );
68+
69+ envVarProperties .put (envVarKey , value );
70+ });
71+ return envVarProperties .build ();
72+ }
5773}
0 commit comments