-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add codegen/build-clients.sh
script, update codegen/apis
submodule
#49
Changes from all commits
dd3cf3b
74cac05
b927ace
a5ad3e8
8179289
67323b2
9d75cc0
727580a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
PINECONE_API_KEY="<Project API Key>" | ||
TEST_POD_INDEX_NAME="<Pod based Index name>" | ||
TEST_PODS_INDEX_NAME="<Pod based Index name>" | ||
TEST_SERVERLESS_INDEX_NAME="<Serverless based Index name>" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[submodule "apis"] | ||
path = apis | ||
url = [email protected]:pinecone-io/go-apis.git | ||
[submodule "codegen/apis"] | ||
path = codegen/apis | ||
url = [email protected]:pinecone-io/apis.git | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/bin/bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was modeling this after the work @jhamon had done in other repos, but this diverges a bit in that I'm not using a docker image, and we're doing both OAS and proto files in here. Let me know if this doesn't make sense - or any other feedback. I didn't want to make too many changes to the dependencies we were using to generate code. |
||
|
||
set -eux -o pipefail | ||
|
||
version=$1 # e.g. 2024-07 | ||
|
||
# data_destination must align with the option go_package: | ||
# https://github.com/pinecone-io/apis/blob/e9b47c76f649656002f4911946ca6c4c4a6f04fc/src/release/data/data.proto#L3 | ||
data_destination="internal/gen/data" | ||
control_destination="internal/gen/control" | ||
version_file="internal/gen/api_version.go" | ||
|
||
update_apis_repo() { | ||
echo "Updating apis repo" | ||
pushd codegen/apis | ||
git fetch | ||
git checkout main | ||
git pull | ||
just build | ||
popd | ||
} | ||
|
||
verify_spec_version() { | ||
local version=$1 | ||
echo "Verifying spec version has been provided: $version" | ||
if [ -z "$version" ]; then | ||
echo "Version is required" | ||
exit 1 | ||
fi | ||
Comment on lines
+25
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I should maybe do some actual checking against the folder names under |
||
} | ||
|
||
generate_oas_client() { | ||
oas_file="codegen/apis/_build/${version}/control_${version}.oas.yaml" | ||
|
||
oapi-codegen --package=control \ | ||
--generate types,client \ | ||
"${oas_file}" > "${control_destination}/control_plane.oas.go" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a |
||
} | ||
|
||
generate_proto_client() { | ||
proto_file="codegen/apis/_build/${version}/data_${version}.proto" | ||
|
||
protoc --experimental_allow_proto3_optional \ | ||
--proto_path=codegen/apis/vendor/protos \ | ||
--proto_path=codegen/apis/_build/${version} \ | ||
--go_opt=module="github.com/pinecone-io/go-pinecone" \ | ||
--go-grpc_opt=module="github.com/pinecone-io/go-pinecone" \ | ||
--go_out=. \ | ||
--go-grpc_out=. \ | ||
"${proto_file}" | ||
} | ||
|
||
generate_version_file() { | ||
echo "Generating version file" | ||
cat > "${version_file}" <<EOL | ||
// Code generated by build-clients.sh - DO NOT EDIT. | ||
package gen | ||
|
||
const PineconeApiVersion = "${version}" | ||
EOL | ||
} | ||
|
||
update_apis_repo | ||
verify_spec_version $version | ||
|
||
# Generate control plane client code | ||
rm -rf "${control_destination}" | ||
mkdir -p "${control_destination}" | ||
|
||
generate_oas_client | ||
|
||
# Generate data plane client code | ||
rm -rf "${data_destination}" | ||
mkdir -p "${data_destination}" | ||
|
||
generate_proto_client | ||
|
||
# Generate version file | ||
rm -rf "${version_file}" | ||
|
||
generate_version_file |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ module github.com/pinecone-io/go-pinecone | |
go 1.21 | ||
|
||
require ( | ||
github.com/golang/protobuf v1.5.4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ran There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we should prefer google.golang.org according to https://protobuf.dev/reference/go/faq/. |
||
github.com/google/go-cmp v0.6.0 | ||
github.com/google/uuid v1.6.0 | ||
github.com/oapi-codegen/runtime v1.1.1 | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving to new submodule location, and swapping the underlying repo.