Skip to content

Commit

Permalink
Remove generation for swagger Go code and Add static swagger codes fo…
Browse files Browse the repository at this point in the history
…r test (#2757)

Co-authored-by: Mark Mandel <[email protected]>
  • Loading branch information
govargo and markmandel authored Oct 27, 2022
1 parent c86ba5b commit d70793c
Show file tree
Hide file tree
Showing 31 changed files with 3,270 additions and 22 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ run:
# from this option's value:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs:
- test/sdk/restapi

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
Expand Down
5 changes: 5 additions & 0 deletions build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Table of Contents
* [make build-images](#make-build-images)
* [make build-sdks](#make-build-sdks)
* [make build-sdk](#make-build-sdk)
* [make run-sdk-command](#make-run-sdk-command)
* [make run-sdk-conformance-tests](#make-run-sdk-conformance-tests)
* [make clean-sdk-conformance-tests](#make-clean-sdk-conformance-tests)
* [make test](#make-test)
Expand Down Expand Up @@ -480,6 +481,10 @@ Build all the sdks required for Agones
Next command `make build-sdk SDK_FOLDER=[SDK_TYPE]` will build SDK of `SDK_TYPE`.
For instance, in order to build the cpp sdk static and dynamic libraries (linux libraries only) use `SDK_FOLDER=cpp`

#### `make run-sdk-command`
Next command `make run-sdk-command COMMAND=[COMMAND] SDK_FOLDER=[SDK_TYPE]` will execute command for `SDK_TYPE`.
For instance, in order to generate swagger codes when you change swagger.json definition, use `make run-sdk-command COMMAND=gen SDK_FOLDER=restapi`

#### `make run-sdk-conformance-local`
Run Agones sidecar which would wait for all requests from the SDK client.
Note that annotation should contain UID and label should contain CreationTimestamp values to pass the test.
Expand Down
20 changes: 0 additions & 20 deletions build/build-sdk-images/restapi/build-sdk-test.sh

This file was deleted.

2 changes: 0 additions & 2 deletions build/build-sdk-images/restapi/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@
# limitations under the License.

set -ex
rm -rf /go/src/agones.dev/agones/test/sdk/restapi/swagger
rm -rf /go/src/agones.dev/agones/test/sdk/restapi/alpha/swagger
rm /go/src/agones.dev/agones/test/sdk/restapi/http-api-test.go || true
45 changes: 45 additions & 0 deletions build/build-sdk-images/restapi/gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash

# Copyright 2022 Google LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

header() {
cat /go/src/agones.dev/agones/build/boilerplate.go.txt "$1" | sponge "$1"
}

wget -q https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.35/swagger-codegen-cli-3.0.35.jar -O /tmp/swagger-codegen-cli.jar
java -jar /tmp/swagger-codegen-cli.jar generate -i /go/src/agones.dev/agones/sdks/swagger/sdk.swagger.json -l go -o /go/src/agones.dev/agones/test/sdk/restapi/swagger
java -jar /tmp/swagger-codegen-cli.jar generate -i /go/src/agones.dev/agones/sdks/swagger/alpha.swagger.json -l go -o /go/src/agones.dev/agones/test/sdk/restapi/alpha/swagger

# remove un-used files
rm -rf /go/src/agones.dev/agones/test/sdk/restapi/swagger/.*
rm -rf /go/src/agones.dev/agones/test/sdk/restapi/swagger/*.md
rm -rf /go/src/agones.dev/agones/test/sdk/restapi/swagger/*.sh
rm -rf /go/src/agones.dev/agones/test/sdk/restapi/swagger/docs
rm -rf /go/src/agones.dev/agones/test/sdk/restapi/swagger/api
rm -rf /go/src/agones.dev/agones/test/sdk/restapi/alpha/swagger/.*
rm -rf /go/src/agones.dev/agones/test/sdk/restapi/alpha/swagger/*.md
rm -rf /go/src/agones.dev/agones/test/sdk/restapi/alpha/swagger/*.sh
rm -rf /go/src/agones.dev/agones/test/sdk/restapi/alpha/swagger/docs
rm -rf /go/src/agones.dev/agones/test/sdk/restapi/alpha/swagger/api

for file in `ls /go/src/agones.dev/agones/test/sdk/restapi/swagger`
do
header /go/src/agones.dev/agones/test/sdk/restapi/swagger/${file}
done

for alpha in `ls /go/src/agones.dev/agones/test/sdk/restapi/alpha/swagger`
do
header /go/src/agones.dev/agones/test/sdk/restapi/alpha/swagger/${alpha}
done
Loading

0 comments on commit d70793c

Please sign in to comment.