Skip to content

Commit

Permalink
feature/introduce-new-deploymenthook-function
Browse files Browse the repository at this point in the history
  • Loading branch information
moreamazingnick committed Aug 24, 2023
1 parent 0d589dc commit 7536bd8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion library/Director/Core/CoreApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -845,17 +845,19 @@ public function dumpConfig(IcingaConfig $config, Db $db, $packageName = null)
// 'username' => Util::getUsername(),
// 'module_name' => $moduleName,
));
$files = $config->getFileContents();

/** @var DeploymentHook[] $hooks */
$hooks = Hook::all('director/Deployment');
foreach ($hooks as $hook) {
$hook->beforeDeploy($deployment);
$files = $hook->beforeDump($files);
}

$this->assertPackageExists($packageName);

$response = $this->client()->post('config/stages/' . \rawurlencode($packageName), [
'files' => $config->getFileContents()
'files' => $files
]);

$duration = (int) ((microtime(true) - $start) * 1000);
Expand Down
11 changes: 11 additions & 0 deletions library/Director/Hook/DeploymentHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ public function beforeDeploy(DirectorDeploymentLog $deployment)
{
}

/**
*
* Please override this method if you want to change the deployed files before writing them to disk
*
* @param $files
* @return array with $files
*/
public function beforeDump($files){
return $files;
}

/**
* Please override this method if you want to trigger custom actions
* on a successful dump of the Icinga configuration
Expand Down

0 comments on commit 7536bd8

Please sign in to comment.