Skip to content

Commit

Permalink
implement Makefile script to generate api types
Browse files Browse the repository at this point in the history
  • Loading branch information
ca7alindev committed Jun 11, 2024
1 parent 41c7316 commit c5477c3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
16 changes: 1 addition & 15 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,7 @@ jobs:
run: make submodules

- name: Process swagger.json
run: |
#!/bin/bash
JSON_FILE="scheme.json"
if [ ! -f "$JSON_FILE" ]; then
echo "File $JSON_FILE does not exist."
exit 1
fi
path_keys=$(jq -r '.paths | keys[]' "$JSON_FILE" | grep -v '{')
for path in $path_keys; do
provider_name="magento.web7.md"
version=$(echo "$path" | awk -F/ '{print $2}')
type=$(echo "$path" | awk -F/ '{print $NF}')
type=$(echo "${type^}")
make provider.addtype provider=${provider_name} group=${version} kind=${type}
done
run: make process.scheme

- name: Install crossplane CLI
id: crossplane
Expand Down
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,20 @@ crossplane.help:
help-special: crossplane.help

.PHONY: crossplane.help help-special

JSON_FILE := scheme.json
check_file:
@if [ ! -f $(JSON_FILE) ]; then \
echo "File $(JSON_FILE) does not exist."; \
exit 1; \
fi
# Extract path keys and process them
process.scheme: check_file
@path_keys=$$(jq -r '.paths | keys[]' $(JSON_FILE) | grep -v '{'); \
for path in $$path_keys; do \
provider_name="magento.web7.md"; \
version=$$(echo "$$path" | awk -F/ '{print tolower($$2)}'); \
type=$$(echo "$$path" | awk -F/ '{print $$NF}'); \
type=$$(echo "$$type" | awk '{print toupper(substr($$0,1,1))tolower(substr($$0,2))}'); \
$(MAKE) provider.addtype provider=$$provider_name group=$$type kind=$$type apiversion=$$version; \
done

0 comments on commit c5477c3

Please sign in to comment.