@@ -271,7 +271,7 @@ func TestDeployment(t *testing.T) {
271
271
}
272
272
})
273
273
274
- deployment , err := cli .NewCaddyDeployment ("" , api.Placement {})
274
+ deployment , err := cli .NewCaddyDeployment ("" , "" , api.Placement {})
275
275
require .NoError (t , err )
276
276
277
277
_ , err = deployment .Run (ctx )
@@ -284,6 +284,12 @@ func TestDeployment(t *testing.T) {
284
284
285
285
ctr := svc .Containers [0 ].Container
286
286
assert .Regexp (t , `^caddy:2\.\d+\.\d+$` , ctr .Config .Image )
287
+
288
+ config , err := cli .Caddy .GetConfig (ctx , nil )
289
+ require .NoError (t , err )
290
+
291
+ assert .Contains (t , config .Caddyfile , "# This file is autogenerated by Uncloud" )
292
+ assert .Contains (t , config .Caddyfile , "handle /.uncloud-verify" )
287
293
})
288
294
289
295
t .Run ("caddy with machine placement" , func (t * testing.T ) {
@@ -295,7 +301,7 @@ func TestDeployment(t *testing.T) {
295
301
})
296
302
297
303
// Deploy to machine #0.
298
- deployment , err := cli .NewCaddyDeployment ("" , api.Placement {
304
+ deployment , err := cli .NewCaddyDeployment ("" , "" , api.Placement {
299
305
Machines : []string {c .Machines [0 ].Name },
300
306
})
301
307
require .NoError (t , err )
@@ -313,7 +319,7 @@ func TestDeployment(t *testing.T) {
313
319
// initialContainerID := svc.Containers[0].Container.ID
314
320
315
321
// Deploy to all machines without a placement constraint.
316
- deployment , err = cli .NewCaddyDeployment (image , api.Placement {})
322
+ deployment , err = cli .NewCaddyDeployment (image , "" , api.Placement {})
317
323
require .NoError (t , err )
318
324
319
325
_ , err = deployment .Run (ctx )
@@ -332,6 +338,40 @@ func TestDeployment(t *testing.T) {
332
338
// assert.True(t, containers.Contains(initialContainerID), "Expected initial container to remain")
333
339
})
334
340
341
+ t .Run ("caddy with custom config" , func (t * testing.T ) {
342
+ t .Cleanup (func () {
343
+ err := cli .RemoveService (ctx , client .CaddyServiceName )
344
+ if ! errors .Is (err , api .ErrNotFound ) {
345
+ require .NoError (t , err )
346
+ }
347
+ })
348
+
349
+ caddyfile := `{
350
+ debug
351
+ }
352
+
353
+ myapp.example.com {
354
+ reverse_proxy myapp:8000
355
+ }`
356
+ deployment , err := cli .NewCaddyDeployment ("" , caddyfile , api.Placement {})
357
+ require .NoError (t , err )
358
+
359
+ _ , err = deployment .Run (ctx )
360
+ require .NoError (t , err )
361
+
362
+ svc , err := cli .InspectService (ctx , client .CaddyServiceName )
363
+ require .NoError (t , err )
364
+ assertServiceMatchesSpec (t , svc , deployment .Spec )
365
+
366
+ config , err := cli .Caddy .GetConfig (ctx , nil )
367
+ require .NoError (t , err )
368
+
369
+ assert .Contains (t , config .Caddyfile , "# This file is autogenerated by Uncloud" )
370
+ assert .Contains (t , config .Caddyfile , "handle /.uncloud-verify" )
371
+ assert .Contains (t , config .Caddyfile , caddyfile ,
372
+ "Expected user-defined global Caddy config to be included in the Caddyfile" )
373
+ })
374
+
335
375
t .Run ("replicated" , func (t * testing.T ) {
336
376
t .Parallel ()
337
377
0 commit comments