Spaces:
Running
Running
File size: 2,024 Bytes
b110593 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
#!/bin/bash
set -eou pipefail
# Version of go-swagger to use.
version=v0.30.4
# Always points to the directory of this script.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SWAGGER=$DIR/swagger-${version}
GOARCH=$(go env GOARCH)
GOOS=$(go env GOOS)
if [ ! -f "$SWAGGER" ]; then
if [ "$GOOS" = "linux" ]; then
curl -o "$SWAGGER" -L'#' https://github.com/go-swagger/go-swagger/releases/download/$version/swagger_"$(echo `uname`|tr '[:upper:]' '[:lower:]')"_"$GOARCH"
else
curl -o "$SWAGGER" -L'#' https://github.com/go-swagger/go-swagger/releases/download/$version/swagger_"$(echo `uname`|tr '[:upper:]' '[:lower:]')"_amd64
fi
chmod +x "$SWAGGER"
fi
# Always install goimports to ensure that all parties use the same version
go install golang.org/x/tools/cmd/[email protected]
# Explicitly get yamplc package
(go get github.com/go-openapi/runtime/[email protected])
# Remove old stuff.
(cd "$DIR"/..; rm -rf entities/models client adapters/handlers/rest/operations/)
(cd "$DIR"/..; $SWAGGER generate server --name=weaviate --model-package=entities/models --server-package=adapters/handlers/rest --spec=openapi-specs/schema.json -P models.Principal --default-scheme=https --struct-tags=yaml --struct-tags=json)
(cd "$DIR"/..; $SWAGGER generate client --name=weaviate --model-package=entities/models --spec=openapi-specs/schema.json -P models.Principal --default-scheme=https)
echo Generate Deprecation code...
(cd "$DIR"/..; GO111MODULE=on go generate ./deprecations)
echo Now add the header to the generated code too.
(cd "$DIR"/..; GO111MODULE=on go run ./tools/license_headers/main.go)
# goimports and exlucde hidden files and proto auto generate files
(cd "$DIR"/..; goimports -w $(find . -type f -name '*.go' -not -name '*pb.go' -not -path './vendor/*' -not -path "./.*/*"))
CHANGED=$(git status -s | wc -l)
if [ "$CHANGED" -gt 0 ]; then
echo "There are changes in the files that need to be committed:"
git status -s
fi
echo Success
|