Implemented fresh configuration loader

* Fresh can now identify and load freshdocker.conf config files
This commit is contained in:
Chris 2022-03-21 01:00:00 +01:00
parent 214db1cee3
commit fb0954b4dd
3 changed files with 35 additions and 1 deletions

View File

@ -26,4 +26,4 @@
- Added option `--state` to override the state file name. - Added option `--state` to override the state file name.
- Renamed the lock file from `fresh.lock` to `.fresh.lock`. - Renamed the lock file from `fresh.lock` to `.fresh.lock`.
- Added option `--lockfile` to override lockfile file name. - Added option `--lockfile` to override lockfile file name.
- Implemented the fresh configuration loader.

View File

@ -53,6 +53,15 @@ Check a specific image:
$ fresh.phar --image my.private.repo/name/package:latest --check -w $ fresh.phar --image my.private.repo/name/package:latest --check -w
$ echo $? # if 1, a newer version is available $ echo $? # if 1, a newer version is available
Check images defined in a custom configuration file:
$ cat freshdocker.conf
check:
- docker.hub.varametall.se/vara/varaprod-4:latest
$ bin/freshdocker -C fresh --check -v
# ..or..
$ bin/freshdocker -c freshdocker.conf --check -v
For all available options, use the `--help` flag. For all available options, use the `--help` flag.
Some of the options can be read from environment variables, for example `FRESH_AFER` Some of the options can be read from environment variables, for example `FRESH_AFER`

View File

@ -297,12 +297,37 @@ class Refresher
$this->config = new ComposeConfiguration($configFile); $this->config = new ComposeConfiguration($configFile);
return; return;
} }
if (basename($configFile) == "freshdocker.conf") {
$this->log->append("Using configuration file ".$this->path."/freshdocker.conf");
$this->config = new LocalConfiguration($this->path."/freshdocker.conf");
return;
}
} else { } else {
if (file_exists($this->path."/docker-compose.yml")) { if (file_exists($this->path."/docker-compose.yml")) {
$this->log->append("Using configuration file ".$this->path."/docker-compose.yml"); $this->log->append("Using configuration file ".$this->path."/docker-compose.yml");
$this->config = new ComposeConfiguration($this->path."/docker-compose.yml"); $this->config = new ComposeConfiguration($this->path."/docker-compose.yml");
return; return;
} }
if (file_exists($this->path."/freshdocker.conf")) {
$this->log->append("Using configuration file ".$this->path."/freshdocker.conf");
$this->config = new LocalConfiguration($this->path."/freshdocker.conf");
return;
}
}
break;
case 'fresh':
if ($configFile) {
if (basename($configFile) == "freshdocker.confl") {
$this->log->append("Using configuration file ".$configFile);
$this->config = new LocalConfiguration($configFile);
return;
}
} else {
if (file_exists($this->path."/freshdocker.conf")) {
$this->log->append("Using configuration file ".$this->path."/freshdocker.conf");
$this->config = new LocalConfiguration($this->path."/freshdocker.conf");
return;
}
} }
break; break;
case 'compose': case 'compose':