11package io .dagger .modules .ci ;
22
3+ import static io .dagger .client .Dagger .dag ;
4+
35import io .dagger .client .AwsCli ;
46import io .dagger .client .CacheVolume ;
57import io .dagger .client .Client .AwsCliArguments ;
1012import io .dagger .client .Directory .DockerBuildArguments ;
1113import io .dagger .client .Platform ;
1214import io .dagger .client .Secret ;
13- import io .dagger .module . AbstractModule ;
15+ import io .dagger .client . engineconn . Connection ;
1416import io .dagger .module .annotation .Default ;
1517import io .dagger .module .annotation .DefaultPath ;
1618import io .dagger .module .annotation .Function ;
1719import io .dagger .module .annotation .Object ;
1820import java .util .List ;
1921import java .util .concurrent .ExecutionException ;
22+ import org .slf4j .Logger ;
23+ import org .slf4j .LoggerFactory ;
2024
2125/** Ci main object */
2226@ Object
23- public class Ci extends AbstractModule {
27+ public class Ci {
28+
29+ static final Logger LOG = LoggerFactory .getLogger (Connection .class );
2430
2531 private static final List <String > ARCHS = List .of ("amd64" , "arm64" );
2632
@@ -51,6 +57,7 @@ public Container buildImage(@DefaultPath(".") Directory source)
5157 private List <Container > buildImageMultiarch (Directory source , List <String > variants ) {
5258 List <Container > images = variants .stream ().map (platform -> {
5359 try {
60+ LOG .info ("Building image for {}" , platform );
5461 return buildImage (source , platform );
5562 } catch (ExecutionException | DaggerQueryException | InterruptedException e ) {
5663 throw new RuntimeException (e );
@@ -80,14 +87,14 @@ private Container buildImage(Directory source, String platform)
8087 public String publish (@ DefaultPath ("." ) Directory source , Secret awsAccessKeyId ,
8188 Secret awsSecretAccessKey , @ Default ("eu-west-1" ) String region )
8289 throws ExecutionException , DaggerQueryException , InterruptedException {
83- AwsCli awsCli = dag .awsCli ()
90+ AwsCli awsCli = dag () .awsCli ()
8491 .withRegion (region )
8592 .withStaticCredentials (awsAccessKeyId , awsSecretAccessKey );
8693 Secret token = awsCli .ecr ().getLoginPassword ();
8794 String accountId = awsCli .sts ().getCallerIdentity ().account ();
8895 String address = "%s.dkr.ecr.%s.amazonaws.com/parisjug-dagger-demo/translate-api:%s"
89- .formatted (accountId , region , dag .gitInfo (source ).commitHash ().substring (0 , 8 ));
90- dag .container ()
96+ .formatted (accountId , region , dag () .gitInfo (source ).commitHash ().substring (0 , 8 ));
97+ dag () .container ()
9198 .withRegistryAuth (address , "AWS" , token )
9299 .publish (address , new PublishArguments ()
93100 .withPlatformVariants (buildImageMultiarch (source , ARCHS )));
@@ -108,11 +115,11 @@ public String publish(@DefaultPath(".") Directory source, Secret awsAccessKeyId,
108115 public String deploy (@ DefaultPath ("." ) Directory source , String image , String clusterName ,
109116 Secret awsAccessKeyId , Secret awsSecretAccessKey , @ Default ("eu-west-1" ) String region )
110117 throws ExecutionException , DaggerQueryException , InterruptedException {
111- Container deployerCtr = dag .container ().from ("alpine" )
118+ Container deployerCtr = dag () .container ().from ("alpine" )
112119 .withExec (List .of ("apk" , "add" , "aws-cli" , "kubectl" ));
113120 String appYaml = source .file ("src/main/kube/app.yaml" ).contents ()
114121 .replace ("${IMAGE_TAG}" , image );
115- return dag .awsCli (new AwsCliArguments ().withContainer (deployerCtr ))
122+ return dag () .awsCli (new AwsCliArguments ().withContainer (deployerCtr ))
116123 .withRegion (region )
117124 .withStaticCredentials (awsAccessKeyId , awsSecretAccessKey )
118125 .exec (List .of ("eks" , "update-kubeconfig" , "--name" , clusterName ))
@@ -124,8 +131,8 @@ public String deploy(@DefaultPath(".") Directory source, String image, String cl
124131
125132 /** Build a ready-to-use development environment */
126133 private Container buildEnv (Directory source ) {
127- CacheVolume mavenCache = dag .cacheVolume ("m2" );
128- return dag
134+ CacheVolume mavenCache = dag () .cacheVolume ("m2" );
135+ return dag ()
129136 .container ()
130137 .from ("maven:3-eclipse-temurin-21" )
131138 .withDirectory ("/src" , source )
0 commit comments