This example shows how to setup a processor that will remove the password and secrets from a non-versioned .env file on pull.
install, which includes a file called .env.environments.0.files.installdevelopmentRemoveSecrets::processdevelopment workflow by default on pullThis is not a complete configuration, for example the remove environment is missing; just the items needed to illustrate this concept are shown.
.live_dev_porter/config.yml
file_groups:
install:
include:
- /.env
workflows:
development:
-
processor: RemoveSecrets::process
environments:
local:
files:
install: install/default/scaffold
command_workflows:
pull: development
./live_dev_porter/processors/RemoveSecrets.php
<?php
use AKlump\LiveDevPorter\Processors\ProcessorFailedException;
class RemoveSecrets extends \AKlump\LiveDevPorter\Processors\ProcessorBase {
use \AKlump\LiveDevPorter\Processors\EnvTrait;
public function process() {
if (!$this->loadFile()
|| basename($this->filepath) != '.env') {
return;
}
$response = [];
$this->envReplaceUrlPassword('DATABASE_URL');
$response[] = "DATABASE_URL password";
foreach (['HASH_SALT', 'SHAREFILE_CLIENT_SECRET'] as $variable_name) {
$this->envReplaceValue($variable_name);
$response[] = $variable_name;
}
$this->saveFile();
return sprintf("Removed %s from %s.", implode(', ', $response), $this->shortpath);
}
}