From 50cb605cf9d3f305f63cd6392762b3a97a6f8dfb Mon Sep 17 00:00:00 2001 From: Yuan Gong Date: Tue, 9 Feb 2021 09:06:31 +0000 Subject: [PATCH] fixed generate_api.sh --- backend/api/BUILD.bazel | 7 +++ backend/api/auth.proto | 1 - backend/api/generate_api.sh | 19 ++++--- backend/api/go_client/auth.pb.go | 72 +++++++++++++-------------- backend/api/swagger/auth.swagger.json | 35 +------------ 5 files changed, 57 insertions(+), 77 deletions(-) diff --git a/backend/api/BUILD.bazel b/backend/api/BUILD.bazel index e04eb250ad6..8694833fb7c 100644 --- a/backend/api/BUILD.bazel +++ b/backend/api/BUILD.bazel @@ -44,6 +44,13 @@ go_proto_library( ], ) +go_library( + name = "go_default_library", + embed = [":go_client_go_proto"], + importpath = "github.com/kubeflow/pipelines/backend/api/go_client", + visibility = ["//visibility:public"], +) + protoc_gen_swagger( name = "api_swagger", proto = ":go_client_proto", diff --git a/backend/api/auth.proto b/backend/api/auth.proto index 28a27b3aa43..692fef5ff84 100644 --- a/backend/api/auth.proto +++ b/backend/api/auth.proto @@ -19,7 +19,6 @@ package api; import "google/api/annotations.proto"; import "google/protobuf/empty.proto"; -import "backend/api/error.proto"; import "protoc-gen-swagger/options/annotations.proto"; option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = { diff --git a/backend/api/generate_api.sh b/backend/api/generate_api.sh index bb464efa356..d8a82bc52a7 100755 --- a/backend/api/generate_api.sh +++ b/backend/api/generate_api.sh @@ -28,16 +28,11 @@ if [ -z "$VERSION" ]; then echo "ERROR: $REPO_ROOT/VERSION is empty" exit 1 fi +TMP_DIR="$(mktemp -d)" BAZEL_BINDIR=$(bazel info bazel-bin) GENERATED_GO_PROTO_FILES="${BAZEL_BINDIR}/backend/api/api_generated_go_sources/src/github.com/kubeflow/pipelines/backend/api/go_client/*.go" -# Reference: https://goswagger.io/install.html -SWAGGER_GO_VERSION=v0.18.0 -SWAGGER_GO_IMAGE="quay.io/goswagger/swagger:${SWAGGER_GO_VERSION}" -docker pull "${SWAGGER_GO_IMAGE}" -SWAGGER_CMD="docker run --rm -it --user $(id -u):$(id -g) -e GOPATH=$HOME/go:/go -v $HOME:$HOME -w $(pwd) ${SWAGGER_GO_IMAGE}" - # TODO this script should be able to be run from anywhere, not just within .../backend/api/ # Delete currently generated code. @@ -47,6 +42,8 @@ rm -r -f ${DIR}/go_client/* # Build .pb.go and .gw.pb.go files from the proto sources. bazel build //backend/api:api_generated_go_sources +mkdir -p ${DIR}/go_client + # Copy the generated files into the source tree and add license. for f in $GENERATED_GO_PROTO_FILES; do target=${DIR}/go_client/$(basename ${f}) @@ -67,6 +64,16 @@ jq -s ' .info.license = { "name": "Apache 2.0", "url": "https://raw.githubusercontent.com/kubeflow/pipelines/master/LICENSE" } ' ${DIR}/swagger/{run,job,pipeline,experiment,pipeline.upload,healthz}.swagger.json > "${DIR}/swagger/kfp_api_single_file.swagger.json" +# Reference: https://goswagger.io/install.html +SWAGGER_GO_VERSION=v0.18.0 +pushd "${TMP_DIR}" +curl -LO "https://github.com/go-swagger/go-swagger/releases/download/${SWAGGER_GO_VERSION}/swagger_linux_amd64" +chmod +x swagger_linux_amd64 +SWAGGER_CMD="${TMP_DIR}/swagger_linux_amd64" +popd + +mkdir -p ${DIR}/go_http_client + # Generate Go HTTP client from the swagger files. ${SWAGGER_CMD} generate client \ -f ${DIR}/swagger/job.swagger.json \ diff --git a/backend/api/go_client/auth.pb.go b/backend/api/go_client/auth.pb.go index c2e63c1aa2e..2aecdd88295 100755 --- a/backend/api/go_client/auth.pb.go +++ b/backend/api/go_client/auth.pb.go @@ -46,7 +46,7 @@ func (x AuthorizeRequest_Resources) String() string { return proto.EnumName(AuthorizeRequest_Resources_name, int32(x)) } func (AuthorizeRequest_Resources) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_auth_b463ef3269931e86, []int{0, 0} + return fileDescriptor_auth_ddacc12b605d8d52, []int{0, 0} } type AuthorizeRequest_Verb int32 @@ -75,7 +75,7 @@ func (x AuthorizeRequest_Verb) String() string { return proto.EnumName(AuthorizeRequest_Verb_name, int32(x)) } func (AuthorizeRequest_Verb) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_auth_b463ef3269931e86, []int{0, 1} + return fileDescriptor_auth_ddacc12b605d8d52, []int{0, 1} } type AuthorizeRequest struct { @@ -91,7 +91,7 @@ func (m *AuthorizeRequest) Reset() { *m = AuthorizeRequest{} } func (m *AuthorizeRequest) String() string { return proto.CompactTextString(m) } func (*AuthorizeRequest) ProtoMessage() {} func (*AuthorizeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_auth_b463ef3269931e86, []int{0} + return fileDescriptor_auth_ddacc12b605d8d52, []int{0} } func (m *AuthorizeRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_AuthorizeRequest.Unmarshal(m, b) @@ -210,37 +210,37 @@ var _AuthService_serviceDesc = grpc.ServiceDesc{ Metadata: "backend/api/auth.proto", } -func init() { proto.RegisterFile("backend/api/auth.proto", fileDescriptor_auth_b463ef3269931e86) } - -var fileDescriptor_auth_b463ef3269931e86 = []byte{ - // 460 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0xc1, 0x6e, 0xd3, 0x40, - 0x14, 0x8c, 0x9d, 0x2a, 0xc1, 0x2f, 0x94, 0x9a, 0x6d, 0x29, 0x91, 0x09, 0x6a, 0x94, 0x53, 0x0f, - 0xd4, 0x56, 0xd3, 0x2b, 0x1c, 0x92, 0x76, 0x55, 0x55, 0x82, 0x22, 0xad, 0xd3, 0x20, 0xf5, 0x52, - 0xad, 0xdd, 0x17, 0x67, 0x55, 0xc7, 0x6b, 0xd6, 0xeb, 0x54, 0x70, 0x44, 0xe2, 0x03, 0x80, 0x4f, - 0xe3, 0x17, 0xf8, 0x10, 0xe4, 0x4d, 0x9a, 0x46, 0x90, 0xd3, 0x6a, 0xdf, 0xcc, 0x9b, 0x19, 0x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, 0x9f, 0xfc, 0x0d, - 0x00, 0x00, 0xff, 0xff, 0x8e, 0x47, 0x2d, 0x41, 0xaa, 0x02, 0x00, 0x00, +func init() { proto.RegisterFile("backend/api/auth.proto", fileDescriptor_auth_ddacc12b605d8d52) } + +var fileDescriptor_auth_ddacc12b605d8d52 = []byte{ + // 453 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xc1, 0x4e, 0xdb, 0x40, + 0x10, 0x86, 0x63, 0x07, 0x25, 0xcd, 0xa4, 0x14, 0x77, 0xa1, 0x28, 0x72, 0x53, 0x11, 0xe5, 0xc4, + 0xa1, 0xd8, 0x22, 0x5c, 0xdb, 0x43, 0x02, 0x2b, 0x84, 0xd4, 0x52, 0x69, 0x1d, 0x52, 0x89, 0x0b, + 0x5a, 0x9b, 0x89, 0xb3, 0xc2, 0xf1, 0xba, 0xeb, 0xdd, 0xa0, 0xf6, 0x58, 0xa9, 0x0f, 0xd0, 0xf6, + 0xd1, 0xfa, 0x0a, 0x7d, 0x90, 0xca, 0x9b, 0x10, 0x50, 0xe1, 0x64, 0x79, 0xe6, 0xff, 0xff, 0xf9, + 0xa5, 0x6f, 0x61, 0x37, 0xe6, 0xc9, 0x0d, 0xe6, 0xd7, 0x21, 0x2f, 0x44, 0xc8, 0x8d, 0x9e, 0x05, + 0x85, 0x92, 0x5a, 0x92, 0x3a, 0x2f, 0x84, 0xdf, 0x4d, 0xa5, 0x4c, 0x33, 0x5c, 0xee, 0xf2, 0x5c, + 0x6a, 0xae, 0x85, 0xcc, 0xcb, 0xa5, 0xc4, 0x7f, 0xbd, 0xda, 0xda, 0xbf, 0xd8, 0x4c, 0x43, 0x9c, + 0x17, 0xfa, 0xeb, 0x6a, 0xf9, 0xd6, 0x7e, 0x92, 0x83, 0x14, 0xf3, 0x83, 0xf2, 0x96, 0xa7, 0x29, + 0xaa, 0x50, 0x16, 0xd6, 0x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, 0xff, 0xfb, 0x9f, 0xbf, + 0xbf, 0xdd, 0x1d, 0x42, 0x2a, 0x92, 0x65, 0xb8, 0x38, 0x8c, 0x51, 0xf3, 0x43, 0x8b, 0x7b, 0xf4, + 0xc3, 0xf9, 0x35, 0xfc, 0xc8, 0xba, 0xd0, 0xbc, 0xc6, 0x29, 0x37, 0x99, 0x26, 0x2f, 0xc9, 0x16, + 0x6c, 0xfa, 0x6d, 0x7b, 0x21, 0xd2, 0x5c, 0x9b, 0xf2, 0x72, 0x0f, 0xde, 0x40, 0x63, 0x84, 0x5c, + 0xa1, 0x22, 0xdb, 0xcf, 0x5c, 0x7f, 0x93, 0xaf, 0x2e, 0x5b, 0x88, 0x3d, 0x37, 0x7e, 0x0e, 0xb0, + 0x16, 0xd4, 0x2e, 0x8f, 0x52, 0xa1, 0x67, 0x26, 0x0e, 0x12, 0x39, 0x0f, 0x6f, 0x4c, 0x8c, 0xd3, + 0x4c, 0xde, 0x86, 0x85, 0x28, 0x30, 0x13, 0x39, 0x96, 0xe1, 0xc3, 0x17, 0x97, 0xca, 0xab, 0x24, + 0x13, 0x98, 0xeb, 0xb8, 0x61, 0x3b, 0x1f, 0xfd, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x98, 0xcf, 0xb4, + 0xb0, 0x91, 0x02, 0x00, 0x00, } diff --git a/backend/api/swagger/auth.swagger.json b/backend/api/swagger/auth.swagger.json index 5b8e5beb0e6..470c6390a1e 100755 --- a/backend/api/swagger/auth.swagger.json +++ b/backend/api/swagger/auth.swagger.json @@ -28,7 +28,7 @@ "default": { "description": "", "schema": { - "$ref": "#/definitions/apiStatus" + "$ref": ".api.Status" } } }, @@ -90,39 +90,6 @@ ], "default": "UNASSIGNED_VERB", "description": "Type of verbs that act on the resources." - }, - "apiStatus": { - "type": "object", - "properties": { - "error": { - "type": "string" - }, - "code": { - "type": "integer", - "format": "int32" - }, - "details": { - "type": "array", - "items": { - "$ref": "#/definitions/protobufAny" - } - } - } - }, - "protobufAny": { - "type": "object", - "properties": { - "type_url": { - "type": "string", - "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." - }, - "value": { - "type": "string", - "format": "byte", - "description": "Must be a valid serialized protocol buffer of the above specified type." - } - }, - "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := ptypes.MarshalAny(foo)\n ...\n foo := \u0026pb.Foo{}\n if err := ptypes.UnmarshalAny(any, foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" } }, "securityDefinitions": {