From ea99d5bc53dccb9fd20694bc93413ab3161ebbca Mon Sep 17 00:00:00 2001
From: Sheogorath <sheogorath@shivering-isles.com>
Date: Sun, 10 Oct 2021 03:26:03 +0200
Subject: [PATCH] cli: Add build-if-not-exists command

This patch allows to optionally build the koolbox container on install
if it isn't already present on the system. This should make the usage as
part of the uplevel CLI easier.
---
 cli/Makefile | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cli/Makefile b/cli/Makefile
index e6ea78236..9658f79bd 100644
--- a/cli/Makefile
+++ b/cli/Makefile
@@ -14,13 +14,17 @@ preflight:
 	command -v podman > /dev/null
 
 .PHONY: install
-install: preflight ## Install koolbox, the Kubernetes Toolbox for SI-Infrastructure
+install: preflight build-if-not-exists ## Install koolbox, the Kubernetes Toolbox for SI-Infrastructure
 	install -m 755 ./koolbox ~/bin/koolbox
 
 .PHONY: build
 build: preflight ## Build container locally instead of using one from upstream
 	podman build -t $(KOOLBOX_IMAGE) .
 
+.PHONY: build-if-not-exists
+build-if-not-exists: preflight
+	podman image exists $(KOOLBOX_IMAGE) || make build
+
 .PHONY: config
 config: ## Edit your koolbox environment config
 	${EDITOR} "${XDG_CONFIG_HOME}/koolbox/env"
-- 
GitLab