Skip to content

Commit

Permalink
Add script to automatically remove old not used models (#1981)
Browse files Browse the repository at this point in the history
Adds step during the SDK's generate process that will strip out old unused model versions. This prevents the SDK from continually to persist old models.
  • Loading branch information
jasdel authored Jun 8, 2018
1 parent 8e4f1c9 commit 37a3090
Show file tree
Hide file tree
Showing 108 changed files with 14 additions and 159,007 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ help:
@echo " get-deps-tests to get the SDK's test dependencies"
@echo " get-deps-verify to get the SDK's verification dependencies"

generate: gen-test gen-endpoints gen-services
generate: cleanup-models gen-test gen-endpoints gen-services

gen-test: gen-protocol-test

Expand All @@ -49,6 +49,10 @@ gen-protocol-test:
gen-endpoints:
go generate ./models/endpoints/

cleanup-models:
@echo "Cleaning up stale model versions"
@./cleanup_models.sh

build:
@echo "go build SDK and vendor packages"
@go build ${SDK_ONLY_PKGS}
Expand Down
9 changes: 9 additions & 0 deletions cleanup_models.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#/usr/bin/env bash

# Deletes all but the most current model version.
for v in $(ls ./models/apis | grep -v '.go' ); do
for vm in $(ls -r models/apis/$v/ | sed -n '1!p' ); do
echo "rm -r models/apis/$v/$vm"
rm -r models/apis/$v/$vm
done
done
Loading

0 comments on commit 37a3090

Please sign in to comment.