Skip to content

Commit 9c36f74

Browse files
parthban-dbIsaac
andcommitted
Generate the modular Go SDK's CLI spec in climod with genkit's cli-mod mode
The modular Go SDK's structs carry no JSON tags, and its names differ from the classic SDK names in .codegen/cli.json. task generate-clijson now also runs genkit's cli-mod mode on climod/, which writes climod/.codegen/cli.json: each SDK message with its fields keyed by JSON name, and the Go path to each. Co-authored-by: Isaac <no-reply@databricks.com>
1 parent e7d21a2 commit 9c36f74

4 files changed

Lines changed: 45829 additions & 3 deletions

File tree

‎Taskfile.yml‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -858,10 +858,15 @@ tasks:
858858
# version bumps (go.mod/go.sum) are a manual `go get` step beforehand;
859859
# TestConsistentDatabricksSdkVersion asserts the two stay in sync.
860860
#
861+
# The same run refreshes climod/.codegen/cli.json in genkit's cli-mod mode. It
862+
# describes the modular Go SDK (github.com/databricks/sdk-go), whose names
863+
# differ from the classic SDK's, so it is generated from the Go SDK's own
864+
# proto view rather than from the OpenAPI spec.
865+
#
861866
# No `sources:`/`generates:`: this task deliberately refreshes cli.json from
862867
# an external Universe checkout whenever it is invoked.
863868
generate-clijson:
864-
desc: Produce .codegen/cli.json from its pinned Universe commit via genkit
869+
desc: Produce .codegen/cli.json and climod/.codegen/cli.json from their pinned Universe commit via genkit
865870
vars:
866871
UNIVERSE_DIR:
867872
sh: echo "${UNIVERSE_DIR:-$HOME/universe}"
@@ -898,15 +903,21 @@ tasks:
898903
fi
899904
git -C "$BUILD_DIR/universe" checkout --quiet --detach "$OPENAPI_SHA"
900905
901-
echo "Building genkit and OpenAPI spec at ${OPENAPI_SHA}..."
906+
echo "Building genkit, OpenAPI spec, and Go SDK descriptor set at ${OPENAPI_SHA}..."
902907
cd "$BUILD_DIR/universe"
903-
./tools/bazel build //deco/genkit //openapi:all-internal.json
908+
./tools/bazel build //deco/genkit //openapi:all-internal.json \
909+
//deco/public_proto:public_proto_sdk_go_descriptor_set_with_source_info
904910
905911
echo "Generating CLI code..."
906912
"$BUILD_DIR/universe/bazel-bin/deco/genkit/genkit_/genkit" update-sdk \
907913
--dir "{{.ROOT_DIR}}" \
908914
--openapi-spec-file "$BUILD_DIR/universe/bazel-bin/openapi/all-internal.json" \
909915
--openapi-spec-sha "$OPENAPI_SHA"
916+
917+
echo "Generating the modular Go SDK's CLI spec..."
918+
"$BUILD_DIR/universe/bazel-bin/deco/genkit/genkit_/genkit" experimental-update-sdk \
919+
--dir "{{.ROOT_DIR}}/climod" \
920+
--descriptor-set "$BUILD_DIR/universe/bazel-bin/deco/public_proto/public_proto_sdk_go_with_source_info.pb"
910921
# The SDK-version consistency check runs here for fast feedback when
911922
# generate-clijson is invoked manually. Cleanup of genkit's output is
912923
# delegated to generate-clijson-post so the SDK bumper can reuse it.

‎climod/.codegen.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"mode": "cli-mod"
3+
}

‎climod/.codegen/.gitattributes‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cli.json linguist-generated=true

0 commit comments

Comments
 (0)