Skip to content

Commit

Permalink
check that osc-api.json seems valide
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Gatto <[email protected]>
  • Loading branch information
outscale-mgo committed Oct 14, 2024
1 parent 5d398bf commit 4abadb2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ help:

include oapi-cli.mk

osc-api.json::
./bin/osc-api-seems-valid.sh osc-api.json "need_remove"

make_cli: $(CLI_NAME) $(CLI_NAME)-completion.bash

bin/funclist: bin/funclist.c
Expand Down
15 changes: 15 additions & 0 deletions bin/osc-api-seems-valid.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# check if $1 is valide, if $2 is present, remove invalide file

test=$(json-search -sn Request $1 | json-search -n properties)
test_ret=$?

if [ "$test_ret" == "1" -o "$test" == "null" ]; then
echo "$1 is invalide" >&2
if [ "$#" -gt 1 ]; then
rm $1
fi
fi


2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ echo JSON_C_CFLAGS=$JSON_C_CFLAGS >> config.mk
echo JSON_C_RULE=$JSON_C_RULE >> config.mk
echo API_VERSION=$API_VERSION >> config.mk
echo CLI_NAME=$CLI_NAME >> config.mk
echo -e "osc-api.json:\n\t$API_SCRIPT" >> config.mk
echo -e "osc-api.json::\n\t$API_SCRIPT" >> config.mk
echo $SDK_VERSION > sdk-version
echo "config done:"
cat config.mk

0 comments on commit 4abadb2

Please sign in to comment.