mirror of
https://github.com/coollabsio/coolify.git
synced 2026-09-26 17:30:46 -04:00
fix(service): write compose .env files atomically via temp rename
Replace direct .env overwrite with a unique temp file and mv so a partial write cannot leave a truncated environment file on disk.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
it('publishes the service environment file atomically', function () {
|
||||
$source = file_get_contents(__DIR__.'/../../app/Models/Service.php');
|
||||
$methodStart = strpos($source, 'public function saveComposeConfigs()');
|
||||
$methodEnd = strpos($source, 'public function parse(', $methodStart);
|
||||
$method = substr($source, $methodStart, $methodEnd - $methodStart);
|
||||
|
||||
expect($method)
|
||||
->not->toContain("'rm -f .env || true'")
|
||||
->toContain("new_public_id().'.env.tmp'")
|
||||
->toContain('tee {$environmentFilename} > /dev/null && mv {$environmentFilename} .env')
|
||||
->toContain('touch {$environmentFilename} && mv {$environmentFilename} .env');
|
||||
});
|
||||
Reference in New Issue
Block a user