Skip to content

Commit 1ba0f68

Browse files
authored
Merge pull request #373 from jolicode/remove-variable
Do not use variable() function when a $context is passed to the function
2 parents 567592d + 441908b commit 1ba0f68

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

.castor/docker.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -367,31 +367,31 @@ function docker_compose(array $subCommand, ?Context $c = null, array $profiles =
367367
$c ??= context();
368368
$profiles = $profiles ?: ['default'];
369369

370-
$domains = [variable('root_domain'), ...variable('extra_domains')];
370+
$domains = [$c['root_domain'], ...$c['extra_domains']];
371371
$domains = '`' . implode('`) || Host(`', $domains) . '`';
372372

373373
$c = $c->withEnvironment([
374-
'PROJECT_NAME' => variable('project_name'),
375-
'PROJECT_ROOT_DOMAIN' => variable('root_domain'),
374+
'PROJECT_NAME' => $c['project_name'],
375+
'PROJECT_ROOT_DOMAIN' => $c['root_domain'],
376376
'PROJECT_DOMAINS' => $domains,
377-
'USER_ID' => variable('user_id'),
378-
'PHP_VERSION' => variable('php_version'),
379-
'REGISTRY' => variable('registry') ?? '',
377+
'USER_ID' => $c['user_id'],
378+
'PHP_VERSION' => $c['php_version'],
379+
'REGISTRY' => $c['registry'] ?? '',
380380
]);
381381

382382
$command = [
383383
'docker',
384384
'compose',
385-
'-p', variable('project_name'),
385+
'-p', $c['project_name'],
386386
];
387387
foreach ($profiles as $profile) {
388388
$command[] = '--profile';
389389
$command[] = $profile;
390390
}
391391

392-
foreach (variable('docker_compose_files') as $file) {
392+
foreach ($c['docker_compose_files'] as $file) {
393393
$command[] = '-f';
394-
$command[] = variable('root_dir') . '/infrastructure/docker/' . $file;
394+
$command[] = $c['root_dir'] . '/infrastructure/docker/' . $file;
395395
}
396396

397397
$command = array_merge($command, $subCommand);
@@ -407,6 +407,8 @@ function docker_compose_run(
407407
?string $workDir = null,
408408
bool $portMapping = false,
409409
): Process {
410+
$c ??= context();
411+
410412
$command = [
411413
'run',
412414
'--rm',
@@ -425,7 +427,7 @@ function docker_compose_run(
425427
$command[] = $workDir;
426428
}
427429

428-
foreach (variable('docker_compose_run_environment') as $key => $value) {
430+
foreach ($c['docker_compose_run_environment'] as $key => $value) {
429431
$command[] = '-e';
430432
$command[] = "{$key}={$value}";
431433
}
@@ -464,8 +466,8 @@ function run_in_docker_or_locally_for_mac(string $command, ?Context $c = null):
464466
{
465467
$c ??= context();
466468

467-
if (variable('macos')) {
468-
run($command, context: $c->withPath(variable('root_dir')));
469+
if ($c['macos']) {
470+
run($command, context: $c->withPath($c['root_dir']));
469471
} else {
470472
docker_compose_run($command, c: $c);
471473
}

0 commit comments

Comments
 (0)