Skip to content

Commit 2dffc9e

Browse files
dimakisFiona-Waters
authored andcommitted
refactor: isntall yq if not exists
1 parent 81400ae commit 2dffc9e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,16 @@ FILE ?= input.yaml # Default value, it isn't a file, but the make cmds fill han
394394
temp_dir := temp_split
395395
output_dir := 'config/crd/'
396396

397+
.PHONY: check_yq
398+
check_yq:
399+
@command -v yq >/dev/null 2>&1 || (echo "Installing wget..."; yum install -y wget)
400+
@command -v yq >/dev/null 2>&1 || (echo "Installing yq..."; wget https://github.com/mikefarah/yq/releases/download/v4.2.0/yq_linux_amd64.tar.gz -O - |\
401+
tar xz && mv yq_linux_amd64 /usr/bin/yq)
402+
397403
# this works on a MacOS by replacing awk with gawk
398404
.PHONY: split_yaml
399405
split_yaml:
406+
@$(MAKE) check_yq
400407
@mkdir -p $(temp_dir)
401408
@awk '/apiVersion: /{if (x>0) close("$(temp_dir)/section_" x ".yaml"); x++}{print > "$(temp_dir)/section_"x".yaml"}' $(FILE)
402409
@$(MAKE) process_sections
@@ -409,4 +416,4 @@ process_sections:
409416
file_name=$$(echo $$metadata_name | awk -F'.' '{print $$2"."$$3"_"$$1".yaml"}'); \
410417
mv $$section_file $(output_dir)/$$file_name; \
411418
done
412-
@rm -r $(temp_dir)
419+
@rm -r $(temp_dir)

0 commit comments

Comments
 (0)