From fb0954b4dd2daa0b0ef8bf80818b1c7f059795b4 Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Mon, 21 Mar 2022 01:00:00 +0100 Subject: [PATCH] Implemented fresh configuration loader * Fresh can now identify and load freshdocker.conf config files --- CHANGES | 2 +- README.md | 9 +++++++++ src/Refresher.php | 25 +++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 7d409c4..3e1fc4d 100644 --- a/CHANGES +++ b/CHANGES @@ -26,4 +26,4 @@ - Added option `--state` to override the state file name. - Renamed the lock file from `fresh.lock` to `.fresh.lock`. - Added option `--lockfile` to override lockfile file name. - +- Implemented the fresh configuration loader. diff --git a/README.md b/README.md index 5717e28..5b6542a 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,15 @@ Check a specific image: $ fresh.phar --image my.private.repo/name/package:latest --check -w $ 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. Some of the options can be read from environment variables, for example `FRESH_AFER` diff --git a/src/Refresher.php b/src/Refresher.php index e18f1e8..8dc7bc0 100644 --- a/src/Refresher.php +++ b/src/Refresher.php @@ -297,12 +297,37 @@ class Refresher $this->config = new ComposeConfiguration($configFile); 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 { if (file_exists($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"); 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; case 'compose':