Skip to content

Commit

Permalink
make sdk generation external pluggable/configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
mjudeikis committed Sep 3, 2024
1 parent a1dc9a3 commit 582c8a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
SHELL := /bin/bash

export API_TAGS ?= ExternalClusterAPI,PoliciesAPI,NodeConfigurationAPI,NodeTemplatesAPI,AuthTokenAPI,ScheduledRebalancingAPI,InventoryAPI,UsersAPI,OperationsAPI,EvictorAPI,SSOAPI,CommitmentsAPI,WorkloadOptimizationAPI
export SWAGGER_LOCATION ?= https://api.cast.ai/v1/spec/openapi.json

default: build

.PHONY: init-examples
Expand All @@ -26,8 +29,8 @@ format-tf:

.PHONY: generate-sdk
generate-sdk:
@echo "==> Generating castai sdk client"
@API_TAGS=ExternalClusterAPI,PoliciesAPI,NodeConfigurationAPI,NodeTemplatesAPI,AuthTokenAPI,ScheduledRebalancingAPI,InventoryAPI,UsersAPI,OperationsAPI,EvictorAPI,SSOAPI,CommitmentsAPI,WorkloadOptimizationAPI go generate castai/sdk/generate.go
echo "==> Generating castai sdk client"
go generate castai/sdk/generate.go

# The following command also rewrites existing documentation
.PHONY: generate-docs
Expand Down
6 changes: 3 additions & 3 deletions castai/sdk/generate.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package sdk

//go:generate echo "generating sdk for: ${API_TAGS}"
//go:generate echo "generating sdk for: ${API_TAGS} from ${SWAGGER_LOCATION}"
//go:generate go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.11.0
//go:generate oapi-codegen -o api.gen.go --old-config-style -generate types -include-tags $API_TAGS -package sdk https://api.cast.ai/v1/spec/openapi.json
//go:generate oapi-codegen -o client.gen.go --old-config-style -templates codegen/templates -generate client -include-tags $API_TAGS -package sdk https://api.cast.ai/v1/spec/openapi.json
//go:generate oapi-codegen -o api.gen.go --old-config-style -generate types -include-tags $API_TAGS -package sdk $SWAGGER_LOCATION
//go:generate oapi-codegen -o client.gen.go --old-config-style -templates codegen/templates -generate client -include-tags $API_TAGS -package sdk $SWAGGER_LOCATION
//go:generate go install github.com/golang/mock/mockgen
//go:generate mockgen -source client.gen.go -destination mock/client.go . ClientInterface

0 comments on commit 582c8a4

Please sign in to comment.