feat: configuration checker for all resources

This commit is contained in:
Andras Bacsai
2024-04-12 12:44:49 +02:00
parent 7b0018b661
commit 7a32b8d1d2
41 changed files with 493 additions and 89 deletions

View File

@@ -43,6 +43,33 @@ class StandaloneMysql extends BaseModel
$database->tags()->detach();
});
}
public function isConfigurationChanged(bool $save = false)
{
$newConfigHash = $this->image . $this->ports_mappings . $this->mysql_conf;
$newConfigHash .= json_encode($this->environment_variables()->get('updated_at'));
$newConfigHash = md5($newConfigHash);
$oldConfigHash = data_get($this, 'config_hash');
if ($oldConfigHash === null) {
if ($save) {
$this->config_hash = $newConfigHash;
$this->save();
}
return true;
}
if ($oldConfigHash === $newConfigHash) {
return false;
} else {
if ($save) {
$this->config_hash = $newConfigHash;
$this->save();
}
return true;
}
}
public function isExited()
{
return (bool) str($this->status)->startsWith('exited');
}
public function workdir()
{
return database_configuration_dir() . "/{$this->uuid}";