Skip to content

Commit

Permalink
Get all the Tugboat info out of the ddev configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
justafish committed Jul 11, 2023
1 parent 662ce89 commit d168100
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,21 +442,21 @@ include which will give you helpers that you can include and reference for tasks
such as setting up [Terminus](https://pantheon.io/docs/terminus). See
[scaffold/gitlab/Pantheon.gitlab-ci.yml](scaffold/gitlab/Pantheon.gitlab-ci.yml).

### Tugboat
## Tugboat

Add the following to `composer.json` to add Tugboat configuration:

```json
{
"extra": {
"drainpipe": {
"tugboat": {
"provider": "pantheon"
}
"tugboat": {}
}
}
}
```

The PHP and database version is autodetected based on your `pantheon.yml`, with
the nodejs version being derived from DDEV settings.
The following will be autodetected based on your `.ddev/config.yml`:
- PHP version
- Database type and version
- nodejs version
- Redis (Obtained with `ddev get ddev/ddev-redis`)
2 changes: 1 addition & 1 deletion scaffold/tugboat/config.yml.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
php:
http: false
image: tugboatqa/php-nginx:{{ php_version }}-fpm
image: tugboatqa/{{ webserver_image }}:{{ php_version }}-fpm
default: true

depends:
Expand Down
29 changes: 15 additions & 14 deletions src/ScaffoldInstallerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,35 +278,36 @@ private function installCICommands(): void
}

// Tugboat
if (!empty($this->extra['drainpipe']['tugboat']['host'])) {
if (isset($this->extra['drainpipe']['tugboat'])) {
$fs->removeDirectory('./.tugboat');
$tugboatConfig = [
'nodejs_version' => '18',
'webserver_image' => 'php-nginx',
'database_type' => 'mariadb',
'database_version' => '10.6',
'php_version' => '8.1',
];

if (file_exists('./.ddev/config.yml')) {
$ddevConfig = Yaml::parseFile('./.ddev/config.yml');
$tugboatConfig = [
'database_type' => $ddevConfig['database']['type'],
'database_version' => $ddevConfig['database']['version'],
'php_version' => $ddevConfig['php_version'],
];
if (!empty($ddevConfig['nodejs_version'])) {
$tugboatConfig['nodejs_version'] = $ddevConfig['nodejs_version'];
}
if (!empty($ddevConfig['webserver_type']) && $ddevConfig['webserver_type'] === 'apache-fpm') {
$tugboatConfig['webserver_image'] = 'php';
}
}

// Pantheon
if ($this->extra['drainpipe']['tugboat']['host'] === 'pantheon') {
$pantheonConfig = Yaml::parseFile('./pantheon.yml');
$composerJson = file_get_contents('composer.json');
$composerFullConfig = json_decode($composerJson, true);

$tugboatConfig['php_version'] = $pantheonConfig['php_version'];
$tugboatConfig['database_version'] = $pantheonConfig['database']['version'];

if (is_array($composerFullConfig['require']) && in_array('drupal/redis', array_keys($composerFullConfig['require']))) {
$tugboatConfig['memory_cache_type'] = 'redis';
$tugboatConfig['memory_cache_version'] = 7;
}
if (file_exists('./.ddev/docker-compose.redis.yaml')) {
$redisConfig = Yaml::parseFile('.ddev/docker-compose.redis.yaml');
$redisImage = explode(':', $redisConfig['services']['redis']['image']);
$tugboatConfig['memory_cache_type'] = 'redis';
$tugboatConfig['memory_cache_version'] = array_pop($redisImage);
}

if (count($tugboatConfig) > 0) {
Expand Down

0 comments on commit d168100

Please sign in to comment.