From 1559db6dec31f63b1cebb6ce85dabb513563b9a5 Mon Sep 17 00:00:00 2001 From: houkms <52267283+houkms@users.noreply.github.com> Date: Mon, 5 Aug 2019 16:10:40 +0800 Subject: [PATCH] Fix resource listing script (#97) * fix resource listing script * code refined --- Makefile | 4 ++-- list_resources.sh | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 list_resources.sh diff --git a/Makefile b/Makefile index f2dc11c..f289a28 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ build-terraform: @if [ -z "$(RESOURCE)" ]; then \ echo "==> Generating source code for terraform from resource list..."; \ cd $(MMROOT) && \ - jq '.[]' $(ROOT)/resources.json | xargs -I '{}' bundle exec compiler -d -p $(SPECROOT)/'{}' -e terraform -c azure -o $(TFROOT)/$(TFREPO)/; \ + sh $(ROOT)/list_resources.sh | xargs -I '{}' bundle exec compiler -d -p $(SPECROOT)/'{}' -e terraform -c azure -o $(TFROOT)/$(TFREPO)/; \ else \ echo "==> Generating source code for terraform from given name..."; \ cd $(MMROOT) && \ @@ -71,7 +71,7 @@ build-ansible: @if [ -z "$(RESOURCE)" ]; then \ echo "==> Generating source code for ansible from resource list..."; \ cd $(MMROOT) && \ - jq '.[]' $(ROOT)/resources.json | xargs -I '{}' bundle exec compiler -d -p $(SPECROOT)/'{}' -e ansible -c azure -o $(GENROOT)/$(ASREPO)/; \ + sh $(ROOT)/list_resources.sh | xargs -I '{}' bundle exec compiler -d -p $(SPECROOT)/'{}' -e ansible -c azure -o $(GENROOT)/$(ASREPO)/; \ else \ echo "==> Generating source code for ansible from given name..."; \ cd $(MMROOT) && \ diff --git a/list_resources.sh b/list_resources.sh new file mode 100644 index 0000000..a2f4d5b --- /dev/null +++ b/list_resources.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +cd `dirname $0` +for file in `ls ./specs`; do + work_dir=./specs/$file + if [ -d $work_dir ]; then + if [ -n "$(git status -s $work_dir)" ]; + then + # remove the directory prefix './specs/' + expr substr "$work_dir" 9 "${#work_dir}" + fi + fi +done