Skip to content

Commit

Permalink
Dockerize code generation
Browse files Browse the repository at this point in the history
- Added a docker-compose spec that uses an openapitools image for codegen
- Reran client gen, which added a missing file for the alternate AddAllowListEntry binding
- Renamed 'ccloud' dir to 'openapi-generator'
  • Loading branch information
erademacher committed Oct 6, 2022
1 parent 0133736 commit f84bc0c
Show file tree
Hide file tree
Showing 9 changed files with 522 additions and 233 deletions.
19 changes: 12 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
.PHONY: generate-openapi-client
generate-openapi-client:
rm -rf ./pkg/client/*.go docs
openapi-generator generate -g go -i internal/spec/swagger.json -o internal/ccloud \
-c internal/spec/config.yaml -t internal/spec
mv internal/ccloud/docs ./
mv internal/ccloud/*.md ./docs/
mv ./internal/ccloud/api_cockroach_cloud.go ./internal/ccloud/service.go
go fmt ./internal/ccloud/...
mv ./internal/ccloud/*.go pkg/client/
docker-compose -f ./docker-compose.yml run --rm \
openapi-generator generate \
-g go \
-i internal/spec/swagger.json \
-o internal/openapi-generator \
-c internal/spec/config.yaml \
-t internal/spec
mv internal/openapi-generator/docs ./
mv internal/openapi-generator/*.md ./docs/
mv ./internal/openapi-generator/api_cockroach_cloud.go ./internal/openapi-generator/service.go
go fmt ./internal/openapi-generator/...
mv ./internal/openapi-generator/*.go pkg/client/
@$(MAKE) add-boilerplate

# Add boilerplate header to all pkg golang files.
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3'

services:
openapi-generator:
image: openapitools/openapi-generator-cli:v6.2.0
volumes:
- ./:/go/src/github.com/cockroachdb/cockroach-cloud-sdk-go
working_dir: /go/src/github.com/cockroachdb/cockroach-cloud-sdk-go
1 change: 0 additions & 1 deletion internal/ccloud/.openapi-generator/VERSION

This file was deleted.

File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions internal/openapi-generator/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.2.0

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/spec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Install `openapi-generator`.
- `brew install openapi-generator`
- [OpenAPI Generator doc: Installation](https://openapi-generator.tech/docs/installation/)

Do not delete [.openapi-generator-ignore](../ccloud/.openapi-generator-ignore)! It prevents certain files from being generated.
Do not delete [.openapi-generator-ignore](../openapi-generator/.openapi-generator-ignore)! It prevents certain files from being generated.

To regenerate the ccloud Go API Client code using the files in this directory, use `make generate-openapi-client`.
The `openapi-generator` cli can also be used like:
Expand Down
134 changes: 134 additions & 0 deletions pkg/client/model_allowlist_entry_1.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f84bc0c

Please sign in to comment.