Skip to content

Commit

Permalink
Makefile: implement helper to process OpenShift templates
Browse files Browse the repository at this point in the history
just for manual checks if the template syntax is fine
  • Loading branch information
schuellerf authored and bcl committed May 28, 2024
1 parent 580903f commit d0cff35
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ __pycache__
/tools/appsre-ansible/inventory

/docs/osbuild-composer.7
processed-templates

21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ help:
@echo " unit-tests: Run unit tests"
@echo " push-check: Replicates the github workflow checks as close as possible"
@echo " (do this before pushing!)"
@echo " process-templates: Execute the OpenShift CLI to check the templates"

$(BUILDDIR)/:
mkdir -p "$@"
Expand Down Expand Up @@ -155,6 +156,7 @@ install: build
clean:
rm -rf $(BUILDDIR)/bin/
rm -rf $(CURDIR)/rpmbuild
rm -rf $(BUILDDIR)/$(PROCESSED_TEMPLATE_DIR)

.PHONY: push-check
push-check: build unit-tests srpm man
Expand Down Expand Up @@ -274,3 +276,22 @@ scratch: $(RPM_SPECFILE) $(RPM_TARBALL)
--nocheck \
$(RPM_SPECFILE)

# The OpenShift CLI - maybe get it from https://access.redhat.com/downloads/content/290
OC_EXECUTABLE ?= oc

OPENSHIFT_TEMPLATES_DIR := templates/openshift
OPENSHIFT_TEMPLATES := $(notdir $(wildcard $(OPENSHIFT_TEMPLATES_DIR)/*.yml))

PROCESSED_TEMPLATE_DIR := $(BUILDDIR)/processed-templates

$(PROCESSED_TEMPLATE_DIR): $(BUILDDIR)
mkdir -p $@

$(PROCESSED_TEMPLATE_DIR)/%.yml: $(PROCESSED_TEMPLATE_DIR) $(OPENSHIFT_TEMPLATES_DIR)/%.yml
$(OC_EXECUTABLE) process -f $(OPENSHIFT_TEMPLATES_DIR)/$*.yml \
-p IMAGE_TAG=image_tag \
--local \
-o yaml > $@

.PHONY: process-templates
process-templates: $(addprefix $(PROCESSED_TEMPLATE_DIR)/, $(OPENSHIFT_TEMPLATES))

0 comments on commit d0cff35

Please sign in to comment.