@@ -252,10 +252,6 @@ tmux_compose_add_volume(PQExpBuffer script, const char *name)
252252static void
253253prepare_tmux_compose_config (TmuxOptions * options , PQExpBuffer script )
254254{
255- /* that's optional, but we still fill it as an header of sorts */
256- appendPQExpBuffer (script , "version: \"3.9\"\n" );
257- appendPQExpBuffer (script , "\n" );
258-
259255 appendPQExpBuffer (script , "services:\n" );
260256
261257 /* first, the monitor */
@@ -348,16 +344,17 @@ tmux_compose_docker_build(TmuxOptions *options)
348344
349345 log_info ("docker compose build" );
350346
351- char dockerCompose [MAXPGPATH ] = { 0 };
347+ char docker [MAXPGPATH ] = { 0 };
352348
353- if (!search_path_first ("docker" , dockerCompose , LOG_ERROR ))
349+ if (!search_path_first ("docker" , docker , LOG_ERROR ))
354350 {
355- log_fatal ("Failed to find program docker compose in PATH" );
351+ log_fatal ("Failed to find program docker in PATH" );
356352 exit (EXIT_CODE_INTERNAL_ERROR );
357353 }
358354
359355 char pgversion [5 ] = { 0 };
360356 char pgversionArg [15 ] = { 0 };
357+ char citustagArg [20 ] = { 0 };
361358
362359 if (env_exists ("PGVERSION" ))
363360 {
@@ -373,16 +370,53 @@ tmux_compose_docker_build(TmuxOptions *options)
373370 strlcpy (pgversion , "14" , sizeof (pgversion ));
374371 }
375372
373+ /* prepare Postgres/Citus compatibility matrix */
374+ char * pgCitusMatrix [18 ] = { 0 };
375+ pgCitusMatrix [13 ] = "v10.2.9" ;
376+ pgCitusMatrix [14 ] = "v12.1.5" ;
377+ pgCitusMatrix [15 ] = "v12.1.5" ;
378+ pgCitusMatrix [16 ] = "v13.0.1" ;
379+ pgCitusMatrix [17 ] = "v13.0.1" ;
380+
381+ int pgVersionNum ;
382+ char * citustag = NULL ;
383+
384+ if (!stringToInt (pgversion , & pgVersionNum ))
385+ {
386+ log_error ("Failed to parse PGVERSION \"%s\" into an int" , pgversion );
387+ exit (EXIT_CODE_INTERNAL_ERROR );
388+ }
389+
390+ if (pgVersionNum > 12 && pgVersionNum < 18 )
391+ {
392+ citustag = pgCitusMatrix [pgVersionNum ];
393+ }
394+ else
395+ {
396+ log_fatal ("Unsupported PGVERSION=%s" , pgversion );
397+ exit (EXIT_CODE_INTERNAL_ERROR );
398+ }
399+
400+ if (citustag == NULL )
401+ {
402+ log_fatal ("Unknown CITUSTAG for PGVERSION=%s" , pgversion );
403+ exit (EXIT_CODE_INTERNAL_ERROR );
404+ }
405+
376406 /* prepare our --build-arg PGVERSION=XX */
377407 sformat (pgversionArg , sizeof (pgversionArg ), "PGVERSION=%s" , pgversion );
408+ sformat (citustagArg , sizeof (citustagArg ), "CITUSTAG=%s" , citustag );
378409
379410 char * args [16 ];
380411 int argsIndex = 0 ;
381412
382- args [argsIndex ++ ] = (char * ) dockerCompose ;
413+ args [argsIndex ++ ] = (char * ) docker ;
414+ args [argsIndex ++ ] = "compose" ;
383415 args [argsIndex ++ ] = "build" ;
384416 args [argsIndex ++ ] = "--build-arg" ;
385417 args [argsIndex ++ ] = (char * ) pgversionArg ;
418+ args [argsIndex ++ ] = "--build-arg" ;
419+ args [argsIndex ++ ] = (char * ) citustagArg ;
386420 args [argsIndex ++ ] = "--quiet" ;
387421 args [argsIndex ] = NULL ;
388422
@@ -519,19 +553,19 @@ tmux_compose_rm_volume(const char *docker, const char *nodeName)
519553static bool
520554tmux_compose_down (TmuxOptions * options )
521555{
522- char dockerCompose [MAXPGPATH ] = { 0 };
556+ char docker [MAXPGPATH ] = { 0 };
523557
524- if (!search_path_first ("docker" , dockerCompose , LOG_ERROR ))
558+ if (!search_path_first ("docker" , docker , LOG_ERROR ))
525559 {
526- log_fatal ("Failed to find program docker compose in PATH" );
560+ log_fatal ("Failed to find program docker in PATH" );
527561 return false;
528562 }
529563
530564 /* first docker compose down */
531565 log_info ("docker compose down" );
532566
533567 Program program =
534- run_program (dockerCompose , "down" ,
568+ run_program (docker , "compose" , "down" ,
535569 "--volumes" , "--remove-orphans" , NULL );
536570
537571 if (program .returnCode != 0 )
@@ -552,14 +586,6 @@ tmux_compose_down(TmuxOptions *options)
552586 /*
553587 * Now remove all the docker volumes
554588 */
555- char docker [MAXPGPATH ] = { 0 };
556-
557- if (!search_path_first ("docker" , docker , LOG_ERROR ))
558- {
559- log_fatal ("Failed to find program docker in PATH" );
560- return false;
561- }
562-
563589 (void ) tmux_compose_rm_volume (docker , "monitor" );
564590
565591 for (int i = 0 ; i < tmuxNodeArray .count ; i ++ )
0 commit comments