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
and align with the github action to use the same code
  • Loading branch information
schuellerf committed Aug 2, 2024
1 parent 1d0232f commit 0a68fe3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,7 @@ jobs:
- uses: redhat-actions/oc-installer@v1
- name: Process template
run: |
mkdir processed-templates
oc process -f templates/openshift/composer.yml \
-p IMAGE_TAG=image_tag \
--local \
-o yaml > processed-templates/composer.yml
oc process -f templates/openshift/maintenance.yml \
-p IMAGE_TAG=image_tag \
--local \
-o yaml > processed-templates/maintenance.yml
make process-templates
- uses: stackrox/kube-linter-action@v1.0.5
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ __pycache__
/docs/osbuild-composer.7
.cache
container_composer_golangci_built.info
processed-templates

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

$(BUILDDIR)/:
mkdir -p "$@"
Expand Down Expand Up @@ -166,6 +167,7 @@ clean:
rm -rf $(BUILDDIR)/bin/
rm -rf $(CURDIR)/rpmbuild
rm -rf container_composer_golangci_built.info
rm -rf $(BUILDDIR)/$(PROCESSED_TEMPLATE_DIR)

.PHONY: push-check
push-check: lint build unit-tests srpm man
Expand Down Expand Up @@ -293,3 +295,24 @@ container_composer_golangci_built.info: Makefile Containerfile_golangci_lint too
.PHONY: lint
lint: $(GOLANGCI_LINT_CACHE_DIR) container_composer_golangci_built.info
podman run -t --rm -v $(SRCDIR):/app:z -v $(GOLANGCI_LINT_CACHE_DIR):/root/.cache:z -w /app $(GOLANGCI_COMPOSER_IMAGE) golangci-lint run -v

# 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 0a68fe3

Please sign in to comment.