@@ -267,7 +267,7 @@ func take(fn func() error) func() error {
267
267
func api (ctx context.Context , _ * dagger.Client , base , flipt * dagger.Container , conf testConfig ) func () error {
268
268
return suite (ctx , "api" , base ,
269
269
// create unique instance for test case
270
- flipt .WithEnvVariable ("UNIQUE" , uuid .New ().String ()). WithExec ( nil ) , conf )
270
+ flipt .WithEnvVariable ("UNIQUE" , uuid .New ().String ()), conf )
271
271
}
272
272
273
273
func snapshot (ctx context.Context , _ * dagger.Client , base , flipt * dagger.Container , conf testConfig ) func () error {
@@ -278,7 +278,7 @@ func snapshot(ctx context.Context, _ *dagger.Client, base, flipt *dagger.Contain
278
278
WithEnvVariable ("FLIPT_STORAGE_LOCAL_PATH" , "/tmp/testdata" ).
279
279
WithEnvVariable ("UNIQUE" , uuid .New ().String ())
280
280
281
- return suite (ctx , "snapshot" , base , flipt . WithExec ( nil ) , conf )
281
+ return suite (ctx , "snapshot" , base , flipt , conf )
282
282
}
283
283
284
284
func ofrep (ctx context.Context , _ * dagger.Client , base , flipt * dagger.Container , conf testConfig ) func () error {
@@ -289,7 +289,7 @@ func ofrep(ctx context.Context, _ *dagger.Client, base, flipt *dagger.Container,
289
289
WithEnvVariable ("FLIPT_STORAGE_LOCAL_PATH" , "/tmp/testdata" ).
290
290
WithEnvVariable ("UNIQUE" , uuid .New ().String ())
291
291
292
- return suite (ctx , "ofrep" , base , flipt . WithExec ( nil ) , conf )
292
+ return suite (ctx , "ofrep" , base , flipt , conf )
293
293
}
294
294
295
295
func withSQLite (fn testCaseFn ) testCaseFn {
@@ -348,10 +348,8 @@ func withCockroach(fn testCaseFn) testCaseFn {
348
348
WithEnvVariable ("COCKROACH_DATABASE" , "defaultdb" ).
349
349
WithEnvVariable ("UNIQUE" , uuid .New ().String ()).
350
350
WithExposedPort (26257 ).
351
- WithExec (
352
- []string {"start-single-node" , "--single-node" , "--insecure" , "--store=type=mem,size=0.7Gb" , "--accept-sql-without-tls" , "--logtostderr=ERROR" },
353
- dagger.ContainerWithExecOpts {UseEntrypoint : true }).
354
- AsService ()),
351
+ WithDefaultArgs ([]string {"start-single-node" , "--single-node" , "--insecure" , "--store=type=mem,size=0.7Gb" , "--accept-sql-without-tls" , "--logtostderr=ERROR" }).
352
+ AsService (dagger.ContainerAsServiceOpts {UseEntrypoint : true })),
355
353
conf ,
356
354
)
357
355
}
@@ -363,7 +361,7 @@ func cache(ctx context.Context, _ *dagger.Client, base, flipt *dagger.Container,
363
361
WithEnvVariable ("FLIPT_CACHE_ENABLED" , "true" ).
364
362
WithEnvVariable ("FLIPT_CACHE_TTL" , "1s" )
365
363
366
- return suite (ctx , "api" , base , flipt . WithExec ( nil ) , conf )
364
+ return suite (ctx , "api" , base , flipt , conf )
367
365
}
368
366
369
367
func cacheWithTLS (ctx context.Context , client * dagger.Client , base , flipt * dagger.Container , conf testConfig ) func () error {
@@ -376,7 +374,7 @@ func cacheWithTLS(ctx context.Context, client *dagger.Client, base, flipt *dagge
376
374
WithExposedPort (6379 ).
377
375
WithNewFile ("/opt/tls/key" , string (keyBytes )).
378
376
WithNewFile ("/opt/tls/crt" , string (crtBytes )).
379
- WithExec ([]string {
377
+ WithDefaultArgs ([]string {
380
378
"redis-server" , "--tls-port" , "6379" , "--port" , "0" ,
381
379
"--tls-key-file" , "/opt/tls/key" , "--tls-cert-file" ,
382
380
"/opt/tls/crt" , "--tls-ca-cert-file" , "/opt/tls/crt" ,
@@ -394,7 +392,7 @@ func cacheWithTLS(ctx context.Context, client *dagger.Client, base, flipt *dagge
394
392
WithEnvVariable ("FLIPT_CACHE_REDIS_CA_CERT_PATH" , "/opt/tls/crt" ).
395
393
WithNewFile ("/opt/tls/crt" , string (crtBytes )).
396
394
WithServiceBinding ("redis" , redis )
397
- return suite (ctx , "api" , base , flipt . WithExec ( nil ) , conf )
395
+ return suite (ctx , "api" , base , flipt , conf )
398
396
}
399
397
400
398
const (
@@ -410,13 +408,14 @@ func local(ctx context.Context, client *dagger.Client, base, flipt *dagger.Conta
410
408
WithEnvVariable ("FLIPT_STORAGE_LOCAL_PATH" , "/tmp/testdata" ).
411
409
WithEnvVariable ("UNIQUE" , uuid .New ().String ())
412
410
413
- return suite (ctx , "readonly" , base , flipt . WithExec ( nil ) , conf )
411
+ return suite (ctx , "readonly" , base , flipt , conf )
414
412
}
415
413
416
414
func git (ctx context.Context , client * dagger.Client , base , flipt * dagger.Container , conf testConfig ) func () error {
417
415
gitea := client .Container ().
418
416
From ("gitea/gitea:1.21.1" ).
419
- WithExposedPort (3000 )
417
+ WithExposedPort (3000 ).
418
+ AsService ()
420
419
421
420
stew := config.Config {
422
421
URL : "http://gitea:3000" ,
@@ -458,15 +457,15 @@ func git(ctx context.Context, client *dagger.Client, base, flipt *dagger.Contain
458
457
WithWorkdir ("/work" ).
459
458
WithDirectory ("/work/base" , base .Directory (rootReadOnlyTestdataDir )).
460
459
WithNewFile ("/etc/stew/config.yml" , string (contents )).
461
- WithServiceBinding ("gitea" , gitea . AsService () ).
462
- WithExec (nil ).
460
+ WithServiceBinding ("gitea" , gitea ).
461
+ WithExec ([] string { "/usr/local/bin/stew" , "-config" , "/etc/stew/config.yml" } ).
463
462
Sync (ctx )
464
463
if err != nil {
465
464
return func () error { return err }
466
465
}
467
466
468
467
flipt = flipt .
469
- WithServiceBinding ("gitea" , gitea . AsService () ).
468
+ WithServiceBinding ("gitea" , gitea ).
470
469
WithEnvVariable ("FLIPT_LOG_LEVEL" , "WARN" ).
471
470
WithEnvVariable ("FLIPT_STORAGE_TYPE" , "git" ).
472
471
WithEnvVariable ("FLIPT_STORAGE_GIT_REPOSITORY" , "http://gitea:3000/root/features.git" ).
@@ -477,7 +476,7 @@ func git(ctx context.Context, client *dagger.Client, base, flipt *dagger.Contain
477
476
// Git backend supports arbitrary references
478
477
conf .references = true
479
478
480
- return suite (ctx , "readonly" , base , flipt . WithExec ( nil ) , conf )
479
+ return suite (ctx , "readonly" , base , flipt , conf )
481
480
}
482
481
483
482
func s3 (ctx context.Context , client * dagger.Client , base , flipt * dagger.Container , conf testConfig ) func () error {
@@ -488,8 +487,8 @@ func s3(ctx context.Context, client *dagger.Client, base, flipt *dagger.Containe
488
487
WithEnvVariable ("MINIO_ROOT_USER" , "user" ).
489
488
WithEnvVariable ("MINIO_ROOT_PASSWORD" , "password" ).
490
489
WithEnvVariable ("MINIO_BROWSER" , "off" ).
491
- WithExec ([]string {"server" , "/data" , "--address" , ":9009" , "--quiet" }, dagger. ContainerWithExecOpts { UseEntrypoint : true }).
492
- AsService ()
490
+ WithDefaultArgs ([]string {"server" , "/data" , "--address" , ":9009" , "--quiet" }).
491
+ AsService (dagger. ContainerAsServiceOpts { UseEntrypoint : true } )
493
492
494
493
_ , err := base .
495
494
WithServiceBinding ("minio" , minio ).
@@ -512,7 +511,7 @@ func s3(ctx context.Context, client *dagger.Client, base, flipt *dagger.Containe
512
511
WithEnvVariable ("FLIPT_STORAGE_OBJECT_S3_BUCKET" , "testdata" ).
513
512
WithEnvVariable ("UNIQUE" , uuid .New ().String ())
514
513
515
- return suite (ctx , "readonly" , base , flipt . WithExec ( nil ) , conf )
514
+ return suite (ctx , "readonly" , base , flipt , conf )
516
515
}
517
516
518
517
func oci (ctx context.Context , client * dagger.Client , base , flipt * dagger.Container , conf testConfig ) func () error {
@@ -549,12 +548,13 @@ func oci(ctx context.Context, client *dagger.Client, base, flipt *dagger.Contain
549
548
platforms .MustParse (string (platform )).Architecture )).
550
549
WithExposedPort (5000 ).
551
550
WithNewFile ("/etc/zot/htpasswd" , htpasswd ).
552
- WithNewFile ("/etc/zot/config.json" , zotConfig )
551
+ WithNewFile ("/etc/zot/config.json" , zotConfig ).
552
+ AsService (dagger.ContainerAsServiceOpts {UseEntrypoint : true })
553
553
554
554
if _ , err := flipt .
555
555
WithDirectory ("/tmp/testdata" , base .Directory (singleRevisionTestdataDir )).
556
556
WithWorkdir ("/tmp/testdata" ).
557
- WithServiceBinding ("zot" , zot . AsService () ).
557
+ WithServiceBinding ("zot" , zot ).
558
558
WithEnvVariable ("FLIPT_STORAGE_OCI_AUTHENTICATION_USERNAME" , "username" ).
559
559
WithEnvVariable ("FLIPT_STORAGE_OCI_AUTHENTICATION_PASSWORD" , "password" ).
560
560
WithExec ([]string {"/flipt" , "bundle" , "build" , "readonly:latest" }).
@@ -566,15 +566,15 @@ func oci(ctx context.Context, client *dagger.Client, base, flipt *dagger.Contain
566
566
}
567
567
568
568
flipt = flipt .
569
- WithServiceBinding ("zot" , zot . AsService () ).
569
+ WithServiceBinding ("zot" , zot ).
570
570
WithEnvVariable ("FLIPT_LOG_LEVEL" , "WARN" ).
571
571
WithEnvVariable ("FLIPT_STORAGE_TYPE" , "oci" ).
572
572
WithEnvVariable ("FLIPT_STORAGE_OCI_REPOSITORY" , "http://zot:5000/readonly:latest" ).
573
573
WithEnvVariable ("FLIPT_STORAGE_OCI_AUTHENTICATION_USERNAME" , "username" ).
574
574
WithEnvVariable ("FLIPT_STORAGE_OCI_AUTHENTICATION_PASSWORD" , "password" ).
575
575
WithEnvVariable ("UNIQUE" , uuid .New ().String ())
576
576
577
- return suite (ctx , "readonly" , base , flipt . WithExec ( nil ) , conf )
577
+ return suite (ctx , "readonly" , base , flipt , conf )
578
578
}
579
579
580
580
func importInto (ctx context.Context , base , flipt , fliptToTest * dagger.Container , flags ... string ) error {
@@ -609,8 +609,7 @@ func importExport(ctx context.Context, _ *dagger.Client, base, flipt *dagger.Con
609
609
610
610
// create unique instance for test case
611
611
fliptToTest := flipt .
612
- WithEnvVariable ("UNIQUE" , uuid .New ().String ()).
613
- WithExec (nil )
612
+ WithEnvVariable ("UNIQUE" , uuid .New ().String ())
614
613
615
614
if err := importInto (ctx , base , flipt , fliptToTest , flags ... ); err != nil {
616
615
return err
@@ -660,7 +659,7 @@ func importExport(ctx context.Context, _ *dagger.Client, base, flipt *dagger.Con
660
659
661
660
func authn (ctx context.Context , _ * dagger.Client , base , flipt * dagger.Container , conf testConfig ) func () error {
662
661
// create unique instance for test case
663
- fliptToTest := flipt .WithEnvVariable ("UNIQUE" , uuid .New ().String ()). WithExec ( nil )
662
+ fliptToTest := flipt .WithEnvVariable ("UNIQUE" , uuid .New ().String ())
664
663
// import state into instance before running test
665
664
if err := importInto (ctx , base , flipt , fliptToTest , "--address" , conf .address , "--token" , bootstrapToken ); err != nil {
666
665
return func () error { return err }
@@ -673,8 +672,7 @@ func authz(ctx context.Context, client *dagger.Client, base, flipt *dagger.Conta
673
672
return withAuthz (func (ctx context.Context , client * dagger.Client , base , flipt * dagger.Container , conf testConfig ) func () error {
674
673
// create unique instance for test case
675
674
fliptToTest := flipt .
676
- WithEnvVariable ("UNIQUE" , uuid .New ().String ()).
677
- WithExec (nil )
675
+ WithEnvVariable ("UNIQUE" , uuid .New ().String ())
678
676
679
677
// import state into instance before running test
680
678
if err := importInto (ctx , base , flipt , fliptToTest , "--address" , conf .address , "--token" , bootstrapToken ); err != nil {
@@ -906,7 +904,7 @@ func azblob(ctx context.Context, client *dagger.Client, base, flipt *dagger.Cont
906
904
From ("mcr.microsoft.com/azure-storage/azurite" ).
907
905
WithEnvVariable ("UNIQUE" , uuid .New ().String ()).
908
906
WithExposedPort (10000 ).
909
- WithExec ([]string {"azurite-blob" , "--blobHost" , "0.0.0.0" , "--silent" }).
907
+ WithDefaultArgs ([]string {"azurite-blob" , "--blobHost" , "0.0.0.0" , "--silent" }).
910
908
AsService ()
911
909
912
910
_ , err := base .
@@ -930,7 +928,7 @@ func azblob(ctx context.Context, client *dagger.Client, base, flipt *dagger.Cont
930
928
WithEnvVariable ("AZURE_STORAGE_KEY" , "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" ).
931
929
WithEnvVariable ("UNIQUE" , uuid .New ().String ())
932
930
933
- return suite (ctx , "readonly" , base , flipt . WithExec ( nil ) , conf )
931
+ return suite (ctx , "readonly" , base , flipt , conf )
934
932
}
935
933
936
934
// gcs simulates the Google Cloud Storage service
@@ -939,8 +937,8 @@ func gcs(ctx context.Context, client *dagger.Client, base, flipt *dagger.Contain
939
937
From ("fsouza/fake-gcs-server" ).
940
938
WithEnvVariable ("UNIQUE" , uuid .New ().String ()).
941
939
WithExposedPort (4443 ).
942
- WithExec ([]string {"-scheme" , "http" , "-public-host" , "gcs:4443" }, dagger. ContainerWithExecOpts { UseEntrypoint : true }).
943
- AsService ()
940
+ WithDefaultArgs ([]string {"-scheme" , "http" , "-public-host" , "gcs:4443" }).
941
+ AsService (dagger. ContainerAsServiceOpts { UseEntrypoint : true } )
944
942
945
943
_ , err := base .
946
944
WithServiceBinding ("gcs" , gcs ).
@@ -989,7 +987,7 @@ func signJWT(key crypto.PrivateKey, claims interface{}) string {
989
987
// The function generates two JWTs, one for Flipt to identify itself and one which is returned to the caller.
990
988
// The caller can use this as the service account token identity to be mounted into the container with the
991
989
// client used for running the test and authenticating with Flipt.
992
- func serveOIDC (_ context.Context , _ * dagger.Client , base , flipt * dagger.Container ) (* dagger.Container , []byte , error ) {
990
+ func serveOIDC (ctx context.Context , _ * dagger.Client , base , flipt * dagger.Container ) (* dagger.Container , []byte , error ) {
993
991
priv , err := rsa .GenerateKey (rand .Reader , 4096 )
994
992
if err != nil {
995
993
return nil , nil , err
@@ -1072,7 +1070,7 @@ func serveOIDC(_ context.Context, _ *dagger.Client, base, flipt *dagger.Containe
1072
1070
WithNewFile ("/server.key" , caPrivKeyPEM .String ()).
1073
1071
WithNewFile ("/priv.pem" , rsaSigningKey .String ()).
1074
1072
WithExposedPort (443 ).
1075
- WithExec ([]string {
1073
+ WithDefaultArgs ([]string {
1076
1074
"sh" ,
1077
1075
"-c" ,
1078
1076
"go run ./build/internal/cmd/discover/... --private-key /priv.pem" ,
0 commit comments