├── .gitignore ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── api ├── git │ ├── repo.pb.go │ ├── repo.proto │ ├── repo_grpc.pb.go │ ├── repo_http.pb.go │ ├── user.pb.go │ ├── user.proto │ ├── user_grpc.pb.go │ └── user_http.pb.go └── helloworld │ └── v1 │ ├── error_reason.pb.go │ ├── error_reason.proto │ ├── greeter.pb.go │ ├── greeter.proto │ ├── greeter_grpc.pb.go │ └── greeter_http.pb.go ├── cmd └── kratos-gorm-git │ ├── main.go │ ├── wire.go │ └── wire_gen.go ├── configs └── config.yaml ├── define └── define.go ├── go.mod ├── go.sum ├── helper └── helper.go ├── internal ├── biz │ ├── README.md │ ├── biz.go │ └── greeter.go ├── conf │ ├── conf.pb.go │ └── conf.proto ├── data │ ├── README.md │ ├── data.go │ └── greeter.go ├── server │ ├── grpc.go │ ├── http.go │ └── server.go └── service │ ├── README.md │ ├── git.go │ ├── greeter.go │ ├── repo.go │ ├── service.go │ └── user.go ├── middleware └── auth.go ├── models ├── init.go ├── repo_basic.go ├── repo_star.go ├── repo_user.go └── user_basic.go ├── openapi.yaml └── third_party ├── README.md ├── errors └── errors.proto ├── google ├── api │ ├── annotations.proto │ ├── client.proto │ ├── field_behavior.proto │ ├── http.proto │ └── httpbody.proto └── protobuf │ ├── any.proto │ ├── api.proto │ ├── compiler │ └── plugin.proto │ ├── descriptor.proto │ ├── duration.proto │ ├── empty.proto │ ├── field_mask.proto │ ├── source_context.proto │ ├── struct.proto │ ├── timestamp.proto │ ├── type.proto │ └── wrappers.proto ├── openapi └── v3 │ ├── annotations.proto │ └── openapi.proto └── validate ├── README.md └── validate.proto /.gitignore: -------------------------------------------------------------------------------- 1 | # Reference https://github.com/github/gitignore/blob/master/Go.gitignore 2 | # Binaries for programs and plugins 3 | *.exe 4 | *.exe~ 5 | *.dll 6 | *.dylib 7 | 8 | # Test binary, built with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | 14 | # Dependency directories (remove the comment below to include it) 15 | vendor/ 16 | 17 | # Go workspace file 18 | go.work 19 | 20 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 21 | *.o 22 | *.a 23 | *.so 24 | 25 | # OS General 26 | Thumbs.db 27 | .DS_Store 28 | 29 | # project 30 | *.cert 31 | *.key 32 | *.log 33 | bin/ 34 | 35 | # Develop tools 36 | .vscode/ 37 | .idea/ 38 | *.swp 39 | repo/ 40 | 41 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.16 AS builder 2 | 3 | COPY . /src 4 | WORKDIR /src 5 | 6 | RUN GOPROXY=https://goproxy.cn make build 7 | 8 | FROM debian:stable-slim 9 | 10 | RUN apt-get update && apt-get install -y --no-install-recommends \ 11 | ca-certificates \ 12 | netbase \ 13 | && rm -rf /var/lib/apt/lists/ \ 14 | && apt-get autoremove -y && apt-get autoclean -y 15 | 16 | COPY --from=builder /src/bin /app 17 | 18 | WORKDIR /app 19 | 20 | EXPOSE 8000 21 | EXPOSE 9000 22 | VOLUME /data/conf 23 | 24 | CMD ["./server", "-conf", "/data/conf"] 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 go-kratos 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | GOHOSTOS:=$(shell go env GOHOSTOS) 2 | GOPATH:=$(shell go env GOPATH) 3 | VERSION=$(shell git describe --tags --always) 4 | 5 | ifeq ($(GOHOSTOS), windows) 6 | #the `find.exe` is different from `find` in bash/shell. 7 | #to see https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/find. 8 | #changed to use git-bash.exe to run find cli or other cli friendly, caused of every developer has a Git. 9 | #Git_Bash= $(subst cmd\,bin\bash.exe,$(dir $(shell where git))) 10 | Git_Bash=$(subst \,/,$(subst cmd\,bin\bash.exe,$(dir $(shell where git)))) 11 | INTERNAL_PROTO_FILES=$(shell $(Git_Bash) -c "find internal -name *.proto") 12 | API_PROTO_FILES=$(shell $(Git_Bash) -c "find api -name *.proto") 13 | else 14 | INTERNAL_PROTO_FILES=$(shell find internal -name *.proto) 15 | API_PROTO_FILES=$(shell find api -name *.proto) 16 | endif 17 | 18 | .PHONY: init 19 | # init env 20 | init: 21 | go install google.golang.org/protobuf/cmd/protoc-gen-go@latest 22 | go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest 23 | go install github.com/go-kratos/kratos/cmd/kratos/v2@latest 24 | go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@latest 25 | go install github.com/google/gnostic/cmd/protoc-gen-openapi@latest 26 | go install github.com/google/wire/cmd/wire@latest 27 | 28 | .PHONY: config 29 | # generate internal proto 30 | config: 31 | protoc --proto_path=./internal \ 32 | --proto_path=./third_party \ 33 | --go_out=paths=source_relative:./internal \ 34 | $(INTERNAL_PROTO_FILES) 35 | 36 | .PHONY: api 37 | # generate api proto 38 | api: 39 | protoc --proto_path=./api \ 40 | --proto_path=./third_party \ 41 | --go_out=paths=source_relative:./api \ 42 | --go-http_out=paths=source_relative:./api \ 43 | --go-grpc_out=paths=source_relative:./api \ 44 | --openapi_out=fq_schema_naming=true,default_response=false:. \ 45 | $(API_PROTO_FILES) 46 | 47 | .PHONY: build 48 | # build 49 | build: 50 | mkdir -p bin/ && go build -ldflags "-X main.Version=$(VERSION)" -o ./bin/ ./... 51 | 52 | .PHONY: generate 53 | # generate 54 | generate: 55 | go mod tidy 56 | go get github.com/google/wire/cmd/wire@latest 57 | go generate ./... 58 | 59 | .PHONY: all 60 | # generate all 61 | all: 62 | make api; 63 | make config; 64 | make generate; 65 | 66 | # show help 67 | help: 68 | @echo '' 69 | @echo 'Usage:' 70 | @echo ' make [target]' 71 | @echo '' 72 | @echo 'Targets:' 73 | @awk '/^[a-zA-Z\-\_0-9]+:/ { \ 74 | helpMessage = match(lastLine, /^# (.*)/); \ 75 | if (helpMessage) { \ 76 | helpCommand = substr($$1, 0, index($$1, ":")-1); \ 77 | helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \ 78 | printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \ 79 | } \ 80 | } \ 81 | { lastLine = $$0 }' $(MAKEFILE_LIST) 82 | 83 | .DEFAULT_GOAL := help 84 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kratos gorm git 2 | 3 | > 使用kratos+gorm搭建的Git代码托管平台 4 | > 5 | > kratos 参考文档:https://go-kratos.dev/ 6 | > 7 | > gorm 参考文档:https://gorm.io/zh_CN/docs/ 8 | > 9 | > B 站视频教程:https://www.bilibili.com/video/BV17Y4y1y7jt/ 10 | 11 | ## 同类产品 12 | 13 | 1. [Github](https://github.com/) 全球最大的代码托管平台 14 | 2. [Gitee](https://gitee.com/) 国内最大的代码托管平台 15 | 3. [Gitea](https://gitea.io/) 轻量级的开源的代码托管平台 16 | 17 | ## 安装 18 | 1. 安装 cli 工具 19 | ```shell 20 | go install github.com/go-kratos/kratos/cmd/kratos/v2@latest 21 | ``` 22 | 23 | 2. 初始项目 24 | ```shell 25 | kratos new kratos-gorm-git 26 | ``` 27 | 28 | 3. 运行 29 | ```shell 30 | kratos run 31 | ``` 32 | 33 | ## 相关命令 34 | ```shell 35 | # 用户模块 36 | # 创建 user.proto 37 | kratos proto add api/git/user.proto 38 | # 创建 PB 39 | kratos proto client api/git/user.proto 40 | # 生成 Service 41 | kratos proto server api/git/user.proto t internal/service 42 | 43 | # 仓库模块 44 | # 创建 repo.proto 45 | kratos proto add api/git/repo.proto 46 | # 创建 PB 47 | kratos proto client api/git/repo.proto 48 | # 生成 Service 49 | kratos proto server api/git/repo.proto t internal/service 50 | 51 | # config init pb 52 | kratos proto client internal/conf/conf.proto 53 | ``` 54 | 55 | ## 核心扩展 56 | 57 | ```shell 58 | go get github.com/asim/git-http-backend 59 | ``` 60 | 61 | ## 系统模块 62 | 63 | - [x] 仓库管理 64 | - [x] 仓库列表 65 | - [x] 新增仓库 66 | - [x] 修改仓库 67 | - [x] 删除仓库 68 | - [x] 仓库授权 69 | - [x] 用户管理 70 | - [x] 登录 71 | - [x] GIT服务 72 | - [x] 新建仓库 73 | - [x] git-http-backend 74 | - [x] 鉴权 75 | 76 | ## 快速体验GIT远程仓库 77 | 78 | 1. 初始化空的存储仓库 79 | ```shell 80 | git init --bare /root/git-test/hello.git 81 | ``` 82 | 83 | 2.生成ssh密钥 84 | ``` 85 | ssh-keygen -t rsa -C "get@qq.com" 86 | ``` 87 | 88 | 3. 将客户端生成的公钥复制到服务器端 89 | ```shell 90 | # 公钥文件地址 91 | cat ~/.ssh/id_rsa.pub 92 | # 服务端的配置文件路径 93 | vi ~/.ssh/authorized_keys 94 | ``` 95 | 96 | 4. 操作远程仓库 97 | ```shell 98 | # clone 99 | git clone root@119.27.164.148:/root/git-test/hello.git 100 | # 添加远程仓库 101 | git remote add origin root@119.27.164.148:/root/git-test/hello.git 102 | # 推送本地代码到远程仓库 103 | git push -u origin master 104 | ``` 105 | 106 | ## Git 远程仓库的其他实现 107 | 1. 使用git守护进程 108 | ```shell 109 | git daemon --export-all --verbose --base-path=. --export-all --port=9091 --enable=receive-pack 110 | ``` 111 | 112 | 2. 使用http-backend 113 | + demo地址: git clone http://127.0.0.1:8000/git/up-zero/up-git.git 114 | -------------------------------------------------------------------------------- /api/git/repo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package api.git; 4 | 5 | import "google/api/annotations.proto"; 6 | option go_package = "kratos-gorm-git/api/git;git"; 7 | option java_multiple_files = true; 8 | option java_package = "api.git"; 9 | 10 | service Repo { 11 | rpc CreateRepo (CreateRepoRequest) returns (CreateRepoReply) { 12 | option (google.api.http) = { 13 | post: "/repo/create", 14 | body: "*" 15 | }; 16 | } 17 | rpc UpdateRepo (UpdateRepoRequest) returns (UpdateRepoReply) { 18 | option (google.api.http) = { 19 | put: "/repo/update", 20 | body: "*" 21 | }; 22 | } 23 | rpc DeleteRepo (DeleteRepoRequest) returns (DeleteRepoReply) { 24 | option (google.api.http) = { 25 | delete: "/repo/delete" 26 | }; 27 | } 28 | rpc GetRepo (GetRepoRequest) returns (GetRepoReply); 29 | rpc ListRepo (ListRepoRequest) returns (ListRepoReply) { 30 | option (google.api.http) = { 31 | get: "/repo/list", 32 | }; 33 | } 34 | rpc RepoAuth (RepoAuthRequest) returns (RepoAuthReply) { 35 | option (google.api.http) = { 36 | post: "/repo/auth", 37 | body: "*" 38 | }; 39 | } 40 | } 41 | 42 | message CreateRepoRequest { 43 | string name = 1; 44 | string desc = 2; 45 | string path = 3; 46 | int32 type = 4; // 类型,{1:公库 0:私库} 47 | } 48 | message CreateRepoReply {} 49 | 50 | message UpdateRepoRequest { 51 | string identity = 1; 52 | string name = 2; 53 | string desc = 3; 54 | int32 type = 4; // 类型,{1:公库 0:私库} 55 | } 56 | message UpdateRepoReply {} 57 | 58 | message DeleteRepoRequest { 59 | string identity = 1; 60 | } 61 | message DeleteRepoReply {} 62 | 63 | message GetRepoRequest {} 64 | message GetRepoReply {} 65 | 66 | message ListRepoRequest { 67 | int64 page = 1; // 当前页码 68 | int64 size = 2; // 每页返回的个数 69 | } 70 | message ListRepoReply { 71 | int64 cnt = 1; // 总个数 72 | repeated ListRepoItem list = 2; // 仓库列表 73 | } 74 | 75 | message ListRepoItem { 76 | string identity = 1; // 唯一标识 77 | string name = 2; 78 | string desc = 3; 79 | string path = 4; 80 | int64 star = 5; 81 | } 82 | 83 | message RepoAuthRequest { 84 | string repo_identity = 1; 85 | string user_identity = 2; 86 | } 87 | 88 | message RepoAuthReply {} -------------------------------------------------------------------------------- /api/git/repo_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.3.0 4 | // - protoc v3.14.0 5 | // source: api/git/repo.proto 6 | 7 | package git 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.32.0 or later. 19 | const _ = grpc.SupportPackageIsVersion7 20 | 21 | const ( 22 | Repo_CreateRepo_FullMethodName = "/api.git.Repo/CreateRepo" 23 | Repo_UpdateRepo_FullMethodName = "/api.git.Repo/UpdateRepo" 24 | Repo_DeleteRepo_FullMethodName = "/api.git.Repo/DeleteRepo" 25 | Repo_GetRepo_FullMethodName = "/api.git.Repo/GetRepo" 26 | Repo_ListRepo_FullMethodName = "/api.git.Repo/ListRepo" 27 | Repo_RepoAuth_FullMethodName = "/api.git.Repo/RepoAuth" 28 | ) 29 | 30 | // RepoClient is the client API for Repo service. 31 | // 32 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 33 | type RepoClient interface { 34 | CreateRepo(ctx context.Context, in *CreateRepoRequest, opts ...grpc.CallOption) (*CreateRepoReply, error) 35 | UpdateRepo(ctx context.Context, in *UpdateRepoRequest, opts ...grpc.CallOption) (*UpdateRepoReply, error) 36 | DeleteRepo(ctx context.Context, in *DeleteRepoRequest, opts ...grpc.CallOption) (*DeleteRepoReply, error) 37 | GetRepo(ctx context.Context, in *GetRepoRequest, opts ...grpc.CallOption) (*GetRepoReply, error) 38 | ListRepo(ctx context.Context, in *ListRepoRequest, opts ...grpc.CallOption) (*ListRepoReply, error) 39 | RepoAuth(ctx context.Context, in *RepoAuthRequest, opts ...grpc.CallOption) (*RepoAuthReply, error) 40 | } 41 | 42 | type repoClient struct { 43 | cc grpc.ClientConnInterface 44 | } 45 | 46 | func NewRepoClient(cc grpc.ClientConnInterface) RepoClient { 47 | return &repoClient{cc} 48 | } 49 | 50 | func (c *repoClient) CreateRepo(ctx context.Context, in *CreateRepoRequest, opts ...grpc.CallOption) (*CreateRepoReply, error) { 51 | out := new(CreateRepoReply) 52 | err := c.cc.Invoke(ctx, Repo_CreateRepo_FullMethodName, in, out, opts...) 53 | if err != nil { 54 | return nil, err 55 | } 56 | return out, nil 57 | } 58 | 59 | func (c *repoClient) UpdateRepo(ctx context.Context, in *UpdateRepoRequest, opts ...grpc.CallOption) (*UpdateRepoReply, error) { 60 | out := new(UpdateRepoReply) 61 | err := c.cc.Invoke(ctx, Repo_UpdateRepo_FullMethodName, in, out, opts...) 62 | if err != nil { 63 | return nil, err 64 | } 65 | return out, nil 66 | } 67 | 68 | func (c *repoClient) DeleteRepo(ctx context.Context, in *DeleteRepoRequest, opts ...grpc.CallOption) (*DeleteRepoReply, error) { 69 | out := new(DeleteRepoReply) 70 | err := c.cc.Invoke(ctx, Repo_DeleteRepo_FullMethodName, in, out, opts...) 71 | if err != nil { 72 | return nil, err 73 | } 74 | return out, nil 75 | } 76 | 77 | func (c *repoClient) GetRepo(ctx context.Context, in *GetRepoRequest, opts ...grpc.CallOption) (*GetRepoReply, error) { 78 | out := new(GetRepoReply) 79 | err := c.cc.Invoke(ctx, Repo_GetRepo_FullMethodName, in, out, opts...) 80 | if err != nil { 81 | return nil, err 82 | } 83 | return out, nil 84 | } 85 | 86 | func (c *repoClient) ListRepo(ctx context.Context, in *ListRepoRequest, opts ...grpc.CallOption) (*ListRepoReply, error) { 87 | out := new(ListRepoReply) 88 | err := c.cc.Invoke(ctx, Repo_ListRepo_FullMethodName, in, out, opts...) 89 | if err != nil { 90 | return nil, err 91 | } 92 | return out, nil 93 | } 94 | 95 | func (c *repoClient) RepoAuth(ctx context.Context, in *RepoAuthRequest, opts ...grpc.CallOption) (*RepoAuthReply, error) { 96 | out := new(RepoAuthReply) 97 | err := c.cc.Invoke(ctx, Repo_RepoAuth_FullMethodName, in, out, opts...) 98 | if err != nil { 99 | return nil, err 100 | } 101 | return out, nil 102 | } 103 | 104 | // RepoServer is the server API for Repo service. 105 | // All implementations must embed UnimplementedRepoServer 106 | // for forward compatibility 107 | type RepoServer interface { 108 | CreateRepo(context.Context, *CreateRepoRequest) (*CreateRepoReply, error) 109 | UpdateRepo(context.Context, *UpdateRepoRequest) (*UpdateRepoReply, error) 110 | DeleteRepo(context.Context, *DeleteRepoRequest) (*DeleteRepoReply, error) 111 | GetRepo(context.Context, *GetRepoRequest) (*GetRepoReply, error) 112 | ListRepo(context.Context, *ListRepoRequest) (*ListRepoReply, error) 113 | RepoAuth(context.Context, *RepoAuthRequest) (*RepoAuthReply, error) 114 | mustEmbedUnimplementedRepoServer() 115 | } 116 | 117 | // UnimplementedRepoServer must be embedded to have forward compatible implementations. 118 | type UnimplementedRepoServer struct { 119 | } 120 | 121 | func (UnimplementedRepoServer) CreateRepo(context.Context, *CreateRepoRequest) (*CreateRepoReply, error) { 122 | return nil, status.Errorf(codes.Unimplemented, "method CreateRepo not implemented") 123 | } 124 | func (UnimplementedRepoServer) UpdateRepo(context.Context, *UpdateRepoRequest) (*UpdateRepoReply, error) { 125 | return nil, status.Errorf(codes.Unimplemented, "method UpdateRepo not implemented") 126 | } 127 | func (UnimplementedRepoServer) DeleteRepo(context.Context, *DeleteRepoRequest) (*DeleteRepoReply, error) { 128 | return nil, status.Errorf(codes.Unimplemented, "method DeleteRepo not implemented") 129 | } 130 | func (UnimplementedRepoServer) GetRepo(context.Context, *GetRepoRequest) (*GetRepoReply, error) { 131 | return nil, status.Errorf(codes.Unimplemented, "method GetRepo not implemented") 132 | } 133 | func (UnimplementedRepoServer) ListRepo(context.Context, *ListRepoRequest) (*ListRepoReply, error) { 134 | return nil, status.Errorf(codes.Unimplemented, "method ListRepo not implemented") 135 | } 136 | func (UnimplementedRepoServer) RepoAuth(context.Context, *RepoAuthRequest) (*RepoAuthReply, error) { 137 | return nil, status.Errorf(codes.Unimplemented, "method RepoAuth not implemented") 138 | } 139 | func (UnimplementedRepoServer) mustEmbedUnimplementedRepoServer() {} 140 | 141 | // UnsafeRepoServer may be embedded to opt out of forward compatibility for this service. 142 | // Use of this interface is not recommended, as added methods to RepoServer will 143 | // result in compilation errors. 144 | type UnsafeRepoServer interface { 145 | mustEmbedUnimplementedRepoServer() 146 | } 147 | 148 | func RegisterRepoServer(s grpc.ServiceRegistrar, srv RepoServer) { 149 | s.RegisterService(&Repo_ServiceDesc, srv) 150 | } 151 | 152 | func _Repo_CreateRepo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 153 | in := new(CreateRepoRequest) 154 | if err := dec(in); err != nil { 155 | return nil, err 156 | } 157 | if interceptor == nil { 158 | return srv.(RepoServer).CreateRepo(ctx, in) 159 | } 160 | info := &grpc.UnaryServerInfo{ 161 | Server: srv, 162 | FullMethod: Repo_CreateRepo_FullMethodName, 163 | } 164 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 165 | return srv.(RepoServer).CreateRepo(ctx, req.(*CreateRepoRequest)) 166 | } 167 | return interceptor(ctx, in, info, handler) 168 | } 169 | 170 | func _Repo_UpdateRepo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 171 | in := new(UpdateRepoRequest) 172 | if err := dec(in); err != nil { 173 | return nil, err 174 | } 175 | if interceptor == nil { 176 | return srv.(RepoServer).UpdateRepo(ctx, in) 177 | } 178 | info := &grpc.UnaryServerInfo{ 179 | Server: srv, 180 | FullMethod: Repo_UpdateRepo_FullMethodName, 181 | } 182 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 183 | return srv.(RepoServer).UpdateRepo(ctx, req.(*UpdateRepoRequest)) 184 | } 185 | return interceptor(ctx, in, info, handler) 186 | } 187 | 188 | func _Repo_DeleteRepo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 189 | in := new(DeleteRepoRequest) 190 | if err := dec(in); err != nil { 191 | return nil, err 192 | } 193 | if interceptor == nil { 194 | return srv.(RepoServer).DeleteRepo(ctx, in) 195 | } 196 | info := &grpc.UnaryServerInfo{ 197 | Server: srv, 198 | FullMethod: Repo_DeleteRepo_FullMethodName, 199 | } 200 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 201 | return srv.(RepoServer).DeleteRepo(ctx, req.(*DeleteRepoRequest)) 202 | } 203 | return interceptor(ctx, in, info, handler) 204 | } 205 | 206 | func _Repo_GetRepo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 207 | in := new(GetRepoRequest) 208 | if err := dec(in); err != nil { 209 | return nil, err 210 | } 211 | if interceptor == nil { 212 | return srv.(RepoServer).GetRepo(ctx, in) 213 | } 214 | info := &grpc.UnaryServerInfo{ 215 | Server: srv, 216 | FullMethod: Repo_GetRepo_FullMethodName, 217 | } 218 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 219 | return srv.(RepoServer).GetRepo(ctx, req.(*GetRepoRequest)) 220 | } 221 | return interceptor(ctx, in, info, handler) 222 | } 223 | 224 | func _Repo_ListRepo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 225 | in := new(ListRepoRequest) 226 | if err := dec(in); err != nil { 227 | return nil, err 228 | } 229 | if interceptor == nil { 230 | return srv.(RepoServer).ListRepo(ctx, in) 231 | } 232 | info := &grpc.UnaryServerInfo{ 233 | Server: srv, 234 | FullMethod: Repo_ListRepo_FullMethodName, 235 | } 236 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 237 | return srv.(RepoServer).ListRepo(ctx, req.(*ListRepoRequest)) 238 | } 239 | return interceptor(ctx, in, info, handler) 240 | } 241 | 242 | func _Repo_RepoAuth_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 243 | in := new(RepoAuthRequest) 244 | if err := dec(in); err != nil { 245 | return nil, err 246 | } 247 | if interceptor == nil { 248 | return srv.(RepoServer).RepoAuth(ctx, in) 249 | } 250 | info := &grpc.UnaryServerInfo{ 251 | Server: srv, 252 | FullMethod: Repo_RepoAuth_FullMethodName, 253 | } 254 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 255 | return srv.(RepoServer).RepoAuth(ctx, req.(*RepoAuthRequest)) 256 | } 257 | return interceptor(ctx, in, info, handler) 258 | } 259 | 260 | // Repo_ServiceDesc is the grpc.ServiceDesc for Repo service. 261 | // It's only intended for direct use with grpc.RegisterService, 262 | // and not to be introspected or modified (even as a copy) 263 | var Repo_ServiceDesc = grpc.ServiceDesc{ 264 | ServiceName: "api.git.Repo", 265 | HandlerType: (*RepoServer)(nil), 266 | Methods: []grpc.MethodDesc{ 267 | { 268 | MethodName: "CreateRepo", 269 | Handler: _Repo_CreateRepo_Handler, 270 | }, 271 | { 272 | MethodName: "UpdateRepo", 273 | Handler: _Repo_UpdateRepo_Handler, 274 | }, 275 | { 276 | MethodName: "DeleteRepo", 277 | Handler: _Repo_DeleteRepo_Handler, 278 | }, 279 | { 280 | MethodName: "GetRepo", 281 | Handler: _Repo_GetRepo_Handler, 282 | }, 283 | { 284 | MethodName: "ListRepo", 285 | Handler: _Repo_ListRepo_Handler, 286 | }, 287 | { 288 | MethodName: "RepoAuth", 289 | Handler: _Repo_RepoAuth_Handler, 290 | }, 291 | }, 292 | Streams: []grpc.StreamDesc{}, 293 | Metadata: "api/git/repo.proto", 294 | } 295 | -------------------------------------------------------------------------------- /api/git/repo_http.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-http. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-http v2.6.1 4 | // - protoc v3.14.0 5 | // source: api/git/repo.proto 6 | 7 | package git 8 | 9 | import ( 10 | context "context" 11 | http "github.com/go-kratos/kratos/v2/transport/http" 12 | binding "github.com/go-kratos/kratos/v2/transport/http/binding" 13 | ) 14 | 15 | // This is a compile-time assertion to ensure that this generated file 16 | // is compatible with the kratos package it is being compiled against. 17 | var _ = new(context.Context) 18 | var _ = binding.EncodeURL 19 | 20 | const _ = http.SupportPackageIsVersion1 21 | 22 | const OperationRepoCreateRepo = "/api.git.Repo/CreateRepo" 23 | const OperationRepoDeleteRepo = "/api.git.Repo/DeleteRepo" 24 | const OperationRepoListRepo = "/api.git.Repo/ListRepo" 25 | const OperationRepoRepoAuth = "/api.git.Repo/RepoAuth" 26 | const OperationRepoUpdateRepo = "/api.git.Repo/UpdateRepo" 27 | 28 | type RepoHTTPServer interface { 29 | CreateRepo(context.Context, *CreateRepoRequest) (*CreateRepoReply, error) 30 | DeleteRepo(context.Context, *DeleteRepoRequest) (*DeleteRepoReply, error) 31 | ListRepo(context.Context, *ListRepoRequest) (*ListRepoReply, error) 32 | RepoAuth(context.Context, *RepoAuthRequest) (*RepoAuthReply, error) 33 | UpdateRepo(context.Context, *UpdateRepoRequest) (*UpdateRepoReply, error) 34 | } 35 | 36 | func RegisterRepoHTTPServer(s *http.Server, srv RepoHTTPServer) { 37 | r := s.Route("/") 38 | r.POST("/repo/create", _Repo_CreateRepo0_HTTP_Handler(srv)) 39 | r.PUT("/repo/update", _Repo_UpdateRepo0_HTTP_Handler(srv)) 40 | r.DELETE("/repo/delete", _Repo_DeleteRepo0_HTTP_Handler(srv)) 41 | r.GET("/repo/list", _Repo_ListRepo0_HTTP_Handler(srv)) 42 | r.POST("/repo/auth", _Repo_RepoAuth0_HTTP_Handler(srv)) 43 | } 44 | 45 | func _Repo_CreateRepo0_HTTP_Handler(srv RepoHTTPServer) func(ctx http.Context) error { 46 | return func(ctx http.Context) error { 47 | var in CreateRepoRequest 48 | if err := ctx.Bind(&in); err != nil { 49 | return err 50 | } 51 | http.SetOperation(ctx, OperationRepoCreateRepo) 52 | h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { 53 | return srv.CreateRepo(ctx, req.(*CreateRepoRequest)) 54 | }) 55 | out, err := h(ctx, &in) 56 | if err != nil { 57 | return err 58 | } 59 | reply := out.(*CreateRepoReply) 60 | return ctx.Result(200, reply) 61 | } 62 | } 63 | 64 | func _Repo_UpdateRepo0_HTTP_Handler(srv RepoHTTPServer) func(ctx http.Context) error { 65 | return func(ctx http.Context) error { 66 | var in UpdateRepoRequest 67 | if err := ctx.Bind(&in); err != nil { 68 | return err 69 | } 70 | http.SetOperation(ctx, OperationRepoUpdateRepo) 71 | h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { 72 | return srv.UpdateRepo(ctx, req.(*UpdateRepoRequest)) 73 | }) 74 | out, err := h(ctx, &in) 75 | if err != nil { 76 | return err 77 | } 78 | reply := out.(*UpdateRepoReply) 79 | return ctx.Result(200, reply) 80 | } 81 | } 82 | 83 | func _Repo_DeleteRepo0_HTTP_Handler(srv RepoHTTPServer) func(ctx http.Context) error { 84 | return func(ctx http.Context) error { 85 | var in DeleteRepoRequest 86 | if err := ctx.BindQuery(&in); err != nil { 87 | return err 88 | } 89 | http.SetOperation(ctx, OperationRepoDeleteRepo) 90 | h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { 91 | return srv.DeleteRepo(ctx, req.(*DeleteRepoRequest)) 92 | }) 93 | out, err := h(ctx, &in) 94 | if err != nil { 95 | return err 96 | } 97 | reply := out.(*DeleteRepoReply) 98 | return ctx.Result(200, reply) 99 | } 100 | } 101 | 102 | func _Repo_ListRepo0_HTTP_Handler(srv RepoHTTPServer) func(ctx http.Context) error { 103 | return func(ctx http.Context) error { 104 | var in ListRepoRequest 105 | if err := ctx.BindQuery(&in); err != nil { 106 | return err 107 | } 108 | http.SetOperation(ctx, OperationRepoListRepo) 109 | h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { 110 | return srv.ListRepo(ctx, req.(*ListRepoRequest)) 111 | }) 112 | out, err := h(ctx, &in) 113 | if err != nil { 114 | return err 115 | } 116 | reply := out.(*ListRepoReply) 117 | return ctx.Result(200, reply) 118 | } 119 | } 120 | 121 | func _Repo_RepoAuth0_HTTP_Handler(srv RepoHTTPServer) func(ctx http.Context) error { 122 | return func(ctx http.Context) error { 123 | var in RepoAuthRequest 124 | if err := ctx.Bind(&in); err != nil { 125 | return err 126 | } 127 | http.SetOperation(ctx, OperationRepoRepoAuth) 128 | h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { 129 | return srv.RepoAuth(ctx, req.(*RepoAuthRequest)) 130 | }) 131 | out, err := h(ctx, &in) 132 | if err != nil { 133 | return err 134 | } 135 | reply := out.(*RepoAuthReply) 136 | return ctx.Result(200, reply) 137 | } 138 | } 139 | 140 | type RepoHTTPClient interface { 141 | CreateRepo(ctx context.Context, req *CreateRepoRequest, opts ...http.CallOption) (rsp *CreateRepoReply, err error) 142 | DeleteRepo(ctx context.Context, req *DeleteRepoRequest, opts ...http.CallOption) (rsp *DeleteRepoReply, err error) 143 | ListRepo(ctx context.Context, req *ListRepoRequest, opts ...http.CallOption) (rsp *ListRepoReply, err error) 144 | RepoAuth(ctx context.Context, req *RepoAuthRequest, opts ...http.CallOption) (rsp *RepoAuthReply, err error) 145 | UpdateRepo(ctx context.Context, req *UpdateRepoRequest, opts ...http.CallOption) (rsp *UpdateRepoReply, err error) 146 | } 147 | 148 | type RepoHTTPClientImpl struct { 149 | cc *http.Client 150 | } 151 | 152 | func NewRepoHTTPClient(client *http.Client) RepoHTTPClient { 153 | return &RepoHTTPClientImpl{client} 154 | } 155 | 156 | func (c *RepoHTTPClientImpl) CreateRepo(ctx context.Context, in *CreateRepoRequest, opts ...http.CallOption) (*CreateRepoReply, error) { 157 | var out CreateRepoReply 158 | pattern := "/repo/create" 159 | path := binding.EncodeURL(pattern, in, false) 160 | opts = append(opts, http.Operation(OperationRepoCreateRepo)) 161 | opts = append(opts, http.PathTemplate(pattern)) 162 | err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) 163 | if err != nil { 164 | return nil, err 165 | } 166 | return &out, err 167 | } 168 | 169 | func (c *RepoHTTPClientImpl) DeleteRepo(ctx context.Context, in *DeleteRepoRequest, opts ...http.CallOption) (*DeleteRepoReply, error) { 170 | var out DeleteRepoReply 171 | pattern := "/repo/delete" 172 | path := binding.EncodeURL(pattern, in, true) 173 | opts = append(opts, http.Operation(OperationRepoDeleteRepo)) 174 | opts = append(opts, http.PathTemplate(pattern)) 175 | err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) 176 | if err != nil { 177 | return nil, err 178 | } 179 | return &out, err 180 | } 181 | 182 | func (c *RepoHTTPClientImpl) ListRepo(ctx context.Context, in *ListRepoRequest, opts ...http.CallOption) (*ListRepoReply, error) { 183 | var out ListRepoReply 184 | pattern := "/repo/list" 185 | path := binding.EncodeURL(pattern, in, true) 186 | opts = append(opts, http.Operation(OperationRepoListRepo)) 187 | opts = append(opts, http.PathTemplate(pattern)) 188 | err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) 189 | if err != nil { 190 | return nil, err 191 | } 192 | return &out, err 193 | } 194 | 195 | func (c *RepoHTTPClientImpl) RepoAuth(ctx context.Context, in *RepoAuthRequest, opts ...http.CallOption) (*RepoAuthReply, error) { 196 | var out RepoAuthReply 197 | pattern := "/repo/auth" 198 | path := binding.EncodeURL(pattern, in, false) 199 | opts = append(opts, http.Operation(OperationRepoRepoAuth)) 200 | opts = append(opts, http.PathTemplate(pattern)) 201 | err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) 202 | if err != nil { 203 | return nil, err 204 | } 205 | return &out, err 206 | } 207 | 208 | func (c *RepoHTTPClientImpl) UpdateRepo(ctx context.Context, in *UpdateRepoRequest, opts ...http.CallOption) (*UpdateRepoReply, error) { 209 | var out UpdateRepoReply 210 | pattern := "/repo/update" 211 | path := binding.EncodeURL(pattern, in, false) 212 | opts = append(opts, http.Operation(OperationRepoUpdateRepo)) 213 | opts = append(opts, http.PathTemplate(pattern)) 214 | err := c.cc.Invoke(ctx, "PUT", path, in, &out, opts...) 215 | if err != nil { 216 | return nil, err 217 | } 218 | return &out, err 219 | } 220 | -------------------------------------------------------------------------------- /api/git/user.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.30.0 4 | // protoc v3.14.0 5 | // source: api/git/user.proto 6 | 7 | package git 8 | 9 | import ( 10 | _ "google.golang.org/genproto/googleapis/api/annotations" 11 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 12 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 13 | reflect "reflect" 14 | sync "sync" 15 | ) 16 | 17 | const ( 18 | // Verify that this generated code is sufficiently up-to-date. 19 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 20 | // Verify that runtime/protoimpl is sufficiently up-to-date. 21 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 22 | ) 23 | 24 | type LoginRequest struct { 25 | state protoimpl.MessageState 26 | sizeCache protoimpl.SizeCache 27 | unknownFields protoimpl.UnknownFields 28 | 29 | Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` // 用户名 30 | Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` // 密码 31 | } 32 | 33 | func (x *LoginRequest) Reset() { 34 | *x = LoginRequest{} 35 | if protoimpl.UnsafeEnabled { 36 | mi := &file_api_git_user_proto_msgTypes[0] 37 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 38 | ms.StoreMessageInfo(mi) 39 | } 40 | } 41 | 42 | func (x *LoginRequest) String() string { 43 | return protoimpl.X.MessageStringOf(x) 44 | } 45 | 46 | func (*LoginRequest) ProtoMessage() {} 47 | 48 | func (x *LoginRequest) ProtoReflect() protoreflect.Message { 49 | mi := &file_api_git_user_proto_msgTypes[0] 50 | if protoimpl.UnsafeEnabled && x != nil { 51 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 52 | if ms.LoadMessageInfo() == nil { 53 | ms.StoreMessageInfo(mi) 54 | } 55 | return ms 56 | } 57 | return mi.MessageOf(x) 58 | } 59 | 60 | // Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. 61 | func (*LoginRequest) Descriptor() ([]byte, []int) { 62 | return file_api_git_user_proto_rawDescGZIP(), []int{0} 63 | } 64 | 65 | func (x *LoginRequest) GetUsername() string { 66 | if x != nil { 67 | return x.Username 68 | } 69 | return "" 70 | } 71 | 72 | func (x *LoginRequest) GetPassword() string { 73 | if x != nil { 74 | return x.Password 75 | } 76 | return "" 77 | } 78 | 79 | type LoginReply struct { 80 | state protoimpl.MessageState 81 | sizeCache protoimpl.SizeCache 82 | unknownFields protoimpl.UnknownFields 83 | 84 | Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` // token 85 | } 86 | 87 | func (x *LoginReply) Reset() { 88 | *x = LoginReply{} 89 | if protoimpl.UnsafeEnabled { 90 | mi := &file_api_git_user_proto_msgTypes[1] 91 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 92 | ms.StoreMessageInfo(mi) 93 | } 94 | } 95 | 96 | func (x *LoginReply) String() string { 97 | return protoimpl.X.MessageStringOf(x) 98 | } 99 | 100 | func (*LoginReply) ProtoMessage() {} 101 | 102 | func (x *LoginReply) ProtoReflect() protoreflect.Message { 103 | mi := &file_api_git_user_proto_msgTypes[1] 104 | if protoimpl.UnsafeEnabled && x != nil { 105 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 106 | if ms.LoadMessageInfo() == nil { 107 | ms.StoreMessageInfo(mi) 108 | } 109 | return ms 110 | } 111 | return mi.MessageOf(x) 112 | } 113 | 114 | // Deprecated: Use LoginReply.ProtoReflect.Descriptor instead. 115 | func (*LoginReply) Descriptor() ([]byte, []int) { 116 | return file_api_git_user_proto_rawDescGZIP(), []int{1} 117 | } 118 | 119 | func (x *LoginReply) GetToken() string { 120 | if x != nil { 121 | return x.Token 122 | } 123 | return "" 124 | } 125 | 126 | var File_api_git_user_proto protoreflect.FileDescriptor 127 | 128 | var file_api_git_user_proto_rawDesc = []byte{ 129 | 0x0a, 0x12, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x69, 0x74, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 130 | 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x61, 0x70, 0x69, 0x2e, 0x67, 0x69, 0x74, 0x1a, 0x1c, 0x67, 131 | 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 132 | 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x46, 0x0a, 0x0c, 0x4c, 133 | 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 134 | 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 135 | 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 136 | 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 137 | 0x6f, 0x72, 0x64, 0x22, 0x22, 0x0a, 0x0a, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x70, 0x6c, 138 | 0x79, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 139 | 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x32, 0x4e, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 140 | 0x46, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x15, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x67, 141 | 0x69, 0x74, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 142 | 0x13, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x67, 0x69, 0x74, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 143 | 0x65, 0x70, 0x6c, 0x79, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x3a, 0x01, 0x2a, 0x22, 144 | 0x06, 0x2f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x42, 0x28, 0x0a, 0x07, 0x61, 0x70, 0x69, 0x2e, 0x67, 145 | 0x69, 0x74, 0x50, 0x01, 0x5a, 0x1b, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2d, 0x67, 0x6f, 0x72, 146 | 0x6d, 0x2d, 0x67, 0x69, 0x74, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x69, 0x74, 0x3b, 0x67, 0x69, 147 | 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 148 | } 149 | 150 | var ( 151 | file_api_git_user_proto_rawDescOnce sync.Once 152 | file_api_git_user_proto_rawDescData = file_api_git_user_proto_rawDesc 153 | ) 154 | 155 | func file_api_git_user_proto_rawDescGZIP() []byte { 156 | file_api_git_user_proto_rawDescOnce.Do(func() { 157 | file_api_git_user_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_git_user_proto_rawDescData) 158 | }) 159 | return file_api_git_user_proto_rawDescData 160 | } 161 | 162 | var file_api_git_user_proto_msgTypes = make([]protoimpl.MessageInfo, 2) 163 | var file_api_git_user_proto_goTypes = []interface{}{ 164 | (*LoginRequest)(nil), // 0: api.git.LoginRequest 165 | (*LoginReply)(nil), // 1: api.git.LoginReply 166 | } 167 | var file_api_git_user_proto_depIdxs = []int32{ 168 | 0, // 0: api.git.User.Login:input_type -> api.git.LoginRequest 169 | 1, // 1: api.git.User.Login:output_type -> api.git.LoginReply 170 | 1, // [1:2] is the sub-list for method output_type 171 | 0, // [0:1] is the sub-list for method input_type 172 | 0, // [0:0] is the sub-list for extension type_name 173 | 0, // [0:0] is the sub-list for extension extendee 174 | 0, // [0:0] is the sub-list for field type_name 175 | } 176 | 177 | func init() { file_api_git_user_proto_init() } 178 | func file_api_git_user_proto_init() { 179 | if File_api_git_user_proto != nil { 180 | return 181 | } 182 | if !protoimpl.UnsafeEnabled { 183 | file_api_git_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 184 | switch v := v.(*LoginRequest); i { 185 | case 0: 186 | return &v.state 187 | case 1: 188 | return &v.sizeCache 189 | case 2: 190 | return &v.unknownFields 191 | default: 192 | return nil 193 | } 194 | } 195 | file_api_git_user_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 196 | switch v := v.(*LoginReply); i { 197 | case 0: 198 | return &v.state 199 | case 1: 200 | return &v.sizeCache 201 | case 2: 202 | return &v.unknownFields 203 | default: 204 | return nil 205 | } 206 | } 207 | } 208 | type x struct{} 209 | out := protoimpl.TypeBuilder{ 210 | File: protoimpl.DescBuilder{ 211 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 212 | RawDescriptor: file_api_git_user_proto_rawDesc, 213 | NumEnums: 0, 214 | NumMessages: 2, 215 | NumExtensions: 0, 216 | NumServices: 1, 217 | }, 218 | GoTypes: file_api_git_user_proto_goTypes, 219 | DependencyIndexes: file_api_git_user_proto_depIdxs, 220 | MessageInfos: file_api_git_user_proto_msgTypes, 221 | }.Build() 222 | File_api_git_user_proto = out.File 223 | file_api_git_user_proto_rawDesc = nil 224 | file_api_git_user_proto_goTypes = nil 225 | file_api_git_user_proto_depIdxs = nil 226 | } 227 | -------------------------------------------------------------------------------- /api/git/user.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package api.git; 4 | 5 | import "google/api/annotations.proto"; 6 | 7 | option go_package = "kratos-gorm-git/api/git;git"; 8 | option java_multiple_files = true; 9 | option java_package = "api.git"; 10 | 11 | service User { 12 | rpc Login (LoginRequest) returns (LoginReply) { 13 | option (google.api.http) = { 14 | post: "/login", 15 | body: "*" 16 | }; 17 | }; 18 | } 19 | 20 | 21 | message LoginRequest { 22 | string username = 1; // 用户名 23 | string password = 2; // 密码 24 | } 25 | message LoginReply { 26 | string token = 1; // token 27 | } -------------------------------------------------------------------------------- /api/git/user_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.3.0 4 | // - protoc v3.14.0 5 | // source: api/git/user.proto 6 | 7 | package git 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.32.0 or later. 19 | const _ = grpc.SupportPackageIsVersion7 20 | 21 | const ( 22 | User_Login_FullMethodName = "/api.git.User/Login" 23 | ) 24 | 25 | // UserClient is the client API for User service. 26 | // 27 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 28 | type UserClient interface { 29 | Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginReply, error) 30 | } 31 | 32 | type userClient struct { 33 | cc grpc.ClientConnInterface 34 | } 35 | 36 | func NewUserClient(cc grpc.ClientConnInterface) UserClient { 37 | return &userClient{cc} 38 | } 39 | 40 | func (c *userClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginReply, error) { 41 | out := new(LoginReply) 42 | err := c.cc.Invoke(ctx, User_Login_FullMethodName, in, out, opts...) 43 | if err != nil { 44 | return nil, err 45 | } 46 | return out, nil 47 | } 48 | 49 | // UserServer is the server API for User service. 50 | // All implementations must embed UnimplementedUserServer 51 | // for forward compatibility 52 | type UserServer interface { 53 | Login(context.Context, *LoginRequest) (*LoginReply, error) 54 | mustEmbedUnimplementedUserServer() 55 | } 56 | 57 | // UnimplementedUserServer must be embedded to have forward compatible implementations. 58 | type UnimplementedUserServer struct { 59 | } 60 | 61 | func (UnimplementedUserServer) Login(context.Context, *LoginRequest) (*LoginReply, error) { 62 | return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") 63 | } 64 | func (UnimplementedUserServer) mustEmbedUnimplementedUserServer() {} 65 | 66 | // UnsafeUserServer may be embedded to opt out of forward compatibility for this service. 67 | // Use of this interface is not recommended, as added methods to UserServer will 68 | // result in compilation errors. 69 | type UnsafeUserServer interface { 70 | mustEmbedUnimplementedUserServer() 71 | } 72 | 73 | func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer) { 74 | s.RegisterService(&User_ServiceDesc, srv) 75 | } 76 | 77 | func _User_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 78 | in := new(LoginRequest) 79 | if err := dec(in); err != nil { 80 | return nil, err 81 | } 82 | if interceptor == nil { 83 | return srv.(UserServer).Login(ctx, in) 84 | } 85 | info := &grpc.UnaryServerInfo{ 86 | Server: srv, 87 | FullMethod: User_Login_FullMethodName, 88 | } 89 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 90 | return srv.(UserServer).Login(ctx, req.(*LoginRequest)) 91 | } 92 | return interceptor(ctx, in, info, handler) 93 | } 94 | 95 | // User_ServiceDesc is the grpc.ServiceDesc for User service. 96 | // It's only intended for direct use with grpc.RegisterService, 97 | // and not to be introspected or modified (even as a copy) 98 | var User_ServiceDesc = grpc.ServiceDesc{ 99 | ServiceName: "api.git.User", 100 | HandlerType: (*UserServer)(nil), 101 | Methods: []grpc.MethodDesc{ 102 | { 103 | MethodName: "Login", 104 | Handler: _User_Login_Handler, 105 | }, 106 | }, 107 | Streams: []grpc.StreamDesc{}, 108 | Metadata: "api/git/user.proto", 109 | } 110 | -------------------------------------------------------------------------------- /api/git/user_http.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-http. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-http v2.6.1 4 | // - protoc v3.14.0 5 | // source: api/git/user.proto 6 | 7 | package git 8 | 9 | import ( 10 | context "context" 11 | http "github.com/go-kratos/kratos/v2/transport/http" 12 | binding "github.com/go-kratos/kratos/v2/transport/http/binding" 13 | ) 14 | 15 | // This is a compile-time assertion to ensure that this generated file 16 | // is compatible with the kratos package it is being compiled against. 17 | var _ = new(context.Context) 18 | var _ = binding.EncodeURL 19 | 20 | const _ = http.SupportPackageIsVersion1 21 | 22 | const OperationUserLogin = "/api.git.User/Login" 23 | 24 | type UserHTTPServer interface { 25 | Login(context.Context, *LoginRequest) (*LoginReply, error) 26 | } 27 | 28 | func RegisterUserHTTPServer(s *http.Server, srv UserHTTPServer) { 29 | r := s.Route("/") 30 | r.POST("/login", _User_Login0_HTTP_Handler(srv)) 31 | } 32 | 33 | func _User_Login0_HTTP_Handler(srv UserHTTPServer) func(ctx http.Context) error { 34 | return func(ctx http.Context) error { 35 | var in LoginRequest 36 | if err := ctx.Bind(&in); err != nil { 37 | return err 38 | } 39 | http.SetOperation(ctx, OperationUserLogin) 40 | h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { 41 | return srv.Login(ctx, req.(*LoginRequest)) 42 | }) 43 | out, err := h(ctx, &in) 44 | if err != nil { 45 | return err 46 | } 47 | reply := out.(*LoginReply) 48 | return ctx.Result(200, reply) 49 | } 50 | } 51 | 52 | type UserHTTPClient interface { 53 | Login(ctx context.Context, req *LoginRequest, opts ...http.CallOption) (rsp *LoginReply, err error) 54 | } 55 | 56 | type UserHTTPClientImpl struct { 57 | cc *http.Client 58 | } 59 | 60 | func NewUserHTTPClient(client *http.Client) UserHTTPClient { 61 | return &UserHTTPClientImpl{client} 62 | } 63 | 64 | func (c *UserHTTPClientImpl) Login(ctx context.Context, in *LoginRequest, opts ...http.CallOption) (*LoginReply, error) { 65 | var out LoginReply 66 | pattern := "/login" 67 | path := binding.EncodeURL(pattern, in, false) 68 | opts = append(opts, http.Operation(OperationUserLogin)) 69 | opts = append(opts, http.PathTemplate(pattern)) 70 | err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) 71 | if err != nil { 72 | return nil, err 73 | } 74 | return &out, err 75 | } 76 | -------------------------------------------------------------------------------- /api/helloworld/v1/error_reason.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.27.1 4 | // protoc v3.19.3 5 | // source: helloworld/v1/error_reason.proto 6 | 7 | package v1 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type ErrorReason int32 24 | 25 | const ( 26 | ErrorReason_GEETER_UNSPECIFIED ErrorReason = 0 27 | ErrorReason_USER_NOT_FOUND ErrorReason = 1 28 | ) 29 | 30 | // Enum value maps for ErrorReason. 31 | var ( 32 | ErrorReason_name = map[int32]string{ 33 | 0: "GEETER_UNSPECIFIED", 34 | 1: "USER_NOT_FOUND", 35 | } 36 | ErrorReason_value = map[string]int32{ 37 | "GEETER_UNSPECIFIED": 0, 38 | "USER_NOT_FOUND": 1, 39 | } 40 | ) 41 | 42 | func (x ErrorReason) Enum() *ErrorReason { 43 | p := new(ErrorReason) 44 | *p = x 45 | return p 46 | } 47 | 48 | func (x ErrorReason) String() string { 49 | return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) 50 | } 51 | 52 | func (ErrorReason) Descriptor() protoreflect.EnumDescriptor { 53 | return file_helloworld_v1_error_reason_proto_enumTypes[0].Descriptor() 54 | } 55 | 56 | func (ErrorReason) Type() protoreflect.EnumType { 57 | return &file_helloworld_v1_error_reason_proto_enumTypes[0] 58 | } 59 | 60 | func (x ErrorReason) Number() protoreflect.EnumNumber { 61 | return protoreflect.EnumNumber(x) 62 | } 63 | 64 | // Deprecated: Use ErrorReason.Descriptor instead. 65 | func (ErrorReason) EnumDescriptor() ([]byte, []int) { 66 | return file_helloworld_v1_error_reason_proto_rawDescGZIP(), []int{0} 67 | } 68 | 69 | var File_helloworld_v1_error_reason_proto protoreflect.FileDescriptor 70 | 71 | var file_helloworld_v1_error_reason_proto_rawDesc = []byte{ 72 | 0x0a, 0x20, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x76, 0x31, 0x2f, 73 | 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 74 | 0x74, 0x6f, 0x12, 0x0d, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x76, 75 | 0x31, 0x2a, 0x39, 0x0a, 0x0b, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 76 | 0x12, 0x16, 0x0a, 0x12, 0x47, 0x45, 0x45, 0x54, 0x45, 0x52, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 77 | 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x55, 0x53, 0x45, 0x52, 78 | 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x46, 0x4f, 0x55, 0x4e, 0x44, 0x10, 0x01, 0x42, 0x5c, 0x0a, 0x0d, 79 | 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x76, 0x31, 0x50, 0x01, 0x5a, 80 | 0x37, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x2d, 0x6b, 81 | 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2d, 0x6c, 0x61, 0x79, 82 | 0x6f, 0x75, 0x74, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 83 | 0x6c, 0x64, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0xa2, 0x02, 0x0f, 0x41, 0x50, 0x49, 0x48, 0x65, 84 | 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 85 | 0x6f, 0x33, 86 | } 87 | 88 | var ( 89 | file_helloworld_v1_error_reason_proto_rawDescOnce sync.Once 90 | file_helloworld_v1_error_reason_proto_rawDescData = file_helloworld_v1_error_reason_proto_rawDesc 91 | ) 92 | 93 | func file_helloworld_v1_error_reason_proto_rawDescGZIP() []byte { 94 | file_helloworld_v1_error_reason_proto_rawDescOnce.Do(func() { 95 | file_helloworld_v1_error_reason_proto_rawDescData = protoimpl.X.CompressGZIP(file_helloworld_v1_error_reason_proto_rawDescData) 96 | }) 97 | return file_helloworld_v1_error_reason_proto_rawDescData 98 | } 99 | 100 | var file_helloworld_v1_error_reason_proto_enumTypes = make([]protoimpl.EnumInfo, 1) 101 | var file_helloworld_v1_error_reason_proto_goTypes = []interface{}{ 102 | (ErrorReason)(0), // 0: helloworld.v1.ErrorReason 103 | } 104 | var file_helloworld_v1_error_reason_proto_depIdxs = []int32{ 105 | 0, // [0:0] is the sub-list for method output_type 106 | 0, // [0:0] is the sub-list for method input_type 107 | 0, // [0:0] is the sub-list for extension type_name 108 | 0, // [0:0] is the sub-list for extension extendee 109 | 0, // [0:0] is the sub-list for field type_name 110 | } 111 | 112 | func init() { file_helloworld_v1_error_reason_proto_init() } 113 | func file_helloworld_v1_error_reason_proto_init() { 114 | if File_helloworld_v1_error_reason_proto != nil { 115 | return 116 | } 117 | type x struct{} 118 | out := protoimpl.TypeBuilder{ 119 | File: protoimpl.DescBuilder{ 120 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 121 | RawDescriptor: file_helloworld_v1_error_reason_proto_rawDesc, 122 | NumEnums: 1, 123 | NumMessages: 0, 124 | NumExtensions: 0, 125 | NumServices: 0, 126 | }, 127 | GoTypes: file_helloworld_v1_error_reason_proto_goTypes, 128 | DependencyIndexes: file_helloworld_v1_error_reason_proto_depIdxs, 129 | EnumInfos: file_helloworld_v1_error_reason_proto_enumTypes, 130 | }.Build() 131 | File_helloworld_v1_error_reason_proto = out.File 132 | file_helloworld_v1_error_reason_proto_rawDesc = nil 133 | file_helloworld_v1_error_reason_proto_goTypes = nil 134 | file_helloworld_v1_error_reason_proto_depIdxs = nil 135 | } 136 | -------------------------------------------------------------------------------- /api/helloworld/v1/error_reason.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package helloworld.v1; 4 | 5 | option go_package = "kratos-gorm-git/api/helloworld/v1;v1"; 6 | option java_multiple_files = true; 7 | option java_package = "helloworld.v1"; 8 | option objc_class_prefix = "APIHelloworldV1"; 9 | 10 | enum ErrorReason { 11 | GREETER_UNSPECIFIED = 0; 12 | USER_NOT_FOUND = 1; 13 | } 14 | -------------------------------------------------------------------------------- /api/helloworld/v1/greeter.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.27.1 4 | // protoc v3.19.3 5 | // source: helloworld/v1/greeter.proto 6 | 7 | package v1 8 | 9 | import ( 10 | _ "google.golang.org/genproto/googleapis/api/annotations" 11 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 12 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 13 | reflect "reflect" 14 | sync "sync" 15 | ) 16 | 17 | const ( 18 | // Verify that this generated code is sufficiently up-to-date. 19 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 20 | // Verify that runtime/protoimpl is sufficiently up-to-date. 21 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 22 | ) 23 | 24 | // The request message containing the user's name. 25 | type HelloRequest struct { 26 | state protoimpl.MessageState 27 | sizeCache protoimpl.SizeCache 28 | unknownFields protoimpl.UnknownFields 29 | 30 | Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` 31 | } 32 | 33 | func (x *HelloRequest) Reset() { 34 | *x = HelloRequest{} 35 | if protoimpl.UnsafeEnabled { 36 | mi := &file_helloworld_v1_greeter_proto_msgTypes[0] 37 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 38 | ms.StoreMessageInfo(mi) 39 | } 40 | } 41 | 42 | func (x *HelloRequest) String() string { 43 | return protoimpl.X.MessageStringOf(x) 44 | } 45 | 46 | func (*HelloRequest) ProtoMessage() {} 47 | 48 | func (x *HelloRequest) ProtoReflect() protoreflect.Message { 49 | mi := &file_helloworld_v1_greeter_proto_msgTypes[0] 50 | if protoimpl.UnsafeEnabled && x != nil { 51 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 52 | if ms.LoadMessageInfo() == nil { 53 | ms.StoreMessageInfo(mi) 54 | } 55 | return ms 56 | } 57 | return mi.MessageOf(x) 58 | } 59 | 60 | // Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead. 61 | func (*HelloRequest) Descriptor() ([]byte, []int) { 62 | return file_helloworld_v1_greeter_proto_rawDescGZIP(), []int{0} 63 | } 64 | 65 | func (x *HelloRequest) GetName() string { 66 | if x != nil { 67 | return x.Name 68 | } 69 | return "" 70 | } 71 | 72 | // The response message containing the greetings 73 | type HelloReply struct { 74 | state protoimpl.MessageState 75 | sizeCache protoimpl.SizeCache 76 | unknownFields protoimpl.UnknownFields 77 | 78 | Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` 79 | } 80 | 81 | func (x *HelloReply) Reset() { 82 | *x = HelloReply{} 83 | if protoimpl.UnsafeEnabled { 84 | mi := &file_helloworld_v1_greeter_proto_msgTypes[1] 85 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 86 | ms.StoreMessageInfo(mi) 87 | } 88 | } 89 | 90 | func (x *HelloReply) String() string { 91 | return protoimpl.X.MessageStringOf(x) 92 | } 93 | 94 | func (*HelloReply) ProtoMessage() {} 95 | 96 | func (x *HelloReply) ProtoReflect() protoreflect.Message { 97 | mi := &file_helloworld_v1_greeter_proto_msgTypes[1] 98 | if protoimpl.UnsafeEnabled && x != nil { 99 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 100 | if ms.LoadMessageInfo() == nil { 101 | ms.StoreMessageInfo(mi) 102 | } 103 | return ms 104 | } 105 | return mi.MessageOf(x) 106 | } 107 | 108 | // Deprecated: Use HelloReply.ProtoReflect.Descriptor instead. 109 | func (*HelloReply) Descriptor() ([]byte, []int) { 110 | return file_helloworld_v1_greeter_proto_rawDescGZIP(), []int{1} 111 | } 112 | 113 | func (x *HelloReply) GetMessage() string { 114 | if x != nil { 115 | return x.Message 116 | } 117 | return "" 118 | } 119 | 120 | var File_helloworld_v1_greeter_proto protoreflect.FileDescriptor 121 | 122 | var file_helloworld_v1_greeter_proto_rawDesc = []byte{ 123 | 0x0a, 0x1b, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x76, 0x31, 0x2f, 124 | 0x67, 0x72, 0x65, 0x65, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x68, 125 | 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x67, 0x6f, 126 | 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 127 | 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x22, 0x0a, 0x0c, 0x48, 0x65, 128 | 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 129 | 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x26, 130 | 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 131 | 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 132 | 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x69, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, 0x74, 0x65, 133 | 0x72, 0x12, 0x5e, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x1b, 0x2e, 134 | 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, 135 | 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x68, 0x65, 0x6c, 136 | 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 137 | 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x12, 0x12, 0x2f, 138 | 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 139 | 0x7d, 0x42, 0x6c, 0x0a, 0x1c, 0x64, 0x65, 0x76, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 140 | 0x61, 0x70, 0x69, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x76, 141 | 0x31, 0x42, 0x11, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x50, 0x72, 0x6f, 142 | 0x74, 0x6f, 0x56, 0x31, 0x50, 0x01, 0x5a, 0x37, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 143 | 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x2d, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2f, 0x6b, 0x72, 0x61, 144 | 0x74, 0x6f, 0x73, 0x2d, 0x6c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x68, 145 | 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 146 | 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 147 | } 148 | 149 | var ( 150 | file_helloworld_v1_greeter_proto_rawDescOnce sync.Once 151 | file_helloworld_v1_greeter_proto_rawDescData = file_helloworld_v1_greeter_proto_rawDesc 152 | ) 153 | 154 | func file_helloworld_v1_greeter_proto_rawDescGZIP() []byte { 155 | file_helloworld_v1_greeter_proto_rawDescOnce.Do(func() { 156 | file_helloworld_v1_greeter_proto_rawDescData = protoimpl.X.CompressGZIP(file_helloworld_v1_greeter_proto_rawDescData) 157 | }) 158 | return file_helloworld_v1_greeter_proto_rawDescData 159 | } 160 | 161 | var file_helloworld_v1_greeter_proto_msgTypes = make([]protoimpl.MessageInfo, 2) 162 | var file_helloworld_v1_greeter_proto_goTypes = []interface{}{ 163 | (*HelloRequest)(nil), // 0: helloworld.v1.HelloRequest 164 | (*HelloReply)(nil), // 1: helloworld.v1.HelloReply 165 | } 166 | var file_helloworld_v1_greeter_proto_depIdxs = []int32{ 167 | 0, // 0: helloworld.v1.Greeter.SayHello:input_type -> helloworld.v1.HelloRequest 168 | 1, // 1: helloworld.v1.Greeter.SayHello:output_type -> helloworld.v1.HelloReply 169 | 1, // [1:2] is the sub-list for method output_type 170 | 0, // [0:1] is the sub-list for method input_type 171 | 0, // [0:0] is the sub-list for extension type_name 172 | 0, // [0:0] is the sub-list for extension extendee 173 | 0, // [0:0] is the sub-list for field type_name 174 | } 175 | 176 | func init() { file_helloworld_v1_greeter_proto_init() } 177 | func file_helloworld_v1_greeter_proto_init() { 178 | if File_helloworld_v1_greeter_proto != nil { 179 | return 180 | } 181 | if !protoimpl.UnsafeEnabled { 182 | file_helloworld_v1_greeter_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 183 | switch v := v.(*HelloRequest); i { 184 | case 0: 185 | return &v.state 186 | case 1: 187 | return &v.sizeCache 188 | case 2: 189 | return &v.unknownFields 190 | default: 191 | return nil 192 | } 193 | } 194 | file_helloworld_v1_greeter_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 195 | switch v := v.(*HelloReply); i { 196 | case 0: 197 | return &v.state 198 | case 1: 199 | return &v.sizeCache 200 | case 2: 201 | return &v.unknownFields 202 | default: 203 | return nil 204 | } 205 | } 206 | } 207 | type x struct{} 208 | out := protoimpl.TypeBuilder{ 209 | File: protoimpl.DescBuilder{ 210 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 211 | RawDescriptor: file_helloworld_v1_greeter_proto_rawDesc, 212 | NumEnums: 0, 213 | NumMessages: 2, 214 | NumExtensions: 0, 215 | NumServices: 1, 216 | }, 217 | GoTypes: file_helloworld_v1_greeter_proto_goTypes, 218 | DependencyIndexes: file_helloworld_v1_greeter_proto_depIdxs, 219 | MessageInfos: file_helloworld_v1_greeter_proto_msgTypes, 220 | }.Build() 221 | File_helloworld_v1_greeter_proto = out.File 222 | file_helloworld_v1_greeter_proto_rawDesc = nil 223 | file_helloworld_v1_greeter_proto_goTypes = nil 224 | file_helloworld_v1_greeter_proto_depIdxs = nil 225 | } 226 | -------------------------------------------------------------------------------- /api/helloworld/v1/greeter.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package helloworld.v1; 4 | 5 | import "google/api/annotations.proto"; 6 | 7 | option go_package = "kratos-gorm-git/api/helloworld/v1;v1"; 8 | option java_multiple_files = true; 9 | option java_package = "dev.kratos.api.helloworld.v1"; 10 | option java_outer_classname = "HelloworldProtoV1"; 11 | 12 | // The greeting service definition. 13 | service Greeter { 14 | // Sends a greeting 15 | rpc SayHello (HelloRequest) returns (HelloReply) { 16 | option (google.api.http) = { 17 | get: "/helloworld/{name}" 18 | }; 19 | } 20 | } 21 | 22 | // The request message containing the user's name. 23 | message HelloRequest { 24 | string name = 1; 25 | } 26 | 27 | // The response message containing the greetings 28 | message HelloReply { 29 | string message = 1; 30 | } 31 | -------------------------------------------------------------------------------- /api/helloworld/v1/greeter_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.2.0 4 | // - protoc v3.19.3 5 | // source: helloworld/v1/greeter.proto 6 | 7 | package v1 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.32.0 or later. 19 | const _ = grpc.SupportPackageIsVersion7 20 | 21 | // GreeterClient is the client API for Greeter service. 22 | // 23 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 24 | type GreeterClient interface { 25 | // Sends a greeting 26 | SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) 27 | } 28 | 29 | type greeterClient struct { 30 | cc grpc.ClientConnInterface 31 | } 32 | 33 | func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient { 34 | return &greeterClient{cc} 35 | } 36 | 37 | func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { 38 | out := new(HelloReply) 39 | err := c.cc.Invoke(ctx, "/helloworld.v1.Greeter/SayHello", in, out, opts...) 40 | if err != nil { 41 | return nil, err 42 | } 43 | return out, nil 44 | } 45 | 46 | // GreeterServer is the server API for Greeter service. 47 | // All implementations must embed UnimplementedGreeterServer 48 | // for forward compatibility 49 | type GreeterServer interface { 50 | // Sends a greeting 51 | SayHello(context.Context, *HelloRequest) (*HelloReply, error) 52 | mustEmbedUnimplementedGreeterServer() 53 | } 54 | 55 | // UnimplementedGreeterServer must be embedded to have forward compatible implementations. 56 | type UnimplementedGreeterServer struct { 57 | } 58 | 59 | func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) { 60 | return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") 61 | } 62 | func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {} 63 | 64 | // UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service. 65 | // Use of this interface is not recommended, as added methods to GreeterServer will 66 | // result in compilation errors. 67 | type UnsafeGreeterServer interface { 68 | mustEmbedUnimplementedGreeterServer() 69 | } 70 | 71 | func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) { 72 | s.RegisterService(&Greeter_ServiceDesc, srv) 73 | } 74 | 75 | func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 76 | in := new(HelloRequest) 77 | if err := dec(in); err != nil { 78 | return nil, err 79 | } 80 | if interceptor == nil { 81 | return srv.(GreeterServer).SayHello(ctx, in) 82 | } 83 | info := &grpc.UnaryServerInfo{ 84 | Server: srv, 85 | FullMethod: "/helloworld.v1.Greeter/SayHello", 86 | } 87 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 88 | return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) 89 | } 90 | return interceptor(ctx, in, info, handler) 91 | } 92 | 93 | // Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service. 94 | // It's only intended for direct use with grpc.RegisterService, 95 | // and not to be introspected or modified (even as a copy) 96 | var Greeter_ServiceDesc = grpc.ServiceDesc{ 97 | ServiceName: "helloworld.v1.Greeter", 98 | HandlerType: (*GreeterServer)(nil), 99 | Methods: []grpc.MethodDesc{ 100 | { 101 | MethodName: "SayHello", 102 | Handler: _Greeter_SayHello_Handler, 103 | }, 104 | }, 105 | Streams: []grpc.StreamDesc{}, 106 | Metadata: "helloworld/v1/greeter.proto", 107 | } 108 | -------------------------------------------------------------------------------- /api/helloworld/v1/greeter_http.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-http. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go-http v2.1.3 4 | 5 | package v1 6 | 7 | import ( 8 | context "context" 9 | http "github.com/go-kratos/kratos/v2/transport/http" 10 | binding "github.com/go-kratos/kratos/v2/transport/http/binding" 11 | ) 12 | 13 | // This is a compile-time assertion to ensure that this generated file 14 | // is compatible with the kratos package it is being compiled against. 15 | var _ = new(context.Context) 16 | var _ = binding.EncodeURL 17 | 18 | const _ = http.SupportPackageIsVersion1 19 | 20 | type GreeterHTTPServer interface { 21 | SayHello(context.Context, *HelloRequest) (*HelloReply, error) 22 | } 23 | 24 | func RegisterGreeterHTTPServer(s *http.Server, srv GreeterHTTPServer) { 25 | r := s.Route("/") 26 | r.GET("/helloworld/{name}", _Greeter_SayHello0_HTTP_Handler(srv)) 27 | } 28 | 29 | func _Greeter_SayHello0_HTTP_Handler(srv GreeterHTTPServer) func(ctx http.Context) error { 30 | return func(ctx http.Context) error { 31 | var in HelloRequest 32 | if err := ctx.BindQuery(&in); err != nil { 33 | return err 34 | } 35 | if err := ctx.BindVars(&in); err != nil { 36 | return err 37 | } 38 | http.SetOperation(ctx, "/helloworld.v1.Greeter/SayHello") 39 | h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { 40 | return srv.SayHello(ctx, req.(*HelloRequest)) 41 | }) 42 | out, err := h(ctx, &in) 43 | if err != nil { 44 | return err 45 | } 46 | reply := out.(*HelloReply) 47 | return ctx.Result(200, reply) 48 | } 49 | } 50 | 51 | type GreeterHTTPClient interface { 52 | SayHello(ctx context.Context, req *HelloRequest, opts ...http.CallOption) (rsp *HelloReply, err error) 53 | } 54 | 55 | type GreeterHTTPClientImpl struct { 56 | cc *http.Client 57 | } 58 | 59 | func NewGreeterHTTPClient(client *http.Client) GreeterHTTPClient { 60 | return &GreeterHTTPClientImpl{client} 61 | } 62 | 63 | func (c *GreeterHTTPClientImpl) SayHello(ctx context.Context, in *HelloRequest, opts ...http.CallOption) (*HelloReply, error) { 64 | var out HelloReply 65 | pattern := "/helloworld/{name}" 66 | path := binding.EncodeURL(pattern, in, true) 67 | opts = append(opts, http.Operation("/helloworld.v1.Greeter/SayHello")) 68 | opts = append(opts, http.PathTemplate(pattern)) 69 | err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) 70 | if err != nil { 71 | return nil, err 72 | } 73 | return &out, err 74 | } 75 | -------------------------------------------------------------------------------- /cmd/kratos-gorm-git/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "github.com/go-kratos/kratos/v2" 6 | "kratos-gorm-git/define" 7 | "kratos-gorm-git/models" 8 | "os" 9 | 10 | "kratos-gorm-git/internal/conf" 11 | 12 | "github.com/go-kratos/kratos/v2/config" 13 | "github.com/go-kratos/kratos/v2/config/file" 14 | "github.com/go-kratos/kratos/v2/log" 15 | "github.com/go-kratos/kratos/v2/middleware/tracing" 16 | "github.com/go-kratos/kratos/v2/transport/grpc" 17 | "github.com/go-kratos/kratos/v2/transport/http" 18 | 19 | _ "go.uber.org/automaxprocs" 20 | ) 21 | 22 | // go build -ldflags "-X main.Version=x.y.z" 23 | var ( 24 | // Name is the name of the compiled software. 25 | Name string 26 | // Version is the version of the compiled software. 27 | Version string 28 | // flagconf is the config flag. 29 | flagconf string 30 | 31 | id, _ = os.Hostname() 32 | ) 33 | 34 | func init() { 35 | flag.StringVar(&flagconf, "conf", "../../configs", "config path, eg: -conf config.yaml") 36 | } 37 | 38 | func newApp(logger log.Logger, gs *grpc.Server, hs *http.Server) *kratos.App { 39 | return kratos.New( 40 | kratos.ID(id), 41 | kratos.Name(Name), 42 | kratos.Version(Version), 43 | kratos.Metadata(map[string]string{}), 44 | kratos.Logger(logger), 45 | kratos.Server( 46 | gs, 47 | hs, 48 | ), 49 | ) 50 | } 51 | 52 | func main() { 53 | flag.Parse() 54 | logger := log.With(log.NewStdLogger(os.Stdout), 55 | "ts", log.DefaultTimestamp, 56 | "caller", log.DefaultCaller, 57 | "service.id", id, 58 | "service.name", Name, 59 | "service.version", Version, 60 | "trace.id", tracing.TraceID(), 61 | "span.id", tracing.SpanID(), 62 | ) 63 | c := config.New( 64 | config.WithSource( 65 | file.NewSource(flagconf), 66 | ), 67 | ) 68 | defer c.Close() 69 | 70 | if err := c.Load(); err != nil { 71 | panic(err) 72 | } 73 | 74 | var bc conf.Bootstrap 75 | if err := c.Scan(&bc); err != nil { 76 | panic(err) 77 | } 78 | // init db 79 | err := models.NewDB(bc.Data.Database.Source) 80 | if err != nil { 81 | panic(err) 82 | } 83 | 84 | define.RepoPath = bc.Server.RepoPath 85 | 86 | app, cleanup, err := wireApp(bc.Server, bc.Data, logger) 87 | if err != nil { 88 | panic(err) 89 | } 90 | defer cleanup() 91 | 92 | // start and wait for stop signal 93 | if err := app.Run(); err != nil { 94 | panic(err) 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /cmd/kratos-gorm-git/wire.go: -------------------------------------------------------------------------------- 1 | //go:build wireinject 2 | // +build wireinject 3 | 4 | // The build tag makes sure the stub is not built in the final build. 5 | 6 | package main 7 | 8 | import ( 9 | "kratos-gorm-git/internal/biz" 10 | "kratos-gorm-git/internal/conf" 11 | "kratos-gorm-git/internal/data" 12 | "kratos-gorm-git/internal/server" 13 | "kratos-gorm-git/internal/service" 14 | 15 | "github.com/go-kratos/kratos/v2" 16 | "github.com/go-kratos/kratos/v2/log" 17 | "github.com/google/wire" 18 | ) 19 | 20 | // wireApp init kratos application. 21 | func wireApp(*conf.Server, *conf.Data, log.Logger) (*kratos.App, func(), error) { 22 | panic(wire.Build(server.ProviderSet, data.ProviderSet, biz.ProviderSet, service.ProviderSet, newApp)) 23 | } 24 | -------------------------------------------------------------------------------- /cmd/kratos-gorm-git/wire_gen.go: -------------------------------------------------------------------------------- 1 | // Code generated by Wire. DO NOT EDIT. 2 | 3 | //go:generate go run github.com/google/wire/cmd/wire 4 | //go:build !wireinject 5 | // +build !wireinject 6 | 7 | package main 8 | 9 | import ( 10 | "kratos-gorm-git/define" 11 | "kratos-gorm-git/internal/biz" 12 | "kratos-gorm-git/internal/conf" 13 | "kratos-gorm-git/internal/data" 14 | "kratos-gorm-git/internal/server" 15 | "kratos-gorm-git/internal/service" 16 | "net/http" 17 | 18 | server2 "github.com/asim/git-http-backend/server" 19 | "github.com/go-kratos/kratos/v2" 20 | "github.com/go-kratos/kratos/v2/log" 21 | ) 22 | 23 | // Injectors from wire.go: 24 | 25 | // wireApp init kratos application. 26 | func wireApp(confServer *conf.Server, confData *conf.Data, logger log.Logger) (*kratos.App, func(), error) { 27 | dataData, cleanup, err := data.NewData(confData, logger) 28 | if err != nil { 29 | return nil, nil, err 30 | } 31 | greeterRepo := data.NewGreeterRepo(dataData, logger) 32 | greeterUsecase := biz.NewGreeterUsecase(greeterRepo, logger) 33 | greeterService := service.NewGreeterService(greeterUsecase) 34 | grpcServer := server.NewGRPCServer(confServer, greeterService, logger) 35 | httpServer := server.NewHTTPServer(confServer, greeterService, logger) 36 | // 1. 指定仓库地址 37 | server2.DefaultConfig.ProjectRoot = define.RepoPath 38 | server2.DefaultConfig.GitBinPath = "/usr/bin/git" 39 | // 2. 指定监听的服务 40 | http.HandleFunc("/git/", service.GitHttpBackend) 41 | app := newApp(logger, grpcServer, httpServer) 42 | return app, func() { 43 | cleanup() 44 | }, nil 45 | } 46 | -------------------------------------------------------------------------------- /configs/config.yaml: -------------------------------------------------------------------------------- 1 | server: 2 | http: 3 | addr: 0.0.0.0:8000 4 | timeout: 1s 5 | grpc: 6 | addr: 0.0.0.0:9000 7 | timeout: 1s 8 | repo_path: /Users/getcharzp/Desktop/home/work/myself/git/gitee/kratos-gorm-git/repo 9 | data: 10 | database: 11 | driver: mysql 12 | source: root:abcdi2124Jcke23@tcp(192.168.1.8:3306)/up-git?charset=utf8mb4&parseTime=True&loc=Local 13 | redis: 14 | addr: 127.0.0.1:6379 15 | read_timeout: 0.2s 16 | write_timeout: 0.2s 17 | -------------------------------------------------------------------------------- /define/define.go: -------------------------------------------------------------------------------- 1 | package define 2 | 3 | // RepoPath 仓库地址 4 | var RepoPath string 5 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module kratos-gorm-git 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/go-kratos/kratos/v2 v2.4.1 7 | github.com/google/wire v0.5.0 8 | go.uber.org/automaxprocs v1.5.1 9 | google.golang.org/genproto v0.0.0-20220524023933-508584e28198 10 | google.golang.org/grpc v1.46.2 11 | google.golang.org/protobuf v1.28.0 12 | ) 13 | 14 | require ( 15 | github.com/asim/git-http-backend v0.3.0 // indirect 16 | github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect 17 | github.com/fsnotify/fsnotify v1.5.4 // indirect 18 | github.com/go-logr/logr v1.2.3 // indirect 19 | github.com/go-logr/stdr v1.2.2 // indirect 20 | github.com/go-playground/form/v4 v4.2.0 // indirect 21 | github.com/go-sql-driver/mysql v1.7.0 // indirect 22 | github.com/golang/protobuf v1.5.2 // indirect 23 | github.com/google/uuid v1.3.0 // indirect 24 | github.com/gorilla/mux v1.8.0 // indirect 25 | github.com/imdario/mergo v0.3.12 // indirect 26 | github.com/jinzhu/inflection v1.0.0 // indirect 27 | github.com/jinzhu/now v1.1.5 // indirect 28 | github.com/kr/text v0.2.0 // indirect 29 | github.com/satori/go.uuid v1.2.0 // indirect 30 | go.opentelemetry.io/otel v1.7.0 // indirect 31 | go.opentelemetry.io/otel/trace v1.7.0 // indirect 32 | golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect 33 | golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 // indirect 34 | golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect 35 | golang.org/x/text v0.3.7 // indirect 36 | gopkg.in/yaml.v3 v3.0.0 // indirect 37 | gorm.io/driver/mysql v1.4.7 // indirect 38 | gorm.io/gorm v1.24.6 // indirect 39 | ) 40 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 3 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 4 | github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= 5 | github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= 6 | github.com/asim/git-http-backend v0.3.0 h1:jGlnxcYUbK0hmzg/4A/KCzZSDvwzjjI3XxWzD1zUVag= 7 | github.com/asim/git-http-backend v0.3.0/go.mod h1:xHP8hU2RZS1aW6tkn+v/bmF2Dxll2XYp3KygCVI24GQ= 8 | github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= 9 | github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= 10 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 11 | github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= 12 | github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= 13 | github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= 14 | github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= 15 | github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= 16 | github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= 17 | github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= 18 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 19 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 20 | github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= 21 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= 22 | github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 23 | github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 24 | github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= 25 | github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= 26 | github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= 27 | github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= 28 | github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= 29 | github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= 30 | github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 31 | github.com/go-kratos/aegis v0.1.2/go.mod h1:jYeSQ3Gesba478zEnujOiG5QdsyF3Xk/8owFUeKcHxw= 32 | github.com/go-kratos/kratos/v2 v2.4.1 h1:NFQy8Ha4Xu6T3Q40JlKzspvlMa5IGvIHhJw5+sqyV4c= 33 | github.com/go-kratos/kratos/v2 v2.4.1/go.mod h1:5acyLj4EgY428AJnZl2EwCrMV1OVlttQFBum+SghMiA= 34 | github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= 35 | github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= 36 | github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= 37 | github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= 38 | github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= 39 | github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= 40 | github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= 41 | github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= 42 | github.com/go-playground/form/v4 v4.2.0 h1:N1wh+Goz61e6w66vo8vJkQt+uwZSoLz50kZPJWR8eic= 43 | github.com/go-playground/form/v4 v4.2.0/go.mod h1:q1a2BY+AQUUzhl6xA/6hBetay6dEIhMHjgvJiGo6K7U= 44 | github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= 45 | github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= 46 | github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= 47 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 48 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 49 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 50 | github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 51 | github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= 52 | github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= 53 | github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= 54 | github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= 55 | github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= 56 | github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= 57 | github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= 58 | github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= 59 | github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= 60 | github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= 61 | github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= 62 | github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= 63 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 64 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 65 | github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 66 | github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 67 | github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 68 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 69 | github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 70 | github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= 71 | github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= 72 | github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= 73 | github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 74 | github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= 75 | github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 76 | github.com/google/wire v0.5.0 h1:I7ELFeVBr3yfPIcc8+MWvrjk+3VjbcSzoXm3JVa+jD8= 77 | github.com/google/wire v0.5.0/go.mod h1:ngWDr9Qvq3yZA10YrxfyGELY/AFWGVpy9c1LTRi1EoU= 78 | github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= 79 | github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= 80 | github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= 81 | github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= 82 | github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= 83 | github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= 84 | github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= 85 | github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= 86 | github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= 87 | github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= 88 | github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= 89 | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= 90 | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 91 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 92 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 93 | github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= 94 | github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 95 | github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= 96 | github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= 97 | github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= 98 | github.com/shirou/gopsutil/v3 v3.21.8/go.mod h1:YWp/H8Qs5fVmf17v7JNZzA0mPJ+mS2e9JdiUF9LlKzQ= 99 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 100 | github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= 101 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 102 | github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= 103 | github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 104 | github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= 105 | github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= 106 | go.opentelemetry.io/otel v1.7.0 h1:Z2lA3Tdch0iDcrhJXDIlC94XE+bxok1F9B+4Lz/lGsM= 107 | go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk= 108 | go.opentelemetry.io/otel/sdk v1.7.0 h1:4OmStpcKVOfvDOgCt7UriAPtKolwIhxpnSNI/yK+1B0= 109 | go.opentelemetry.io/otel/sdk v1.7.0/go.mod h1:uTEOTwaqIVuTGiJN7ii13Ibp75wJmYUDe374q6cZwUU= 110 | go.opentelemetry.io/otel/trace v1.7.0 h1:O37Iogk1lEkMRXewVtZ1BBTVn5JEp8GrJvP92bJqC6o= 111 | go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU= 112 | go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= 113 | go.uber.org/automaxprocs v1.5.1 h1:e1YG66Lrk73dn4qhg8WFSvhF0JuFQF0ERIp4rpuV8Qk= 114 | go.uber.org/automaxprocs v1.5.1/go.mod h1:BF4eumQw0P9GtnuxxovUd06vwm1o18oMzFtK66vU6XU= 115 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 116 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 117 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 118 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 119 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= 120 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 121 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 122 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 123 | golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 124 | golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 125 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 126 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 127 | golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 128 | golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 129 | golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= 130 | golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 h1:NWy5+hlRbC7HK+PmcXVUmW1IMyFce7to56IUvhUFm7Y= 131 | golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= 132 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 133 | golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 134 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 135 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 136 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 137 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 138 | golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 h1:w8s32wxx3sY+OjLlv9qltkLU5yvJzxjjgiHWLjdIcw4= 139 | golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 140 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 141 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 142 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 143 | golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 144 | golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 145 | golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 146 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 147 | golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 148 | golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 149 | golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 150 | golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 151 | golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 152 | golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 153 | golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= 154 | golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 155 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 156 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 157 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 158 | golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 159 | golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= 160 | golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= 161 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 162 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 163 | golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= 164 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 165 | golang.org/x/tools v0.0.0-20190422233926-fe54fb35175b/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 166 | golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 167 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 168 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= 169 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 170 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 171 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 172 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 173 | google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= 174 | google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 175 | google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= 176 | google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= 177 | google.golang.org/genproto v0.0.0-20220524023933-508584e28198 h1:a1g7i05I2vUwq5eYrmxBJy6rPbw/yo7WzzwPJmcC0P4= 178 | google.golang.org/genproto v0.0.0-20220524023933-508584e28198/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= 179 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 180 | google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= 181 | google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= 182 | google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 183 | google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= 184 | google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= 185 | google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= 186 | google.golang.org/grpc v1.46.2 h1:u+MLGgVf7vRdjEYZ8wDFhAVNmhkbJ5hmrA1LMWK1CAQ= 187 | google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= 188 | google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= 189 | google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= 190 | google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= 191 | google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= 192 | google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= 193 | google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 194 | google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 195 | google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 196 | google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= 197 | google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= 198 | google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= 199 | google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= 200 | google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= 201 | google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= 202 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 203 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= 204 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 205 | gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 206 | gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= 207 | gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 208 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 209 | gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA= 210 | gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 211 | gorm.io/driver/mysql v1.4.7 h1:rY46lkCspzGHn7+IYsNpSfEv9tA+SU4SkkB+GFX125Y= 212 | gorm.io/driver/mysql v1.4.7/go.mod h1:SxzItlnT1cb6e1e4ZRpgJN2VYtcqJgqnHxWr4wsP8oc= 213 | gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= 214 | gorm.io/gorm v1.24.6 h1:wy98aq9oFEetsc4CAbKD2SoBCdMzsbSIvSUUFJuHi5s= 215 | gorm.io/gorm v1.24.6/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= 216 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 217 | honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 218 | -------------------------------------------------------------------------------- /helper/helper.go: -------------------------------------------------------------------------------- 1 | package helper 2 | 3 | import ( 4 | "crypto/md5" 5 | "fmt" 6 | "github.com/dgrijalva/jwt-go" 7 | uuid "github.com/satori/go.uuid" 8 | "math/rand" 9 | "strconv" 10 | "time" 11 | ) 12 | 13 | type UserClaims struct { 14 | Identity string `json:"identity"` 15 | Name string `json:"name"` 16 | jwt.StandardClaims 17 | } 18 | 19 | // GetMd5 20 | // 生成 md5 21 | func GetMd5(s string) string { 22 | return fmt.Sprintf("%x", md5.Sum([]byte(s))) 23 | } 24 | 25 | var myKey = []byte("gin-gorm-oj-key") 26 | 27 | // GenerateToken 28 | // 生成 token 29 | func GenerateToken(identity, name string) (string, error) { 30 | UserClaim := &UserClaims{ 31 | Identity: identity, 32 | Name: name, 33 | StandardClaims: jwt.StandardClaims{}, 34 | } 35 | token := jwt.NewWithClaims(jwt.SigningMethodHS256, UserClaim) 36 | tokenString, err := token.SignedString(myKey) 37 | if err != nil { 38 | return "", err 39 | } 40 | return tokenString, nil 41 | } 42 | 43 | // AnalyseToken 44 | // 解析 token 45 | func AnalyseToken(tokenString string) (*UserClaims, error) { 46 | userClaim := new(UserClaims) 47 | claims, err := jwt.ParseWithClaims(tokenString, userClaim, func(token *jwt.Token) (interface{}, error) { 48 | return myKey, nil 49 | }) 50 | if err != nil { 51 | return nil, err 52 | } 53 | if !claims.Valid { 54 | return nil, fmt.Errorf("analyse Token Error:%v", err) 55 | } 56 | return userClaim, nil 57 | } 58 | 59 | // GetUUID 60 | // 生成唯一码 61 | func GetUUID() string { 62 | return uuid.NewV4().String() 63 | } 64 | 65 | // GetRand 66 | // 生成验证码 67 | func GetRand() string { 68 | rand.Seed(time.Now().UnixNano()) 69 | s := "" 70 | for i := 0; i < 6; i++ { 71 | s += strconv.Itoa(rand.Intn(10)) 72 | } 73 | return s 74 | } 75 | -------------------------------------------------------------------------------- /internal/biz/README.md: -------------------------------------------------------------------------------- 1 | # Biz 2 | -------------------------------------------------------------------------------- /internal/biz/biz.go: -------------------------------------------------------------------------------- 1 | package biz 2 | 3 | import "github.com/google/wire" 4 | 5 | // ProviderSet is biz providers. 6 | var ProviderSet = wire.NewSet(NewGreeterUsecase) 7 | -------------------------------------------------------------------------------- /internal/biz/greeter.go: -------------------------------------------------------------------------------- 1 | package biz 2 | 3 | import ( 4 | "context" 5 | 6 | v1 "kratos-gorm-git/api/helloworld/v1" 7 | 8 | "github.com/go-kratos/kratos/v2/errors" 9 | "github.com/go-kratos/kratos/v2/log" 10 | ) 11 | 12 | var ( 13 | // ErrUserNotFound is user not found. 14 | ErrUserNotFound = errors.NotFound(v1.ErrorReason_USER_NOT_FOUND.String(), "user not found") 15 | ) 16 | 17 | // Greeter is a Greeter model. 18 | type Greeter struct { 19 | Hello string 20 | } 21 | 22 | // GreeterRepo is a Greater repo. 23 | type GreeterRepo interface { 24 | Save(context.Context, *Greeter) (*Greeter, error) 25 | Update(context.Context, *Greeter) (*Greeter, error) 26 | FindByID(context.Context, int64) (*Greeter, error) 27 | ListByHello(context.Context, string) ([]*Greeter, error) 28 | ListAll(context.Context) ([]*Greeter, error) 29 | } 30 | 31 | // GreeterUsecase is a Greeter usecase. 32 | type GreeterUsecase struct { 33 | repo GreeterRepo 34 | log *log.Helper 35 | } 36 | 37 | // NewGreeterUsecase new a Greeter usecase. 38 | func NewGreeterUsecase(repo GreeterRepo, logger log.Logger) *GreeterUsecase { 39 | return &GreeterUsecase{repo: repo, log: log.NewHelper(logger)} 40 | } 41 | 42 | // CreateGreeter creates a Greeter, and returns the new Greeter. 43 | func (uc *GreeterUsecase) CreateGreeter(ctx context.Context, g *Greeter) (*Greeter, error) { 44 | uc.log.WithContext(ctx).Infof("CreateGreeter: %v", g.Hello) 45 | return uc.repo.Save(ctx, g) 46 | } 47 | -------------------------------------------------------------------------------- /internal/conf/conf.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package kratos.api; 3 | 4 | option go_package = "kratos-gorm-git/internal/conf;conf"; 5 | 6 | import "google/protobuf/duration.proto"; 7 | 8 | message Bootstrap { 9 | Server server = 1; 10 | Data data = 2; 11 | } 12 | 13 | message Server { 14 | message HTTP { 15 | string network = 1; 16 | string addr = 2; 17 | google.protobuf.Duration timeout = 3; 18 | } 19 | message GRPC { 20 | string network = 1; 21 | string addr = 2; 22 | google.protobuf.Duration timeout = 3; 23 | } 24 | HTTP http = 1; 25 | GRPC grpc = 2; 26 | string repo_path = 3; 27 | } 28 | 29 | message Data { 30 | message Database { 31 | string driver = 1; 32 | string source = 2; 33 | } 34 | message Redis { 35 | string network = 1; 36 | string addr = 2; 37 | google.protobuf.Duration read_timeout = 3; 38 | google.protobuf.Duration write_timeout = 4; 39 | } 40 | Database database = 1; 41 | Redis redis = 2; 42 | } 43 | -------------------------------------------------------------------------------- /internal/data/README.md: -------------------------------------------------------------------------------- 1 | # Data 2 | -------------------------------------------------------------------------------- /internal/data/data.go: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | import ( 4 | "kratos-gorm-git/internal/conf" 5 | 6 | "github.com/go-kratos/kratos/v2/log" 7 | "github.com/google/wire" 8 | ) 9 | 10 | // ProviderSet is data providers. 11 | var ProviderSet = wire.NewSet(NewData, NewGreeterRepo) 12 | 13 | // Data . 14 | type Data struct { 15 | // TODO wrapped database client 16 | } 17 | 18 | // NewData . 19 | func NewData(c *conf.Data, logger log.Logger) (*Data, func(), error) { 20 | cleanup := func() { 21 | log.NewHelper(logger).Info("closing the data resources") 22 | } 23 | return &Data{}, cleanup, nil 24 | } 25 | -------------------------------------------------------------------------------- /internal/data/greeter.go: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | import ( 4 | "context" 5 | 6 | "kratos-gorm-git/internal/biz" 7 | 8 | "github.com/go-kratos/kratos/v2/log" 9 | ) 10 | 11 | type greeterRepo struct { 12 | data *Data 13 | log *log.Helper 14 | } 15 | 16 | // NewGreeterRepo . 17 | func NewGreeterRepo(data *Data, logger log.Logger) biz.GreeterRepo { 18 | return &greeterRepo{ 19 | data: data, 20 | log: log.NewHelper(logger), 21 | } 22 | } 23 | 24 | func (r *greeterRepo) Save(ctx context.Context, g *biz.Greeter) (*biz.Greeter, error) { 25 | return g, nil 26 | } 27 | 28 | func (r *greeterRepo) Update(ctx context.Context, g *biz.Greeter) (*biz.Greeter, error) { 29 | return g, nil 30 | } 31 | 32 | func (r *greeterRepo) FindByID(context.Context, int64) (*biz.Greeter, error) { 33 | return nil, nil 34 | } 35 | 36 | func (r *greeterRepo) ListByHello(context.Context, string) ([]*biz.Greeter, error) { 37 | return nil, nil 38 | } 39 | 40 | func (r *greeterRepo) ListAll(context.Context) ([]*biz.Greeter, error) { 41 | return nil, nil 42 | } 43 | -------------------------------------------------------------------------------- /internal/server/grpc.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | v1 "kratos-gorm-git/api/helloworld/v1" 5 | "kratos-gorm-git/internal/conf" 6 | "kratos-gorm-git/internal/service" 7 | 8 | "github.com/go-kratos/kratos/v2/log" 9 | "github.com/go-kratos/kratos/v2/middleware/recovery" 10 | "github.com/go-kratos/kratos/v2/transport/grpc" 11 | ) 12 | 13 | // NewGRPCServer new a gRPC server. 14 | func NewGRPCServer(c *conf.Server, greeter *service.GreeterService, logger log.Logger) *grpc.Server { 15 | var opts = []grpc.ServerOption{ 16 | grpc.Middleware( 17 | recovery.Recovery(), 18 | ), 19 | } 20 | if c.Grpc.Network != "" { 21 | opts = append(opts, grpc.Network(c.Grpc.Network)) 22 | } 23 | if c.Grpc.Addr != "" { 24 | opts = append(opts, grpc.Address(c.Grpc.Addr)) 25 | } 26 | if c.Grpc.Timeout != nil { 27 | opts = append(opts, grpc.Timeout(c.Grpc.Timeout.AsDuration())) 28 | } 29 | srv := grpc.NewServer(opts...) 30 | v1.RegisterGreeterServer(srv, greeter) 31 | return srv 32 | } 33 | -------------------------------------------------------------------------------- /internal/server/http.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "github.com/go-kratos/kratos/v2/middleware/selector" 5 | "kratos-gorm-git/api/git" 6 | v1 "kratos-gorm-git/api/helloworld/v1" 7 | "kratos-gorm-git/internal/conf" 8 | "kratos-gorm-git/internal/service" 9 | "kratos-gorm-git/middleware" 10 | 11 | "github.com/go-kratos/kratos/v2/log" 12 | "github.com/go-kratos/kratos/v2/middleware/recovery" 13 | "github.com/go-kratos/kratos/v2/transport/http" 14 | ) 15 | 16 | // NewHTTPServer new an HTTP server. 17 | func NewHTTPServer(c *conf.Server, greeter *service.GreeterService, logger log.Logger) *http.Server { 18 | var opts = []http.ServerOption{ 19 | http.Middleware( 20 | recovery.Recovery(), 21 | selector.Server(middleware.Auth()).Path("/api.git.Repo/CreateRepo", "/api.git.Repo/RepoAuth").Build(), 22 | ), 23 | } 24 | if c.Http.Network != "" { 25 | opts = append(opts, http.Network(c.Http.Network)) 26 | } 27 | if c.Http.Addr != "" { 28 | opts = append(opts, http.Address(c.Http.Addr)) 29 | } 30 | if c.Http.Timeout != nil { 31 | opts = append(opts, http.Timeout(c.Http.Timeout.AsDuration())) 32 | } 33 | srv := http.NewServer(opts...) 34 | v1.RegisterGreeterHTTPServer(srv, greeter) 35 | git.RegisterUserHTTPServer(srv, service.NewUserService()) 36 | git.RegisterRepoHTTPServer(srv, service.NewRepoService()) 37 | return srv 38 | } 39 | -------------------------------------------------------------------------------- /internal/server/server.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "github.com/google/wire" 5 | ) 6 | 7 | // ProviderSet is server providers. 8 | var ProviderSet = wire.NewSet(NewGRPCServer, NewHTTPServer) 9 | -------------------------------------------------------------------------------- /internal/service/README.md: -------------------------------------------------------------------------------- 1 | # Service 2 | -------------------------------------------------------------------------------- /internal/service/git.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "github.com/asim/git-http-backend/server" 5 | "kratos-gorm-git/helper" 6 | "kratos-gorm-git/models" 7 | "net/http" 8 | "os" 9 | "strings" 10 | ) 11 | 12 | func GitHttpBackend(w http.ResponseWriter, r *http.Request) { 13 | // 1. 获取仓库的基础信息 14 | r.URL.Path = strings.TrimPrefix(r.URL.Path, "/git") 15 | repoPaths := strings.Split(r.URL.Path, "/") 16 | if len(repoPaths) < 3 { 17 | w.Write([]byte("error request")) 18 | w.WriteHeader(http.StatusBadRequest) 19 | return 20 | } 21 | repoPath := repoPaths[1] + string(os.PathSeparator) + repoPaths[2] 22 | rb := new(models.RepoBasic) 23 | ub := new(models.UserBasic) 24 | err := models.DB.Model(new(models.RepoBasic)).Where("path = ?", repoPath).First(rb).Error 25 | if err != nil { 26 | w.Write([]byte("sys error")) 27 | w.WriteHeader(http.StatusBadGateway) 28 | return 29 | } 30 | // 2. clone || push 31 | if repoPaths[3] == "git-upload-pack" || repoPaths[3] == "git-receive-pack" { 32 | if rb.Type == 0 { 33 | // 获取用户的基础信息 34 | auth := r.Header.Get("Authorization") 35 | if auth == "" { 36 | w.Header().Set("WWW-Authenticate", `Basic realm="Git Repository"`) 37 | http.Error(w, "Unauthorized", http.StatusUnauthorized) 38 | return 39 | } 40 | username, password, _ := r.BasicAuth() 41 | err = models.DB.Model(new(models.UserBasic)).Where("username = ? AND password = ?", username, helper.GetMd5(password)).First(ub).Error 42 | if err != nil { 43 | w.Write([]byte("sys error")) 44 | w.WriteHeader(http.StatusBadGateway) 45 | return 46 | } 47 | // 获取授权信息 48 | var cnt int64 49 | err = models.DB.Model(new(models.RepoUser)).Where("rid = ? AND uid = ?", rb.ID, ub.ID).Count(&cnt).Error 50 | if err != nil { 51 | w.Write([]byte("sys error")) 52 | w.WriteHeader(http.StatusBadGateway) 53 | return 54 | } 55 | if cnt == 0 { 56 | w.Write([]byte("no auth")) 57 | w.WriteHeader(http.StatusUnauthorized) 58 | return 59 | } 60 | } 61 | } 62 | server.Handler().ServeHTTP(w, r) 63 | } 64 | -------------------------------------------------------------------------------- /internal/service/greeter.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "context" 5 | 6 | v1 "kratos-gorm-git/api/helloworld/v1" 7 | "kratos-gorm-git/internal/biz" 8 | ) 9 | 10 | // GreeterService is a greeter service. 11 | type GreeterService struct { 12 | v1.UnimplementedGreeterServer 13 | 14 | uc *biz.GreeterUsecase 15 | } 16 | 17 | // NewGreeterService new a greeter service. 18 | func NewGreeterService(uc *biz.GreeterUsecase) *GreeterService { 19 | return &GreeterService{uc: uc} 20 | } 21 | 22 | // SayHello implements helloworld.GreeterServer. 23 | func (s *GreeterService) SayHello(ctx context.Context, in *v1.HelloRequest) (*v1.HelloReply, error) { 24 | g, err := s.uc.CreateGreeter(ctx, &biz.Greeter{Hello: in.Name}) 25 | if err != nil { 26 | return nil, err 27 | } 28 | return &v1.HelloReply{Message: "Hello " + g.Hello}, nil 29 | } 30 | -------------------------------------------------------------------------------- /internal/service/repo.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | "github.com/go-kratos/kratos/v2/metadata" 7 | "gorm.io/gorm" 8 | pb "kratos-gorm-git/api/git" 9 | "kratos-gorm-git/define" 10 | "kratos-gorm-git/helper" 11 | "kratos-gorm-git/models" 12 | "os" 13 | "os/exec" 14 | ) 15 | 16 | type RepoService struct { 17 | pb.UnimplementedRepoServer 18 | } 19 | 20 | func NewRepoService() *RepoService { 21 | return &RepoService{} 22 | } 23 | 24 | func (s *RepoService) CreateRepo(ctx context.Context, req *pb.CreateRepoRequest) (*pb.CreateRepoReply, error) { 25 | // 获取用户的基础信息 26 | md, exit := metadata.FromServerContext(ctx) 27 | if !exit { 28 | return nil, errors.New("no auth") 29 | } 30 | userIdentity := md.Get("identity") 31 | ub := new(models.UserBasic) 32 | err := models.DB.Model(new(models.UserBasic)).Where("identity = ?", userIdentity).First(ub).Error 33 | if err != nil { 34 | return nil, err 35 | } 36 | // 1. 查重 37 | var cnt int64 38 | err = models.DB.Model(new(models.RepoBasic)).Where("path = ?", req.Path).Count(&cnt).Error 39 | if err != nil { 40 | return nil, err 41 | } 42 | if cnt > 0 { 43 | return nil, errors.New("路径已存在") 44 | } 45 | // 2. 落库 46 | rb := &models.RepoBasic{ 47 | Identity: helper.GetUUID(), 48 | Path: req.Path, 49 | Name: req.Name, 50 | Desc: req.Desc, 51 | Type: int(req.Type), 52 | } 53 | ru := &models.RepoUser{ 54 | Uid: ub.ID, 55 | Type: 1, 56 | } 57 | err = models.DB.Transaction(func(tx *gorm.DB) error { 58 | err = tx.Create(rb).Error 59 | if err != nil { 60 | return err 61 | } 62 | ru.Rid = rb.ID 63 | err = tx.Create(ru).Error 64 | if err != nil { 65 | return err 66 | } 67 | // init repo path 68 | // mkdir path 69 | gitRepoPath := define.RepoPath + string(os.PathSeparator) + req.Path 70 | err = os.MkdirAll(gitRepoPath, 0755) 71 | if err != nil { 72 | return err 73 | } 74 | // git init --bare 75 | cmd := exec.Command("/bin/bash", "-c", "cd "+gitRepoPath+" ; git init --bare") 76 | err = cmd.Run() 77 | if err != nil { 78 | return err 79 | } 80 | return nil 81 | }) 82 | if err != nil { 83 | return nil, err 84 | } 85 | 86 | return &pb.CreateRepoReply{}, nil 87 | } 88 | func (s *RepoService) UpdateRepo(ctx context.Context, req *pb.UpdateRepoRequest) (*pb.UpdateRepoReply, error) { 89 | err := models.DB.Model(new(models.RepoBasic)).Where("identity = ?", req.Identity).Updates(map[string]interface{}{ 90 | "name": req.Name, 91 | "desc": req.Desc, 92 | "type": req.Type, 93 | }).Error 94 | if err != nil { 95 | return nil, err 96 | } 97 | return &pb.UpdateRepoReply{}, nil 98 | } 99 | func (s *RepoService) DeleteRepo(ctx context.Context, req *pb.DeleteRepoRequest) (*pb.DeleteRepoReply, error) { 100 | // 1. 获取仓库的基础信息 101 | var rb = new(models.RepoBasic) 102 | err := models.DB.Model(new(models.RepoBasic)).Where("identity = ?", req.Identity).First(rb).Error 103 | if err != nil { 104 | return nil, err 105 | } 106 | // 2. 删除记录 107 | err = models.DB.Transaction(func(tx *gorm.DB) error { 108 | // 2.1 删除仓库数据 109 | err = os.RemoveAll(define.RepoPath + string(os.PathSeparator) + rb.Path) 110 | if err != nil { 111 | return err 112 | } 113 | // 2.2 删除DB记录 114 | err = tx.Where("identity = ?", req.Identity).Delete(new(models.RepoBasic)).Error 115 | if err != nil { 116 | return err 117 | } 118 | return nil 119 | }) 120 | if err != nil { 121 | return nil, err 122 | } 123 | return &pb.DeleteRepoReply{}, nil 124 | } 125 | func (s *RepoService) GetRepo(ctx context.Context, req *pb.GetRepoRequest) (*pb.GetRepoReply, error) { 126 | return &pb.GetRepoReply{}, nil 127 | } 128 | func (s *RepoService) ListRepo(ctx context.Context, req *pb.ListRepoRequest) (*pb.ListRepoReply, error) { 129 | rb := make([]*models.RepoBasic, 0) 130 | var cnt int64 131 | err := models.DB.Model(new(models.RepoBasic)).Count(&cnt).Offset(int((req.Page - 1) * req.Size)).Limit(int(req.Size)). 132 | Find(&rb).Error 133 | if err != nil { 134 | return nil, err 135 | } 136 | list := make([]*pb.ListRepoItem, 0, len(rb)) 137 | for _, v := range rb { 138 | list = append(list, &pb.ListRepoItem{ 139 | Identity: v.Identity, 140 | Name: v.Name, 141 | Desc: v.Desc, 142 | Path: v.Path, 143 | Star: v.Star, 144 | }) 145 | } 146 | return &pb.ListRepoReply{ 147 | List: list, 148 | Cnt: cnt, 149 | }, nil 150 | } 151 | func (s *RepoService) RepoAuth(ctx context.Context, req *pb.RepoAuthRequest) (*pb.RepoAuthReply, error) { 152 | // 获取当前用户的信息 153 | md, exit := metadata.FromServerContext(ctx) 154 | if !exit { 155 | return nil, errors.New("no auth") 156 | } 157 | userIdentity := md.Get("identity") 158 | ub := new(models.UserBasic) 159 | err := models.DB.Model(new(models.UserBasic)).Where("identity = ?", userIdentity).First(ub).Error 160 | if err != nil { 161 | return nil, err 162 | } 163 | // 获取被授权的用户信息 164 | ubAuth := new(models.UserBasic) 165 | err = models.DB.Model(new(models.UserBasic)).Where("identity = ?", req.UserIdentity).First(ubAuth).Error 166 | if err != nil { 167 | return nil, err 168 | } 169 | // 获取仓库信息 170 | rb := new(models.RepoBasic) 171 | err = models.DB.Model(new(models.RepoBasic)).Where("identity = ?", req.RepoIdentity).First(&rb).Error 172 | if err != nil { 173 | return nil, err 174 | } 175 | // 判断当前用户的权限 176 | var cnt int64 177 | err = models.DB.Model(new(models.RepoUser)).Where("rid = ? AND uid = ? AND type = 1", rb.ID, ub.ID).Count(&cnt).Error 178 | if err != nil { 179 | return nil, err 180 | } 181 | if cnt == 0 { 182 | return nil, errors.New("非法操作") 183 | } 184 | // 判断是否已有权限 185 | err = models.DB.Model(new(models.RepoUser)).Where("rid = ? AND uid = ?", rb.ID, ubAuth.ID).Count(&cnt).Error 186 | if err != nil { 187 | return nil, err 188 | } 189 | if cnt > 0 { 190 | return &pb.RepoAuthReply{}, nil 191 | } 192 | // 入库 193 | err = models.DB.Create(&models.RepoUser{ 194 | Rid: rb.ID, 195 | Uid: ubAuth.ID, 196 | Type: 2, 197 | }).Error 198 | if err != nil { 199 | return nil, err 200 | } 201 | 202 | return &pb.RepoAuthReply{}, nil 203 | } 204 | -------------------------------------------------------------------------------- /internal/service/service.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import "github.com/google/wire" 4 | 5 | // ProviderSet is service providers. 6 | var ProviderSet = wire.NewSet(NewGreeterService) 7 | -------------------------------------------------------------------------------- /internal/service/user.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "context" 5 | "kratos-gorm-git/helper" 6 | "kratos-gorm-git/models" 7 | 8 | pb "kratos-gorm-git/api/git" 9 | ) 10 | 11 | type UserService struct { 12 | pb.UnimplementedUserServer 13 | } 14 | 15 | func NewUserService() *UserService { 16 | return &UserService{} 17 | } 18 | 19 | func (s *UserService) Login(ctx context.Context, req *pb.LoginRequest) (*pb.LoginReply, error) { 20 | ub := new(models.UserBasic) 21 | err := models.DB.Where("username = ? AND password = ?", req.Username, helper.GetMd5(req.Password)).First(ub).Error 22 | if err != nil { 23 | return nil, err 24 | } 25 | token, err := helper.GenerateToken(ub.Identity, ub.Username) 26 | if err != nil { 27 | return nil, err 28 | } 29 | return &pb.LoginReply{ 30 | Token: token, 31 | }, nil 32 | } 33 | -------------------------------------------------------------------------------- /middleware/auth.go: -------------------------------------------------------------------------------- 1 | package middleware 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | "github.com/go-kratos/kratos/v2/metadata" 7 | "github.com/go-kratos/kratos/v2/middleware" 8 | "github.com/go-kratos/kratos/v2/transport" 9 | "kratos-gorm-git/helper" 10 | ) 11 | 12 | func Auth() middleware.Middleware { 13 | return func(handler middleware.Handler) middleware.Handler { 14 | return func(ctx context.Context, req interface{}) (reply interface{}, err error) { 15 | if tr, ok := transport.FromServerContext(ctx); ok { 16 | auth := tr.RequestHeader().Get("Authorization") 17 | if auth == "" { 18 | return nil, errors.New("no auth") 19 | } 20 | userClaims, err := helper.AnalyseToken(auth) 21 | if err != nil { 22 | return nil, err 23 | } 24 | if userClaims.Identity == "" { 25 | return nil, errors.New("no auth") 26 | } 27 | ctx = metadata.NewServerContext(ctx, metadata.New(map[string]string{ 28 | "username": userClaims.Name, 29 | "identity": userClaims.Identity, 30 | })) 31 | } 32 | return handler(ctx, req) 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /models/init.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | "gorm.io/driver/mysql" 5 | "gorm.io/gorm" 6 | ) 7 | 8 | var DB *gorm.DB 9 | 10 | func NewDB(dsn string) error { 11 | db, err := gorm.Open(mysql.Open(dsn)) 12 | if err != nil { 13 | return err 14 | } 15 | err = db.AutoMigrate(&UserBasic{}, &RepoBasic{}, &RepoUser{}) 16 | if err != nil { 17 | return err 18 | } 19 | DB = db 20 | return nil 21 | } 22 | -------------------------------------------------------------------------------- /models/repo_basic.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "gorm.io/gorm" 4 | 5 | type RepoBasic struct { 6 | gorm.Model 7 | Identity string `gorm:"column:identity;type:varchar(36);" json:"identity"` // 唯一标识 8 | Path string `gorm:"column:path;type:varchar(255);" json:"path"` // 仓库路径 9 | Name string `gorm:"column:name;type:varchar(255);" json:"name"` // Name 10 | Desc string `gorm:"column:desc;type:varchar(255);" json:"desc"` // Desc 11 | Star int64 `gorm:"column:star;type:int(11);default:0;" json:"star"` // Star 12 | Type int `gorm:"column:type;type:tinyint(1);" json:"type"` // 类型,{1:公库 0:私库} 13 | } 14 | 15 | func (table *RepoBasic) TableName() string { 16 | return "repo_basic" 17 | } 18 | -------------------------------------------------------------------------------- /models/repo_star.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "gorm.io/gorm" 4 | 5 | type RepoStar struct { 6 | gorm.Model 7 | Rid int `gorm:"column:rid;type:int(11);" json:"rid"` // 仓库ID 8 | Uid int `gorm:"column:uid;type:int(11);" json:"uid"` // 用户ID 9 | } 10 | 11 | func (table *RepoStar) TableName() string { 12 | return "repo_star" 13 | } 14 | -------------------------------------------------------------------------------- /models/repo_user.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "gorm.io/gorm" 4 | 5 | type RepoUser struct { 6 | gorm.Model 7 | Rid uint `gorm:"column:rid;type:int(11);" json:"rid"` // 仓库ID 8 | Uid uint `gorm:"column:uid;type:int(11);" json:"uid"` // 用户ID 9 | Type int `gorm:"column:type;type:tinyint(1);" json:"type"` // 类型,{1:所有者 2:被授权者} 10 | } 11 | 12 | func (table *RepoUser) TableName() string { 13 | return "repo_user" 14 | } 15 | -------------------------------------------------------------------------------- /models/user_basic.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "gorm.io/gorm" 4 | 5 | type UserBasic struct { 6 | gorm.Model 7 | Identity string `gorm:"column:identity;type:varchar(36);" json:"identity"` // 唯一标识 8 | Username string `gorm:"column:username;type:varchar(255);" json:"username"` // 用户名 9 | Password string `gorm:"column:password;type:varchar(36);" json:"password"` // 密码 10 | Email string `gorm:"column:email;type:varchar(100);" json:"email"` // 电子邮箱 11 | } 12 | 13 | func (table *UserBasic) TableName() string { 14 | return "user_basic" 15 | } 16 | -------------------------------------------------------------------------------- /openapi.yaml: -------------------------------------------------------------------------------- 1 | # Generated with protoc-gen-openapi 2 | # https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi 3 | 4 | openapi: 3.0.3 5 | info: 6 | title: Repo API 7 | version: 0.0.1 8 | paths: 9 | /repo/auth: 10 | post: 11 | tags: 12 | - Repo 13 | operationId: Repo_RepoAuth 14 | requestBody: 15 | content: 16 | application/json: 17 | schema: 18 | $ref: '#/components/schemas/RepoAuthRequest' 19 | required: true 20 | responses: 21 | "200": 22 | description: OK 23 | content: 24 | application/json: 25 | schema: 26 | $ref: '#/components/schemas/RepoAuthReply' 27 | default: 28 | description: Default error response 29 | content: 30 | application/json: 31 | schema: 32 | $ref: '#/components/schemas/Status' 33 | /repo/create: 34 | post: 35 | tags: 36 | - Repo 37 | operationId: Repo_CreateRepo 38 | requestBody: 39 | content: 40 | application/json: 41 | schema: 42 | $ref: '#/components/schemas/CreateRepoRequest' 43 | required: true 44 | responses: 45 | "200": 46 | description: OK 47 | content: 48 | application/json: 49 | schema: 50 | $ref: '#/components/schemas/CreateRepoReply' 51 | default: 52 | description: Default error response 53 | content: 54 | application/json: 55 | schema: 56 | $ref: '#/components/schemas/Status' 57 | /repo/delete: 58 | delete: 59 | tags: 60 | - Repo 61 | operationId: Repo_DeleteRepo 62 | parameters: 63 | - name: identity 64 | in: query 65 | schema: 66 | type: string 67 | responses: 68 | "200": 69 | description: OK 70 | content: 71 | application/json: 72 | schema: 73 | $ref: '#/components/schemas/DeleteRepoReply' 74 | default: 75 | description: Default error response 76 | content: 77 | application/json: 78 | schema: 79 | $ref: '#/components/schemas/Status' 80 | /repo/list: 81 | get: 82 | tags: 83 | - Repo 84 | operationId: Repo_ListRepo 85 | parameters: 86 | - name: page 87 | in: query 88 | schema: 89 | type: integer 90 | format: int64 91 | - name: size 92 | in: query 93 | schema: 94 | type: integer 95 | format: int64 96 | responses: 97 | "200": 98 | description: OK 99 | content: 100 | application/json: 101 | schema: 102 | $ref: '#/components/schemas/ListRepoReply' 103 | default: 104 | description: Default error response 105 | content: 106 | application/json: 107 | schema: 108 | $ref: '#/components/schemas/Status' 109 | /repo/update: 110 | put: 111 | tags: 112 | - Repo 113 | operationId: Repo_UpdateRepo 114 | requestBody: 115 | content: 116 | application/json: 117 | schema: 118 | $ref: '#/components/schemas/UpdateRepoRequest' 119 | required: true 120 | responses: 121 | "200": 122 | description: OK 123 | content: 124 | application/json: 125 | schema: 126 | $ref: '#/components/schemas/UpdateRepoReply' 127 | default: 128 | description: Default error response 129 | content: 130 | application/json: 131 | schema: 132 | $ref: '#/components/schemas/Status' 133 | components: 134 | schemas: 135 | CreateRepoReply: 136 | type: object 137 | properties: {} 138 | CreateRepoRequest: 139 | type: object 140 | properties: 141 | name: 142 | type: string 143 | desc: 144 | type: string 145 | path: 146 | type: string 147 | type: 148 | type: integer 149 | format: int32 150 | DeleteRepoReply: 151 | type: object 152 | properties: {} 153 | GoogleProtobufAny: 154 | type: object 155 | properties: 156 | '@type': 157 | type: string 158 | description: The type of the serialized message. 159 | additionalProperties: true 160 | description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. 161 | ListRepoItem: 162 | type: object 163 | properties: 164 | identity: 165 | type: string 166 | name: 167 | type: string 168 | desc: 169 | type: string 170 | path: 171 | type: string 172 | star: 173 | type: integer 174 | format: int64 175 | ListRepoReply: 176 | type: object 177 | properties: 178 | cnt: 179 | type: integer 180 | format: int64 181 | list: 182 | type: array 183 | items: 184 | $ref: '#/components/schemas/ListRepoItem' 185 | RepoAuthReply: 186 | type: object 187 | properties: {} 188 | RepoAuthRequest: 189 | type: object 190 | properties: 191 | repoIdentity: 192 | type: string 193 | userIdentity: 194 | type: string 195 | Status: 196 | type: object 197 | properties: 198 | code: 199 | type: integer 200 | description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. 201 | format: int32 202 | message: 203 | type: string 204 | description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. 205 | details: 206 | type: array 207 | items: 208 | $ref: '#/components/schemas/GoogleProtobufAny' 209 | description: A list of messages that carry the error details. There is a common set of message types for APIs to use. 210 | description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' 211 | UpdateRepoReply: 212 | type: object 213 | properties: {} 214 | UpdateRepoRequest: 215 | type: object 216 | properties: 217 | identity: 218 | type: string 219 | name: 220 | type: string 221 | desc: 222 | type: string 223 | type: 224 | type: integer 225 | format: int32 226 | tags: 227 | - name: Repo 228 | -------------------------------------------------------------------------------- /third_party/README.md: -------------------------------------------------------------------------------- 1 | # third_party 2 | -------------------------------------------------------------------------------- /third_party/errors/errors.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package errors; 4 | 5 | option go_package = "github.com/go-kratos/kratos/v2/errors;errors"; 6 | option java_multiple_files = true; 7 | option java_package = "com.github.kratos.errors"; 8 | option objc_class_prefix = "KratosErrors"; 9 | 10 | import "google/protobuf/descriptor.proto"; 11 | 12 | extend google.protobuf.EnumOptions { 13 | int32 default_code = 1108; 14 | } 15 | 16 | extend google.protobuf.EnumValueOptions { 17 | int32 code = 1109; 18 | } -------------------------------------------------------------------------------- /third_party/google/api/annotations.proto: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/api/http.proto"; 20 | import "google/protobuf/descriptor.proto"; 21 | 22 | option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; 23 | option java_multiple_files = true; 24 | option java_outer_classname = "AnnotationsProto"; 25 | option java_package = "com.google.api"; 26 | option objc_class_prefix = "GAPI"; 27 | 28 | extend google.protobuf.MethodOptions { 29 | // See `HttpRule`. 30 | HttpRule http = 72295728; 31 | } 32 | -------------------------------------------------------------------------------- /third_party/google/api/client.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/protobuf/descriptor.proto"; 20 | 21 | option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; 22 | option java_multiple_files = true; 23 | option java_outer_classname = "ClientProto"; 24 | option java_package = "com.google.api"; 25 | option objc_class_prefix = "GAPI"; 26 | 27 | 28 | extend google.protobuf.ServiceOptions { 29 | // The hostname for this service. 30 | // This should be specified with no prefix or protocol. 31 | // 32 | // Example: 33 | // 34 | // service Foo { 35 | // option (google.api.default_host) = "foo.googleapi.com"; 36 | // ... 37 | // } 38 | string default_host = 1049; 39 | 40 | // OAuth scopes needed for the client. 41 | // 42 | // Example: 43 | // 44 | // service Foo { 45 | // option (google.api.oauth_scopes) = \ 46 | // "https://www.googleapis.com/auth/cloud-platform"; 47 | // ... 48 | // } 49 | // 50 | // If there is more than one scope, use a comma-separated string: 51 | // 52 | // Example: 53 | // 54 | // service Foo { 55 | // option (google.api.oauth_scopes) = \ 56 | // "https://www.googleapis.com/auth/cloud-platform," 57 | // "https://www.googleapis.com/auth/monitoring"; 58 | // ... 59 | // } 60 | string oauth_scopes = 1050; 61 | } 62 | 63 | 64 | extend google.protobuf.MethodOptions { 65 | // A definition of a client library method signature. 66 | // 67 | // In client libraries, each proto RPC corresponds to one or more methods 68 | // which the end user is able to call, and calls the underlying RPC. 69 | // Normally, this method receives a single argument (a struct or instance 70 | // corresponding to the RPC request object). Defining this field will 71 | // add one or more overloads providing flattened or simpler method signatures 72 | // in some languages. 73 | // 74 | // The fields on the method signature are provided as a comma-separated 75 | // string. 76 | // 77 | // For example, the proto RPC and annotation: 78 | // 79 | // rpc CreateSubscription(CreateSubscriptionRequest) 80 | // returns (Subscription) { 81 | // option (google.api.method_signature) = "name,topic"; 82 | // } 83 | // 84 | // Would add the following Java overload (in addition to the method accepting 85 | // the request object): 86 | // 87 | // public final Subscription createSubscription(String name, String topic) 88 | // 89 | // The following backwards-compatibility guidelines apply: 90 | // 91 | // * Adding this annotation to an unannotated method is backwards 92 | // compatible. 93 | // * Adding this annotation to a method which already has existing 94 | // method signature annotations is backwards compatible if and only if 95 | // the new method signature annotation is last in the sequence. 96 | // * Modifying or removing an existing method signature annotation is 97 | // a breaking change. 98 | // * Re-ordering existing method signature annotations is a breaking 99 | // change. 100 | repeated string method_signature = 1051; 101 | } -------------------------------------------------------------------------------- /third_party/google/api/field_behavior.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/protobuf/descriptor.proto"; 20 | 21 | option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; 22 | option java_multiple_files = true; 23 | option java_outer_classname = "FieldBehaviorProto"; 24 | option java_package = "com.google.api"; 25 | option objc_class_prefix = "GAPI"; 26 | 27 | 28 | // An indicator of the behavior of a given field (for example, that a field 29 | // is required in requests, or given as output but ignored as input). 30 | // This **does not** change the behavior in protocol buffers itself; it only 31 | // denotes the behavior and may affect how API tooling handles the field. 32 | // 33 | // Note: This enum **may** receive new values in the future. 34 | enum FieldBehavior { 35 | // Conventional default for enums. Do not use this. 36 | FIELD_BEHAVIOR_UNSPECIFIED = 0; 37 | 38 | // Specifically denotes a field as optional. 39 | // While all fields in protocol buffers are optional, this may be specified 40 | // for emphasis if appropriate. 41 | OPTIONAL = 1; 42 | 43 | // Denotes a field as required. 44 | // This indicates that the field **must** be provided as part of the request, 45 | // and failure to do so will cause an error (usually `INVALID_ARGUMENT`). 46 | REQUIRED = 2; 47 | 48 | // Denotes a field as output only. 49 | // This indicates that the field is provided in responses, but including the 50 | // field in a request does nothing (the server *must* ignore it and 51 | // *must not* throw an error as a result of the field's presence). 52 | OUTPUT_ONLY = 3; 53 | 54 | // Denotes a field as input only. 55 | // This indicates that the field is provided in requests, and the 56 | // corresponding field is not included in output. 57 | INPUT_ONLY = 4; 58 | 59 | // Denotes a field as immutable. 60 | // This indicates that the field may be set once in a request to create a 61 | // resource, but may not be changed thereafter. 62 | IMMUTABLE = 5; 63 | } 64 | 65 | 66 | extend google.protobuf.FieldOptions { 67 | // A designation of a specific field behavior (required, output only, etc.) 68 | // in protobuf messages. 69 | // 70 | // Examples: 71 | // 72 | // string name = 1 [(google.api.field_behavior) = REQUIRED]; 73 | // State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; 74 | // google.protobuf.Duration ttl = 1 75 | // [(google.api.field_behavior) = INPUT_ONLY]; 76 | // google.protobuf.Timestamp expire_time = 1 77 | // [(google.api.field_behavior) = OUTPUT_ONLY, 78 | // (google.api.field_behavior) = IMMUTABLE]; 79 | repeated FieldBehavior field_behavior = 1052; 80 | } -------------------------------------------------------------------------------- /third_party/google/api/http.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | option cc_enable_arenas = true; 20 | option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; 21 | option java_multiple_files = true; 22 | option java_outer_classname = "HttpProto"; 23 | option java_package = "com.google.api"; 24 | option objc_class_prefix = "GAPI"; 25 | 26 | // Defines the HTTP configuration for an API service. It contains a list of 27 | // [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method 28 | // to one or more HTTP REST API methods. 29 | message Http { 30 | // A list of HTTP configuration rules that apply to individual API methods. 31 | // 32 | // **NOTE:** All service configuration rules follow "last one wins" order. 33 | repeated HttpRule rules = 1; 34 | 35 | // When set to true, URL path parameters will be fully URI-decoded except in 36 | // cases of single segment matches in reserved expansion, where "%2F" will be 37 | // left encoded. 38 | // 39 | // The default behavior is to not decode RFC 6570 reserved characters in multi 40 | // segment matches. 41 | bool fully_decode_reserved_expansion = 2; 42 | } 43 | 44 | // # gRPC Transcoding 45 | // 46 | // gRPC Transcoding is a feature for mapping between a gRPC method and one or 47 | // more HTTP REST endpoints. It allows developers to build a single API service 48 | // that supports both gRPC APIs and REST APIs. Many systems, including [Google 49 | // APIs](https://github.com/googleapis/googleapis), 50 | // [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC 51 | // Gateway](https://github.com/grpc-ecosystem/grpc-gateway), 52 | // and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature 53 | // and use it for large scale production services. 54 | // 55 | // `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies 56 | // how different portions of the gRPC request message are mapped to the URL 57 | // path, URL query parameters, and HTTP request body. It also controls how the 58 | // gRPC response message is mapped to the HTTP response body. `HttpRule` is 59 | // typically specified as an `google.api.http` annotation on the gRPC method. 60 | // 61 | // Each mapping specifies a URL path template and an HTTP method. The path 62 | // template may refer to one or more fields in the gRPC request message, as long 63 | // as each field is a non-repeated field with a primitive (non-message) type. 64 | // The path template controls how fields of the request message are mapped to 65 | // the URL path. 66 | // 67 | // Example: 68 | // 69 | // service Messaging { 70 | // rpc GetMessage(GetMessageRequest) returns (Message) { 71 | // option (google.api.http) = { 72 | // get: "/v1/{name=messages/*}" 73 | // }; 74 | // } 75 | // } 76 | // message GetMessageRequest { 77 | // string name = 1; // Mapped to URL path. 78 | // } 79 | // message Message { 80 | // string text = 1; // The resource content. 81 | // } 82 | // 83 | // This enables an HTTP REST to gRPC mapping as below: 84 | // 85 | // HTTP | gRPC 86 | // -----|----- 87 | // `GET /v1/messages/123456` | `GetMessage(name: "messages/123456")` 88 | // 89 | // Any fields in the request message which are not bound by the path template 90 | // automatically become HTTP query parameters if there is no HTTP request body. 91 | // For example: 92 | // 93 | // service Messaging { 94 | // rpc GetMessage(GetMessageRequest) returns (Message) { 95 | // option (google.api.http) = { 96 | // get:"/v1/messages/{message_id}" 97 | // }; 98 | // } 99 | // } 100 | // message GetMessageRequest { 101 | // message SubMessage { 102 | // string subfield = 1; 103 | // } 104 | // string message_id = 1; // Mapped to URL path. 105 | // int64 revision = 2; // Mapped to URL query parameter `revision`. 106 | // SubMessage sub = 3; // Mapped to URL query parameter `sub.subfield`. 107 | // } 108 | // 109 | // This enables a HTTP JSON to RPC mapping as below: 110 | // 111 | // HTTP | gRPC 112 | // -----|----- 113 | // `GET /v1/messages/123456?revision=2&sub.subfield=foo` | 114 | // `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: 115 | // "foo"))` 116 | // 117 | // Note that fields which are mapped to URL query parameters must have a 118 | // primitive type or a repeated primitive type or a non-repeated message type. 119 | // In the case of a repeated type, the parameter can be repeated in the URL 120 | // as `...?param=A¶m=B`. In the case of a message type, each field of the 121 | // message is mapped to a separate parameter, such as 122 | // `...?foo.a=A&foo.b=B&foo.c=C`. 123 | // 124 | // For HTTP methods that allow a request body, the `body` field 125 | // specifies the mapping. Consider a REST update method on the 126 | // message resource collection: 127 | // 128 | // service Messaging { 129 | // rpc UpdateMessage(UpdateMessageRequest) returns (Message) { 130 | // option (google.api.http) = { 131 | // patch: "/v1/messages/{message_id}" 132 | // body: "message" 133 | // }; 134 | // } 135 | // } 136 | // message UpdateMessageRequest { 137 | // string message_id = 1; // mapped to the URL 138 | // Message message = 2; // mapped to the body 139 | // } 140 | // 141 | // The following HTTP JSON to RPC mapping is enabled, where the 142 | // representation of the JSON in the request body is determined by 143 | // protos JSON encoding: 144 | // 145 | // HTTP | gRPC 146 | // -----|----- 147 | // `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: 148 | // "123456" message { text: "Hi!" })` 149 | // 150 | // The special name `*` can be used in the body mapping to define that 151 | // every field not bound by the path template should be mapped to the 152 | // request body. This enables the following alternative definition of 153 | // the update method: 154 | // 155 | // service Messaging { 156 | // rpc UpdateMessage(Message) returns (Message) { 157 | // option (google.api.http) = { 158 | // patch: "/v1/messages/{message_id}" 159 | // body: "*" 160 | // }; 161 | // } 162 | // } 163 | // message Message { 164 | // string message_id = 1; 165 | // string text = 2; 166 | // } 167 | // 168 | // 169 | // The following HTTP JSON to RPC mapping is enabled: 170 | // 171 | // HTTP | gRPC 172 | // -----|----- 173 | // `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: 174 | // "123456" text: "Hi!")` 175 | // 176 | // Note that when using `*` in the body mapping, it is not possible to 177 | // have HTTP parameters, as all fields not bound by the path end in 178 | // the body. This makes this option more rarely used in practice when 179 | // defining REST APIs. The common usage of `*` is in custom methods 180 | // which don't use the URL at all for transferring data. 181 | // 182 | // It is possible to define multiple HTTP methods for one RPC by using 183 | // the `additional_bindings` option. Example: 184 | // 185 | // service Messaging { 186 | // rpc GetMessage(GetMessageRequest) returns (Message) { 187 | // option (google.api.http) = { 188 | // get: "/v1/messages/{message_id}" 189 | // additional_bindings { 190 | // get: "/v1/users/{user_id}/messages/{message_id}" 191 | // } 192 | // }; 193 | // } 194 | // } 195 | // message GetMessageRequest { 196 | // string message_id = 1; 197 | // string user_id = 2; 198 | // } 199 | // 200 | // This enables the following two alternative HTTP JSON to RPC mappings: 201 | // 202 | // HTTP | gRPC 203 | // -----|----- 204 | // `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` 205 | // `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: 206 | // "123456")` 207 | // 208 | // ## Rules for HTTP mapping 209 | // 210 | // 1. Leaf request fields (recursive expansion nested messages in the request 211 | // message) are classified into three categories: 212 | // - Fields referred by the path template. They are passed via the URL path. 213 | // - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They are passed via the HTTP 214 | // request body. 215 | // - All other fields are passed via the URL query parameters, and the 216 | // parameter name is the field path in the request message. A repeated 217 | // field can be represented as multiple query parameters under the same 218 | // name. 219 | // 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL query parameter, all fields 220 | // are passed via URL path and HTTP request body. 221 | // 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP request body, all 222 | // fields are passed via URL path and URL query parameters. 223 | // 224 | // ### Path template syntax 225 | // 226 | // Template = "/" Segments [ Verb ] ; 227 | // Segments = Segment { "/" Segment } ; 228 | // Segment = "*" | "**" | LITERAL | Variable ; 229 | // Variable = "{" FieldPath [ "=" Segments ] "}" ; 230 | // FieldPath = IDENT { "." IDENT } ; 231 | // Verb = ":" LITERAL ; 232 | // 233 | // The syntax `*` matches a single URL path segment. The syntax `**` matches 234 | // zero or more URL path segments, which must be the last part of the URL path 235 | // except the `Verb`. 236 | // 237 | // The syntax `Variable` matches part of the URL path as specified by its 238 | // template. A variable template must not contain other variables. If a variable 239 | // matches a single path segment, its template may be omitted, e.g. `{var}` 240 | // is equivalent to `{var=*}`. 241 | // 242 | // The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL` 243 | // contains any reserved character, such characters should be percent-encoded 244 | // before the matching. 245 | // 246 | // If a variable contains exactly one path segment, such as `"{var}"` or 247 | // `"{var=*}"`, when such a variable is expanded into a URL path on the client 248 | // side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The 249 | // server side does the reverse decoding. Such variables show up in the 250 | // [Discovery 251 | // Document](https://developers.google.com/discovery/v1/reference/apis) as 252 | // `{var}`. 253 | // 254 | // If a variable contains multiple path segments, such as `"{var=foo/*}"` 255 | // or `"{var=**}"`, when such a variable is expanded into a URL path on the 256 | // client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. 257 | // The server side does the reverse decoding, except "%2F" and "%2f" are left 258 | // unchanged. Such variables show up in the 259 | // [Discovery 260 | // Document](https://developers.google.com/discovery/v1/reference/apis) as 261 | // `{+var}`. 262 | // 263 | // ## Using gRPC API Service Configuration 264 | // 265 | // gRPC API Service Configuration (service config) is a configuration language 266 | // for configuring a gRPC service to become a user-facing product. The 267 | // service config is simply the YAML representation of the `google.api.Service` 268 | // proto message. 269 | // 270 | // As an alternative to annotating your proto file, you can configure gRPC 271 | // transcoding in your service config YAML files. You do this by specifying a 272 | // `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same 273 | // effect as the proto annotation. This can be particularly useful if you 274 | // have a proto that is reused in multiple services. Note that any transcoding 275 | // specified in the service config will override any matching transcoding 276 | // configuration in the proto. 277 | // 278 | // Example: 279 | // 280 | // http: 281 | // rules: 282 | // # Selects a gRPC method and applies HttpRule to it. 283 | // - selector: example.v1.Messaging.GetMessage 284 | // get: /v1/messages/{message_id}/{sub.subfield} 285 | // 286 | // ## Special notes 287 | // 288 | // When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the 289 | // proto to JSON conversion must follow the [proto3 290 | // specification](https://developers.google.com/protocol-buffers/docs/proto3#json). 291 | // 292 | // While the single segment variable follows the semantics of 293 | // [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String 294 | // Expansion, the multi segment variable **does not** follow RFC 6570 Section 295 | // 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion 296 | // does not expand special characters like `?` and `#`, which would lead 297 | // to invalid URLs. As the result, gRPC Transcoding uses a custom encoding 298 | // for multi segment variables. 299 | // 300 | // The path variables **must not** refer to any repeated or mapped field, 301 | // because client libraries are not capable of handling such variable expansion. 302 | // 303 | // The path variables **must not** capture the leading "/" character. The reason 304 | // is that the most common use case "{var}" does not capture the leading "/" 305 | // character. For consistency, all path variables must share the same behavior. 306 | // 307 | // Repeated message fields must not be mapped to URL query parameters, because 308 | // no client library can support such complicated mapping. 309 | // 310 | // If an API needs to use a JSON array for request or response body, it can map 311 | // the request or response body to a repeated field. However, some gRPC 312 | // Transcoding implementations may not support this feature. 313 | message HttpRule { 314 | // Selects a method to which this rule applies. 315 | // 316 | // Refer to [selector][google.api.DocumentationRule.selector] for syntax details. 317 | string selector = 1; 318 | 319 | // Determines the URL pattern is matched by this rules. This pattern can be 320 | // used with any of the {get|put|post|delete|patch} methods. A custom method 321 | // can be defined using the 'custom' field. 322 | oneof pattern { 323 | // Maps to HTTP GET. Used for listing and getting information about 324 | // resources. 325 | string get = 2; 326 | 327 | // Maps to HTTP PUT. Used for replacing a resource. 328 | string put = 3; 329 | 330 | // Maps to HTTP POST. Used for creating a resource or performing an action. 331 | string post = 4; 332 | 333 | // Maps to HTTP DELETE. Used for deleting a resource. 334 | string delete = 5; 335 | 336 | // Maps to HTTP PATCH. Used for updating a resource. 337 | string patch = 6; 338 | 339 | // The custom pattern is used for specifying an HTTP method that is not 340 | // included in the `pattern` field, such as HEAD, or "*" to leave the 341 | // HTTP method unspecified for this rule. The wild-card rule is useful 342 | // for services that provide content to Web (HTML) clients. 343 | CustomHttpPattern custom = 8; 344 | } 345 | 346 | // The name of the request field whose value is mapped to the HTTP request 347 | // body, or `*` for mapping all request fields not captured by the path 348 | // pattern to the HTTP body, or omitted for not having any HTTP request body. 349 | // 350 | // NOTE: the referred field must be present at the top-level of the request 351 | // message type. 352 | string body = 7; 353 | 354 | // Optional. The name of the response field whose value is mapped to the HTTP 355 | // response body. When omitted, the entire response message will be used 356 | // as the HTTP response body. 357 | // 358 | // NOTE: The referred field must be present at the top-level of the response 359 | // message type. 360 | string response_body = 12; 361 | 362 | // Additional HTTP bindings for the selector. Nested bindings must 363 | // not contain an `additional_bindings` field themselves (that is, 364 | // the nesting may only be one level deep). 365 | repeated HttpRule additional_bindings = 11; 366 | } 367 | 368 | // A custom pattern is used for defining custom HTTP verb. 369 | message CustomHttpPattern { 370 | // The name of this custom HTTP verb. 371 | string kind = 1; 372 | 373 | // The path matched by this custom verb. 374 | string path = 2; 375 | } 376 | -------------------------------------------------------------------------------- /third_party/google/api/httpbody.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/protobuf/any.proto"; 20 | 21 | option cc_enable_arenas = true; 22 | option go_package = "google.golang.org/genproto/googleapis/api/httpbody;httpbody"; 23 | option java_multiple_files = true; 24 | option java_outer_classname = "HttpBodyProto"; 25 | option java_package = "com.google.api"; 26 | option objc_class_prefix = "GAPI"; 27 | 28 | // Message that represents an arbitrary HTTP body. It should only be used for 29 | // payload formats that can't be represented as JSON, such as raw binary or 30 | // an HTML page. 31 | // 32 | // 33 | // This message can be used both in streaming and non-streaming API methods in 34 | // the request as well as the response. 35 | // 36 | // It can be used as a top-level request field, which is convenient if one 37 | // wants to extract parameters from either the URL or HTTP template into the 38 | // request fields and also want access to the raw HTTP body. 39 | // 40 | // Example: 41 | // 42 | // message GetResourceRequest { 43 | // // A unique request id. 44 | // string request_id = 1; 45 | // 46 | // // The raw HTTP body is bound to this field. 47 | // google.api.HttpBody http_body = 2; 48 | // } 49 | // 50 | // service ResourceService { 51 | // rpc GetResource(GetResourceRequest) returns (google.api.HttpBody); 52 | // rpc UpdateResource(google.api.HttpBody) returns 53 | // (google.protobuf.Empty); 54 | // } 55 | // 56 | // Example with streaming methods: 57 | // 58 | // service CaldavService { 59 | // rpc GetCalendar(stream google.api.HttpBody) 60 | // returns (stream google.api.HttpBody); 61 | // rpc UpdateCalendar(stream google.api.HttpBody) 62 | // returns (stream google.api.HttpBody); 63 | // } 64 | // 65 | // Use of this type only changes how the request and response bodies are 66 | // handled, all other features will continue to work unchanged. 67 | message HttpBody { 68 | // The HTTP Content-Type header value specifying the content type of the body. 69 | string content_type = 1; 70 | 71 | // The HTTP request/response body as raw binary. 72 | bytes data = 2; 73 | 74 | // Application specific response metadata. Must be set in the first response 75 | // for streaming APIs. 76 | repeated google.protobuf.Any extensions = 3; 77 | } 78 | -------------------------------------------------------------------------------- /third_party/google/protobuf/any.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option go_package = "google.golang.org/protobuf/types/known/anypb"; 37 | option java_package = "com.google.protobuf"; 38 | option java_outer_classname = "AnyProto"; 39 | option java_multiple_files = true; 40 | option objc_class_prefix = "GPB"; 41 | 42 | // `Any` contains an arbitrary serialized protocol buffer message along with a 43 | // URL that describes the type of the serialized message. 44 | // 45 | // Protobuf library provides support to pack/unpack Any values in the form 46 | // of utility functions or additional generated methods of the Any type. 47 | // 48 | // Example 1: Pack and unpack a message in C++. 49 | // 50 | // Foo foo = ...; 51 | // Any any; 52 | // any.PackFrom(foo); 53 | // ... 54 | // if (any.UnpackTo(&foo)) { 55 | // ... 56 | // } 57 | // 58 | // Example 2: Pack and unpack a message in Java. 59 | // 60 | // Foo foo = ...; 61 | // Any any = Any.pack(foo); 62 | // ... 63 | // if (any.is(Foo.class)) { 64 | // foo = any.unpack(Foo.class); 65 | // } 66 | // 67 | // Example 3: Pack and unpack a message in Python. 68 | // 69 | // foo = Foo(...) 70 | // any = Any() 71 | // any.Pack(foo) 72 | // ... 73 | // if any.Is(Foo.DESCRIPTOR): 74 | // any.Unpack(foo) 75 | // ... 76 | // 77 | // Example 4: Pack and unpack a message in Go 78 | // 79 | // foo := &pb.Foo{...} 80 | // any, err := anypb.New(foo) 81 | // if err != nil { 82 | // ... 83 | // } 84 | // ... 85 | // foo := &pb.Foo{} 86 | // if err := any.UnmarshalTo(foo); err != nil { 87 | // ... 88 | // } 89 | // 90 | // The pack methods provided by protobuf library will by default use 91 | // 'type.googleapis.com/full.type.name' as the type URL and the unpack 92 | // methods only use the fully qualified type name after the last '/' 93 | // in the type URL, for example "foo.bar.com/x/y.z" will yield type 94 | // name "y.z". 95 | // 96 | // 97 | // JSON 98 | // 99 | // The JSON representation of an `Any` value uses the regular 100 | // representation of the deserialized, embedded message, with an 101 | // additional field `@type` which contains the type URL. Example: 102 | // 103 | // package google.profile; 104 | // message Person { 105 | // string first_name = 1; 106 | // string last_name = 2; 107 | // } 108 | // 109 | // { 110 | // "@type": "type.googleapis.com/google.profile.Person", 111 | // "firstName": , 112 | // "lastName": 113 | // } 114 | // 115 | // If the embedded message type is well-known and has a custom JSON 116 | // representation, that representation will be embedded adding a field 117 | // `value` which holds the custom JSON in addition to the `@type` 118 | // field. Example (for message [google.protobuf.Duration][]): 119 | // 120 | // { 121 | // "@type": "type.googleapis.com/google.protobuf.Duration", 122 | // "value": "1.212s" 123 | // } 124 | // 125 | message Any { 126 | // A URL/resource name that uniquely identifies the type of the serialized 127 | // protocol buffer message. This string must contain at least 128 | // one "/" character. The last segment of the URL's path must represent 129 | // the fully qualified name of the type (as in 130 | // `path/google.protobuf.Duration`). The name should be in a canonical form 131 | // (e.g., leading "." is not accepted). 132 | // 133 | // In practice, teams usually precompile into the binary all types that they 134 | // expect it to use in the context of Any. However, for URLs which use the 135 | // scheme `http`, `https`, or no scheme, one can optionally set up a type 136 | // server that maps type URLs to message definitions as follows: 137 | // 138 | // * If no scheme is provided, `https` is assumed. 139 | // * An HTTP GET on the URL must yield a [google.protobuf.Type][] 140 | // value in binary format, or produce an error. 141 | // * Applications are allowed to cache lookup results based on the 142 | // URL, or have them precompiled into a binary to avoid any 143 | // lookup. Therefore, binary compatibility needs to be preserved 144 | // on changes to types. (Use versioned type names to manage 145 | // breaking changes.) 146 | // 147 | // Note: this functionality is not currently available in the official 148 | // protobuf release, and it is not used for type URLs beginning with 149 | // type.googleapis.com. 150 | // 151 | // Schemes other than `http`, `https` (or the empty scheme) might be 152 | // used with implementation specific semantics. 153 | // 154 | string type_url = 1; 155 | 156 | // Must be a valid serialized protocol buffer of the above specified type. 157 | bytes value = 2; 158 | } 159 | -------------------------------------------------------------------------------- /third_party/google/protobuf/api.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | import "google/protobuf/source_context.proto"; 36 | import "google/protobuf/type.proto"; 37 | 38 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 39 | option java_package = "com.google.protobuf"; 40 | option java_outer_classname = "ApiProto"; 41 | option java_multiple_files = true; 42 | option objc_class_prefix = "GPB"; 43 | option go_package = "google.golang.org/protobuf/types/known/apipb"; 44 | 45 | // Api is a light-weight descriptor for an API Interface. 46 | // 47 | // Interfaces are also described as "protocol buffer services" in some contexts, 48 | // such as by the "service" keyword in a .proto file, but they are different 49 | // from API Services, which represent a concrete implementation of an interface 50 | // as opposed to simply a description of methods and bindings. They are also 51 | // sometimes simply referred to as "APIs" in other contexts, such as the name of 52 | // this message itself. See https://cloud.google.com/apis/design/glossary for 53 | // detailed terminology. 54 | message Api { 55 | // The fully qualified name of this interface, including package name 56 | // followed by the interface's simple name. 57 | string name = 1; 58 | 59 | // The methods of this interface, in unspecified order. 60 | repeated Method methods = 2; 61 | 62 | // Any metadata attached to the interface. 63 | repeated Option options = 3; 64 | 65 | // A version string for this interface. If specified, must have the form 66 | // `major-version.minor-version`, as in `1.10`. If the minor version is 67 | // omitted, it defaults to zero. If the entire version field is empty, the 68 | // major version is derived from the package name, as outlined below. If the 69 | // field is not empty, the version in the package name will be verified to be 70 | // consistent with what is provided here. 71 | // 72 | // The versioning schema uses [semantic 73 | // versioning](http://semver.org) where the major version number 74 | // indicates a breaking change and the minor version an additive, 75 | // non-breaking change. Both version numbers are signals to users 76 | // what to expect from different versions, and should be carefully 77 | // chosen based on the product plan. 78 | // 79 | // The major version is also reflected in the package name of the 80 | // interface, which must end in `v`, as in 81 | // `google.feature.v1`. For major versions 0 and 1, the suffix can 82 | // be omitted. Zero major versions must only be used for 83 | // experimental, non-GA interfaces. 84 | // 85 | // 86 | string version = 4; 87 | 88 | // Source context for the protocol buffer service represented by this 89 | // message. 90 | SourceContext source_context = 5; 91 | 92 | // Included interfaces. See [Mixin][]. 93 | repeated Mixin mixins = 6; 94 | 95 | // The source syntax of the service. 96 | Syntax syntax = 7; 97 | } 98 | 99 | // Method represents a method of an API interface. 100 | message Method { 101 | // The simple name of this method. 102 | string name = 1; 103 | 104 | // A URL of the input message type. 105 | string request_type_url = 2; 106 | 107 | // If true, the request is streamed. 108 | bool request_streaming = 3; 109 | 110 | // The URL of the output message type. 111 | string response_type_url = 4; 112 | 113 | // If true, the response is streamed. 114 | bool response_streaming = 5; 115 | 116 | // Any metadata attached to the method. 117 | repeated Option options = 6; 118 | 119 | // The source syntax of this method. 120 | Syntax syntax = 7; 121 | } 122 | 123 | // Declares an API Interface to be included in this interface. The including 124 | // interface must redeclare all the methods from the included interface, but 125 | // documentation and options are inherited as follows: 126 | // 127 | // - If after comment and whitespace stripping, the documentation 128 | // string of the redeclared method is empty, it will be inherited 129 | // from the original method. 130 | // 131 | // - Each annotation belonging to the service config (http, 132 | // visibility) which is not set in the redeclared method will be 133 | // inherited. 134 | // 135 | // - If an http annotation is inherited, the path pattern will be 136 | // modified as follows. Any version prefix will be replaced by the 137 | // version of the including interface plus the [root][] path if 138 | // specified. 139 | // 140 | // Example of a simple mixin: 141 | // 142 | // package google.acl.v1; 143 | // service AccessControl { 144 | // // Get the underlying ACL object. 145 | // rpc GetAcl(GetAclRequest) returns (Acl) { 146 | // option (google.api.http).get = "/v1/{resource=**}:getAcl"; 147 | // } 148 | // } 149 | // 150 | // package google.storage.v2; 151 | // service Storage { 152 | // rpc GetAcl(GetAclRequest) returns (Acl); 153 | // 154 | // // Get a data record. 155 | // rpc GetData(GetDataRequest) returns (Data) { 156 | // option (google.api.http).get = "/v2/{resource=**}"; 157 | // } 158 | // } 159 | // 160 | // Example of a mixin configuration: 161 | // 162 | // apis: 163 | // - name: google.storage.v2.Storage 164 | // mixins: 165 | // - name: google.acl.v1.AccessControl 166 | // 167 | // The mixin construct implies that all methods in `AccessControl` are 168 | // also declared with same name and request/response types in 169 | // `Storage`. A documentation generator or annotation processor will 170 | // see the effective `Storage.GetAcl` method after inheriting 171 | // documentation and annotations as follows: 172 | // 173 | // service Storage { 174 | // // Get the underlying ACL object. 175 | // rpc GetAcl(GetAclRequest) returns (Acl) { 176 | // option (google.api.http).get = "/v2/{resource=**}:getAcl"; 177 | // } 178 | // ... 179 | // } 180 | // 181 | // Note how the version in the path pattern changed from `v1` to `v2`. 182 | // 183 | // If the `root` field in the mixin is specified, it should be a 184 | // relative path under which inherited HTTP paths are placed. Example: 185 | // 186 | // apis: 187 | // - name: google.storage.v2.Storage 188 | // mixins: 189 | // - name: google.acl.v1.AccessControl 190 | // root: acls 191 | // 192 | // This implies the following inherited HTTP annotation: 193 | // 194 | // service Storage { 195 | // // Get the underlying ACL object. 196 | // rpc GetAcl(GetAclRequest) returns (Acl) { 197 | // option (google.api.http).get = "/v2/acls/{resource=**}:getAcl"; 198 | // } 199 | // ... 200 | // } 201 | message Mixin { 202 | // The fully qualified name of the interface which is included. 203 | string name = 1; 204 | 205 | // If non-empty specifies a path under which inherited HTTP paths 206 | // are rooted. 207 | string root = 2; 208 | } 209 | -------------------------------------------------------------------------------- /third_party/google/protobuf/compiler/plugin.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: kenton@google.com (Kenton Varda) 32 | // 33 | // WARNING: The plugin interface is currently EXPERIMENTAL and is subject to 34 | // change. 35 | // 36 | // protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is 37 | // just a program that reads a CodeGeneratorRequest from stdin and writes a 38 | // CodeGeneratorResponse to stdout. 39 | // 40 | // Plugins written using C++ can use google/protobuf/compiler/plugin.h instead 41 | // of dealing with the raw protocol defined here. 42 | // 43 | // A plugin executable needs only to be placed somewhere in the path. The 44 | // plugin should be named "protoc-gen-$NAME", and will then be used when the 45 | // flag "--${NAME}_out" is passed to protoc. 46 | 47 | syntax = "proto2"; 48 | 49 | package google.protobuf.compiler; 50 | option java_package = "com.google.protobuf.compiler"; 51 | option java_outer_classname = "PluginProtos"; 52 | 53 | option go_package = "google.golang.org/protobuf/types/pluginpb"; 54 | 55 | import "google/protobuf/descriptor.proto"; 56 | 57 | // The version number of protocol compiler. 58 | message Version { 59 | optional int32 major = 1; 60 | optional int32 minor = 2; 61 | optional int32 patch = 3; 62 | // A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should 63 | // be empty for mainline stable releases. 64 | optional string suffix = 4; 65 | } 66 | 67 | // An encoded CodeGeneratorRequest is written to the plugin's stdin. 68 | message CodeGeneratorRequest { 69 | // The .proto files that were explicitly listed on the command-line. The 70 | // code generator should generate code only for these files. Each file's 71 | // descriptor will be included in proto_file, below. 72 | repeated string file_to_generate = 1; 73 | 74 | // The generator parameter passed on the command-line. 75 | optional string parameter = 2; 76 | 77 | // FileDescriptorProtos for all files in files_to_generate and everything 78 | // they import. The files will appear in topological order, so each file 79 | // appears before any file that imports it. 80 | // 81 | // protoc guarantees that all proto_files will be written after 82 | // the fields above, even though this is not technically guaranteed by the 83 | // protobuf wire format. This theoretically could allow a plugin to stream 84 | // in the FileDescriptorProtos and handle them one by one rather than read 85 | // the entire set into memory at once. However, as of this writing, this 86 | // is not similarly optimized on protoc's end -- it will store all fields in 87 | // memory at once before sending them to the plugin. 88 | // 89 | // Type names of fields and extensions in the FileDescriptorProto are always 90 | // fully qualified. 91 | repeated FileDescriptorProto proto_file = 15; 92 | 93 | // The version number of protocol compiler. 94 | optional Version compiler_version = 3; 95 | 96 | } 97 | 98 | // The plugin writes an encoded CodeGeneratorResponse to stdout. 99 | message CodeGeneratorResponse { 100 | // Error message. If non-empty, code generation failed. The plugin process 101 | // should exit with status code zero even if it reports an error in this way. 102 | // 103 | // This should be used to indicate errors in .proto files which prevent the 104 | // code generator from generating correct code. Errors which indicate a 105 | // problem in protoc itself -- such as the input CodeGeneratorRequest being 106 | // unparseable -- should be reported by writing a message to stderr and 107 | // exiting with a non-zero status code. 108 | optional string error = 1; 109 | 110 | // A bitmask of supported features that the code generator supports. 111 | // This is a bitwise "or" of values from the Feature enum. 112 | optional uint64 supported_features = 2; 113 | 114 | // Sync with code_generator.h. 115 | enum Feature { 116 | FEATURE_NONE = 0; 117 | FEATURE_PROTO3_OPTIONAL = 1; 118 | } 119 | 120 | // Represents a single generated file. 121 | message File { 122 | // The file name, relative to the output directory. The name must not 123 | // contain "." or ".." components and must be relative, not be absolute (so, 124 | // the file cannot lie outside the output directory). "/" must be used as 125 | // the path separator, not "\". 126 | // 127 | // If the name is omitted, the content will be appended to the previous 128 | // file. This allows the generator to break large files into small chunks, 129 | // and allows the generated text to be streamed back to protoc so that large 130 | // files need not reside completely in memory at one time. Note that as of 131 | // this writing protoc does not optimize for this -- it will read the entire 132 | // CodeGeneratorResponse before writing files to disk. 133 | optional string name = 1; 134 | 135 | // If non-empty, indicates that the named file should already exist, and the 136 | // content here is to be inserted into that file at a defined insertion 137 | // point. This feature allows a code generator to extend the output 138 | // produced by another code generator. The original generator may provide 139 | // insertion points by placing special annotations in the file that look 140 | // like: 141 | // @@protoc_insertion_point(NAME) 142 | // The annotation can have arbitrary text before and after it on the line, 143 | // which allows it to be placed in a comment. NAME should be replaced with 144 | // an identifier naming the point -- this is what other generators will use 145 | // as the insertion_point. Code inserted at this point will be placed 146 | // immediately above the line containing the insertion point (thus multiple 147 | // insertions to the same point will come out in the order they were added). 148 | // The double-@ is intended to make it unlikely that the generated code 149 | // could contain things that look like insertion points by accident. 150 | // 151 | // For example, the C++ code generator places the following line in the 152 | // .pb.h files that it generates: 153 | // // @@protoc_insertion_point(namespace_scope) 154 | // This line appears within the scope of the file's package namespace, but 155 | // outside of any particular class. Another plugin can then specify the 156 | // insertion_point "namespace_scope" to generate additional classes or 157 | // other declarations that should be placed in this scope. 158 | // 159 | // Note that if the line containing the insertion point begins with 160 | // whitespace, the same whitespace will be added to every line of the 161 | // inserted text. This is useful for languages like Python, where 162 | // indentation matters. In these languages, the insertion point comment 163 | // should be indented the same amount as any inserted code will need to be 164 | // in order to work correctly in that context. 165 | // 166 | // The code generator that generates the initial file and the one which 167 | // inserts into it must both run as part of a single invocation of protoc. 168 | // Code generators are executed in the order in which they appear on the 169 | // command line. 170 | // 171 | // If |insertion_point| is present, |name| must also be present. 172 | optional string insertion_point = 2; 173 | 174 | // The file contents. 175 | optional string content = 15; 176 | 177 | // Information describing the file content being inserted. If an insertion 178 | // point is used, this information will be appropriately offset and inserted 179 | // into the code generation metadata for the generated files. 180 | optional GeneratedCodeInfo generated_code_info = 16; 181 | } 182 | repeated File file = 15; 183 | } 184 | -------------------------------------------------------------------------------- /third_party/google/protobuf/duration.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option cc_enable_arenas = true; 37 | option go_package = "google.golang.org/protobuf/types/known/durationpb"; 38 | option java_package = "com.google.protobuf"; 39 | option java_outer_classname = "DurationProto"; 40 | option java_multiple_files = true; 41 | option objc_class_prefix = "GPB"; 42 | 43 | // A Duration represents a signed, fixed-length span of time represented 44 | // as a count of seconds and fractions of seconds at nanosecond 45 | // resolution. It is independent of any calendar and concepts like "day" 46 | // or "month". It is related to Timestamp in that the difference between 47 | // two Timestamp values is a Duration and it can be added or subtracted 48 | // from a Timestamp. Range is approximately +-10,000 years. 49 | // 50 | // # Examples 51 | // 52 | // Example 1: Compute Duration from two Timestamps in pseudo code. 53 | // 54 | // Timestamp start = ...; 55 | // Timestamp end = ...; 56 | // Duration duration = ...; 57 | // 58 | // duration.seconds = end.seconds - start.seconds; 59 | // duration.nanos = end.nanos - start.nanos; 60 | // 61 | // if (duration.seconds < 0 && duration.nanos > 0) { 62 | // duration.seconds += 1; 63 | // duration.nanos -= 1000000000; 64 | // } else if (duration.seconds > 0 && duration.nanos < 0) { 65 | // duration.seconds -= 1; 66 | // duration.nanos += 1000000000; 67 | // } 68 | // 69 | // Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. 70 | // 71 | // Timestamp start = ...; 72 | // Duration duration = ...; 73 | // Timestamp end = ...; 74 | // 75 | // end.seconds = start.seconds + duration.seconds; 76 | // end.nanos = start.nanos + duration.nanos; 77 | // 78 | // if (end.nanos < 0) { 79 | // end.seconds -= 1; 80 | // end.nanos += 1000000000; 81 | // } else if (end.nanos >= 1000000000) { 82 | // end.seconds += 1; 83 | // end.nanos -= 1000000000; 84 | // } 85 | // 86 | // Example 3: Compute Duration from datetime.timedelta in Python. 87 | // 88 | // td = datetime.timedelta(days=3, minutes=10) 89 | // duration = Duration() 90 | // duration.FromTimedelta(td) 91 | // 92 | // # JSON Mapping 93 | // 94 | // In JSON format, the Duration type is encoded as a string rather than an 95 | // object, where the string ends in the suffix "s" (indicating seconds) and 96 | // is preceded by the number of seconds, with nanoseconds expressed as 97 | // fractional seconds. For example, 3 seconds with 0 nanoseconds should be 98 | // encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should 99 | // be expressed in JSON format as "3.000000001s", and 3 seconds and 1 100 | // microsecond should be expressed in JSON format as "3.000001s". 101 | // 102 | // 103 | message Duration { 104 | // Signed seconds of the span of time. Must be from -315,576,000,000 105 | // to +315,576,000,000 inclusive. Note: these bounds are computed from: 106 | // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years 107 | int64 seconds = 1; 108 | 109 | // Signed fractions of a second at nanosecond resolution of the span 110 | // of time. Durations less than one second are represented with a 0 111 | // `seconds` field and a positive or negative `nanos` field. For durations 112 | // of one second or more, a non-zero value for the `nanos` field must be 113 | // of the same sign as the `seconds` field. Must be from -999,999,999 114 | // to +999,999,999 inclusive. 115 | int32 nanos = 2; 116 | } 117 | -------------------------------------------------------------------------------- /third_party/google/protobuf/empty.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option go_package = "google.golang.org/protobuf/types/known/emptypb"; 37 | option java_package = "com.google.protobuf"; 38 | option java_outer_classname = "EmptyProto"; 39 | option java_multiple_files = true; 40 | option objc_class_prefix = "GPB"; 41 | option cc_enable_arenas = true; 42 | 43 | // A generic empty message that you can re-use to avoid defining duplicated 44 | // empty messages in your APIs. A typical example is to use it as the request 45 | // or the response type of an API method. For instance: 46 | // 47 | // service Foo { 48 | // rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); 49 | // } 50 | // 51 | // The JSON representation for `Empty` is empty JSON object `{}`. 52 | message Empty {} 53 | -------------------------------------------------------------------------------- /third_party/google/protobuf/field_mask.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option java_package = "com.google.protobuf"; 37 | option java_outer_classname = "FieldMaskProto"; 38 | option java_multiple_files = true; 39 | option objc_class_prefix = "GPB"; 40 | option go_package = "google.golang.org/protobuf/types/known/fieldmaskpb"; 41 | option cc_enable_arenas = true; 42 | 43 | // `FieldMask` represents a set of symbolic field paths, for example: 44 | // 45 | // paths: "f.a" 46 | // paths: "f.b.d" 47 | // 48 | // Here `f` represents a field in some root message, `a` and `b` 49 | // fields in the message found in `f`, and `d` a field found in the 50 | // message in `f.b`. 51 | // 52 | // Field masks are used to specify a subset of fields that should be 53 | // returned by a get operation or modified by an update operation. 54 | // Field masks also have a custom JSON encoding (see below). 55 | // 56 | // # Field Masks in Projections 57 | // 58 | // When used in the context of a projection, a response message or 59 | // sub-message is filtered by the API to only contain those fields as 60 | // specified in the mask. For example, if the mask in the previous 61 | // example is applied to a response message as follows: 62 | // 63 | // f { 64 | // a : 22 65 | // b { 66 | // d : 1 67 | // x : 2 68 | // } 69 | // y : 13 70 | // } 71 | // z: 8 72 | // 73 | // The result will not contain specific values for fields x,y and z 74 | // (their value will be set to the default, and omitted in proto text 75 | // output): 76 | // 77 | // 78 | // f { 79 | // a : 22 80 | // b { 81 | // d : 1 82 | // } 83 | // } 84 | // 85 | // A repeated field is not allowed except at the last position of a 86 | // paths string. 87 | // 88 | // If a FieldMask object is not present in a get operation, the 89 | // operation applies to all fields (as if a FieldMask of all fields 90 | // had been specified). 91 | // 92 | // Note that a field mask does not necessarily apply to the 93 | // top-level response message. In case of a REST get operation, the 94 | // field mask applies directly to the response, but in case of a REST 95 | // list operation, the mask instead applies to each individual message 96 | // in the returned resource list. In case of a REST custom method, 97 | // other definitions may be used. Where the mask applies will be 98 | // clearly documented together with its declaration in the API. In 99 | // any case, the effect on the returned resource/resources is required 100 | // behavior for APIs. 101 | // 102 | // # Field Masks in Update Operations 103 | // 104 | // A field mask in update operations specifies which fields of the 105 | // targeted resource are going to be updated. The API is required 106 | // to only change the values of the fields as specified in the mask 107 | // and leave the others untouched. If a resource is passed in to 108 | // describe the updated values, the API ignores the values of all 109 | // fields not covered by the mask. 110 | // 111 | // If a repeated field is specified for an update operation, new values will 112 | // be appended to the existing repeated field in the target resource. Note that 113 | // a repeated field is only allowed in the last position of a `paths` string. 114 | // 115 | // If a sub-message is specified in the last position of the field mask for an 116 | // update operation, then new value will be merged into the existing sub-message 117 | // in the target resource. 118 | // 119 | // For example, given the target message: 120 | // 121 | // f { 122 | // b { 123 | // d: 1 124 | // x: 2 125 | // } 126 | // c: [1] 127 | // } 128 | // 129 | // And an update message: 130 | // 131 | // f { 132 | // b { 133 | // d: 10 134 | // } 135 | // c: [2] 136 | // } 137 | // 138 | // then if the field mask is: 139 | // 140 | // paths: ["f.b", "f.c"] 141 | // 142 | // then the result will be: 143 | // 144 | // f { 145 | // b { 146 | // d: 10 147 | // x: 2 148 | // } 149 | // c: [1, 2] 150 | // } 151 | // 152 | // An implementation may provide options to override this default behavior for 153 | // repeated and message fields. 154 | // 155 | // In order to reset a field's value to the default, the field must 156 | // be in the mask and set to the default value in the provided resource. 157 | // Hence, in order to reset all fields of a resource, provide a default 158 | // instance of the resource and set all fields in the mask, or do 159 | // not provide a mask as described below. 160 | // 161 | // If a field mask is not present on update, the operation applies to 162 | // all fields (as if a field mask of all fields has been specified). 163 | // Note that in the presence of schema evolution, this may mean that 164 | // fields the client does not know and has therefore not filled into 165 | // the request will be reset to their default. If this is unwanted 166 | // behavior, a specific service may require a client to always specify 167 | // a field mask, producing an error if not. 168 | // 169 | // As with get operations, the location of the resource which 170 | // describes the updated values in the request message depends on the 171 | // operation kind. In any case, the effect of the field mask is 172 | // required to be honored by the API. 173 | // 174 | // ## Considerations for HTTP REST 175 | // 176 | // The HTTP kind of an update operation which uses a field mask must 177 | // be set to PATCH instead of PUT in order to satisfy HTTP semantics 178 | // (PUT must only be used for full updates). 179 | // 180 | // # JSON Encoding of Field Masks 181 | // 182 | // In JSON, a field mask is encoded as a single string where paths are 183 | // separated by a comma. Fields name in each path are converted 184 | // to/from lower-camel naming conventions. 185 | // 186 | // As an example, consider the following message declarations: 187 | // 188 | // message Profile { 189 | // User user = 1; 190 | // Photo photo = 2; 191 | // } 192 | // message User { 193 | // string display_name = 1; 194 | // string address = 2; 195 | // } 196 | // 197 | // In proto a field mask for `Profile` may look as such: 198 | // 199 | // mask { 200 | // paths: "user.display_name" 201 | // paths: "photo" 202 | // } 203 | // 204 | // In JSON, the same mask is represented as below: 205 | // 206 | // { 207 | // mask: "user.displayName,photo" 208 | // } 209 | // 210 | // # Field Masks and Oneof Fields 211 | // 212 | // Field masks treat fields in oneofs just as regular fields. Consider the 213 | // following message: 214 | // 215 | // message SampleMessage { 216 | // oneof test_oneof { 217 | // string name = 4; 218 | // SubMessage sub_message = 9; 219 | // } 220 | // } 221 | // 222 | // The field mask can be: 223 | // 224 | // mask { 225 | // paths: "name" 226 | // } 227 | // 228 | // Or: 229 | // 230 | // mask { 231 | // paths: "sub_message" 232 | // } 233 | // 234 | // Note that oneof type names ("test_oneof" in this case) cannot be used in 235 | // paths. 236 | // 237 | // ## Field Mask Verification 238 | // 239 | // The implementation of any API method which has a FieldMask type field in the 240 | // request should verify the included field paths, and return an 241 | // `INVALID_ARGUMENT` error if any path is unmappable. 242 | message FieldMask { 243 | // The set of field mask paths. 244 | repeated string paths = 1; 245 | } 246 | -------------------------------------------------------------------------------- /third_party/google/protobuf/source_context.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option java_package = "com.google.protobuf"; 37 | option java_outer_classname = "SourceContextProto"; 38 | option java_multiple_files = true; 39 | option objc_class_prefix = "GPB"; 40 | option go_package = "google.golang.org/protobuf/types/known/sourcecontextpb"; 41 | 42 | // `SourceContext` represents information about the source of a 43 | // protobuf element, like the file in which it is defined. 44 | message SourceContext { 45 | // The path-qualified name of the .proto file that contained the associated 46 | // protobuf element. For example: `"google/protobuf/source_context.proto"`. 47 | string file_name = 1; 48 | } 49 | -------------------------------------------------------------------------------- /third_party/google/protobuf/struct.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option cc_enable_arenas = true; 37 | option go_package = "google.golang.org/protobuf/types/known/structpb"; 38 | option java_package = "com.google.protobuf"; 39 | option java_outer_classname = "StructProto"; 40 | option java_multiple_files = true; 41 | option objc_class_prefix = "GPB"; 42 | 43 | // `Struct` represents a structured data value, consisting of fields 44 | // which map to dynamically typed values. In some languages, `Struct` 45 | // might be supported by a native representation. For example, in 46 | // scripting languages like JS a struct is represented as an 47 | // object. The details of that representation are described together 48 | // with the proto support for the language. 49 | // 50 | // The JSON representation for `Struct` is JSON object. 51 | message Struct { 52 | // Unordered map of dynamically typed values. 53 | map fields = 1; 54 | } 55 | 56 | // `Value` represents a dynamically typed value which can be either 57 | // null, a number, a string, a boolean, a recursive struct value, or a 58 | // list of values. A producer of value is expected to set one of these 59 | // variants. Absence of any variant indicates an error. 60 | // 61 | // The JSON representation for `Value` is JSON value. 62 | message Value { 63 | // The kind of value. 64 | oneof kind { 65 | // Represents a null value. 66 | NullValue null_value = 1; 67 | // Represents a double value. 68 | double number_value = 2; 69 | // Represents a string value. 70 | string string_value = 3; 71 | // Represents a boolean value. 72 | bool bool_value = 4; 73 | // Represents a structured value. 74 | Struct struct_value = 5; 75 | // Represents a repeated `Value`. 76 | ListValue list_value = 6; 77 | } 78 | } 79 | 80 | // `NullValue` is a singleton enumeration to represent the null value for the 81 | // `Value` type union. 82 | // 83 | // The JSON representation for `NullValue` is JSON `null`. 84 | enum NullValue { 85 | // Null value. 86 | NULL_VALUE = 0; 87 | } 88 | 89 | // `ListValue` is a wrapper around a repeated field of values. 90 | // 91 | // The JSON representation for `ListValue` is JSON array. 92 | message ListValue { 93 | // Repeated field of dynamically typed values. 94 | repeated Value values = 1; 95 | } 96 | -------------------------------------------------------------------------------- /third_party/google/protobuf/timestamp.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option cc_enable_arenas = true; 37 | option go_package = "google.golang.org/protobuf/types/known/timestamppb"; 38 | option java_package = "com.google.protobuf"; 39 | option java_outer_classname = "TimestampProto"; 40 | option java_multiple_files = true; 41 | option objc_class_prefix = "GPB"; 42 | 43 | // A Timestamp represents a point in time independent of any time zone or local 44 | // calendar, encoded as a count of seconds and fractions of seconds at 45 | // nanosecond resolution. The count is relative to an epoch at UTC midnight on 46 | // January 1, 1970, in the proleptic Gregorian calendar which extends the 47 | // Gregorian calendar backwards to year one. 48 | // 49 | // All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap 50 | // second table is needed for interpretation, using a [24-hour linear 51 | // smear](https://developers.google.com/time/smear). 52 | // 53 | // The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By 54 | // restricting to that range, we ensure that we can convert to and from [RFC 55 | // 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. 56 | // 57 | // # Examples 58 | // 59 | // Example 1: Compute Timestamp from POSIX `time()`. 60 | // 61 | // Timestamp timestamp; 62 | // timestamp.set_seconds(time(NULL)); 63 | // timestamp.set_nanos(0); 64 | // 65 | // Example 2: Compute Timestamp from POSIX `gettimeofday()`. 66 | // 67 | // struct timeval tv; 68 | // gettimeofday(&tv, NULL); 69 | // 70 | // Timestamp timestamp; 71 | // timestamp.set_seconds(tv.tv_sec); 72 | // timestamp.set_nanos(tv.tv_usec * 1000); 73 | // 74 | // Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. 75 | // 76 | // FILETIME ft; 77 | // GetSystemTimeAsFileTime(&ft); 78 | // UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; 79 | // 80 | // // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z 81 | // // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. 82 | // Timestamp timestamp; 83 | // timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); 84 | // timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); 85 | // 86 | // Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. 87 | // 88 | // long millis = System.currentTimeMillis(); 89 | // 90 | // Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) 91 | // .setNanos((int) ((millis % 1000) * 1000000)).build(); 92 | // 93 | // 94 | // Example 5: Compute Timestamp from Java `Instant.now()`. 95 | // 96 | // Instant now = Instant.now(); 97 | // 98 | // Timestamp timestamp = 99 | // Timestamp.newBuilder().setSeconds(now.getEpochSecond()) 100 | // .setNanos(now.getNano()).build(); 101 | // 102 | // 103 | // Example 6: Compute Timestamp from current time in Python. 104 | // 105 | // timestamp = Timestamp() 106 | // timestamp.GetCurrentTime() 107 | // 108 | // # JSON Mapping 109 | // 110 | // In JSON format, the Timestamp type is encoded as a string in the 111 | // [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the 112 | // format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" 113 | // where {year} is always expressed using four digits while {month}, {day}, 114 | // {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional 115 | // seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), 116 | // are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone 117 | // is required. A proto3 JSON serializer should always use UTC (as indicated by 118 | // "Z") when printing the Timestamp type and a proto3 JSON parser should be 119 | // able to accept both UTC and other timezones (as indicated by an offset). 120 | // 121 | // For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past 122 | // 01:30 UTC on January 15, 2017. 123 | // 124 | // In JavaScript, one can convert a Date object to this format using the 125 | // standard 126 | // [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) 127 | // method. In Python, a standard `datetime.datetime` object can be converted 128 | // to this format using 129 | // [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with 130 | // the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use 131 | // the Joda Time's [`ISODateTimeFormat.dateTime()`]( 132 | // http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D 133 | // ) to obtain a formatter capable of generating timestamps in this format. 134 | // 135 | // 136 | message Timestamp { 137 | // Represents seconds of UTC time since Unix epoch 138 | // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 139 | // 9999-12-31T23:59:59Z inclusive. 140 | int64 seconds = 1; 141 | 142 | // Non-negative fractions of a second at nanosecond resolution. Negative 143 | // second values with fractions must still have non-negative nanos values 144 | // that count forward in time. Must be from 0 to 999,999,999 145 | // inclusive. 146 | int32 nanos = 2; 147 | } 148 | -------------------------------------------------------------------------------- /third_party/google/protobuf/type.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | import "google/protobuf/any.proto"; 36 | import "google/protobuf/source_context.proto"; 37 | 38 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 39 | option cc_enable_arenas = true; 40 | option java_package = "com.google.protobuf"; 41 | option java_outer_classname = "TypeProto"; 42 | option java_multiple_files = true; 43 | option objc_class_prefix = "GPB"; 44 | option go_package = "google.golang.org/protobuf/types/known/typepb"; 45 | 46 | // A protocol buffer message type. 47 | message Type { 48 | // The fully qualified message name. 49 | string name = 1; 50 | // The list of fields. 51 | repeated Field fields = 2; 52 | // The list of types appearing in `oneof` definitions in this type. 53 | repeated string oneofs = 3; 54 | // The protocol buffer options. 55 | repeated Option options = 4; 56 | // The source context. 57 | SourceContext source_context = 5; 58 | // The source syntax. 59 | Syntax syntax = 6; 60 | } 61 | 62 | // A single field of a message type. 63 | message Field { 64 | // Basic field types. 65 | enum Kind { 66 | // Field type unknown. 67 | TYPE_UNKNOWN = 0; 68 | // Field type double. 69 | TYPE_DOUBLE = 1; 70 | // Field type float. 71 | TYPE_FLOAT = 2; 72 | // Field type int64. 73 | TYPE_INT64 = 3; 74 | // Field type uint64. 75 | TYPE_UINT64 = 4; 76 | // Field type int32. 77 | TYPE_INT32 = 5; 78 | // Field type fixed64. 79 | TYPE_FIXED64 = 6; 80 | // Field type fixed32. 81 | TYPE_FIXED32 = 7; 82 | // Field type bool. 83 | TYPE_BOOL = 8; 84 | // Field type string. 85 | TYPE_STRING = 9; 86 | // Field type group. Proto2 syntax only, and deprecated. 87 | TYPE_GROUP = 10; 88 | // Field type message. 89 | TYPE_MESSAGE = 11; 90 | // Field type bytes. 91 | TYPE_BYTES = 12; 92 | // Field type uint32. 93 | TYPE_UINT32 = 13; 94 | // Field type enum. 95 | TYPE_ENUM = 14; 96 | // Field type sfixed32. 97 | TYPE_SFIXED32 = 15; 98 | // Field type sfixed64. 99 | TYPE_SFIXED64 = 16; 100 | // Field type sint32. 101 | TYPE_SINT32 = 17; 102 | // Field type sint64. 103 | TYPE_SINT64 = 18; 104 | } 105 | 106 | // Whether a field is optional, required, or repeated. 107 | enum Cardinality { 108 | // For fields with unknown cardinality. 109 | CARDINALITY_UNKNOWN = 0; 110 | // For optional fields. 111 | CARDINALITY_OPTIONAL = 1; 112 | // For required fields. Proto2 syntax only. 113 | CARDINALITY_REQUIRED = 2; 114 | // For repeated fields. 115 | CARDINALITY_REPEATED = 3; 116 | } 117 | 118 | // The field type. 119 | Kind kind = 1; 120 | // The field cardinality. 121 | Cardinality cardinality = 2; 122 | // The field number. 123 | int32 number = 3; 124 | // The field name. 125 | string name = 4; 126 | // The field type URL, without the scheme, for message or enumeration 127 | // types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`. 128 | string type_url = 6; 129 | // The index of the field type in `Type.oneofs`, for message or enumeration 130 | // types. The first type has index 1; zero means the type is not in the list. 131 | int32 oneof_index = 7; 132 | // Whether to use alternative packed wire representation. 133 | bool packed = 8; 134 | // The protocol buffer options. 135 | repeated Option options = 9; 136 | // The field JSON name. 137 | string json_name = 10; 138 | // The string value of the default value of this field. Proto2 syntax only. 139 | string default_value = 11; 140 | } 141 | 142 | // Enum type definition. 143 | message Enum { 144 | // Enum type name. 145 | string name = 1; 146 | // Enum value definitions. 147 | repeated EnumValue enumvalue = 2; 148 | // Protocol buffer options. 149 | repeated Option options = 3; 150 | // The source context. 151 | SourceContext source_context = 4; 152 | // The source syntax. 153 | Syntax syntax = 5; 154 | } 155 | 156 | // Enum value definition. 157 | message EnumValue { 158 | // Enum value name. 159 | string name = 1; 160 | // Enum value number. 161 | int32 number = 2; 162 | // Protocol buffer options. 163 | repeated Option options = 3; 164 | } 165 | 166 | // A protocol buffer option, which can be attached to a message, field, 167 | // enumeration, etc. 168 | message Option { 169 | // The option's name. For protobuf built-in options (options defined in 170 | // descriptor.proto), this is the short name. For example, `"map_entry"`. 171 | // For custom options, it should be the fully-qualified name. For example, 172 | // `"google.api.http"`. 173 | string name = 1; 174 | // The option's value packed in an Any message. If the value is a primitive, 175 | // the corresponding wrapper type defined in google/protobuf/wrappers.proto 176 | // should be used. If the value is an enum, it should be stored as an int32 177 | // value using the google.protobuf.Int32Value type. 178 | Any value = 2; 179 | } 180 | 181 | // The syntax in which a protocol buffer element is defined. 182 | enum Syntax { 183 | // Syntax `proto2`. 184 | SYNTAX_PROTO2 = 0; 185 | // Syntax `proto3`. 186 | SYNTAX_PROTO3 = 1; 187 | } 188 | -------------------------------------------------------------------------------- /third_party/google/protobuf/wrappers.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Wrappers for primitive (non-message) types. These types are useful 32 | // for embedding primitives in the `google.protobuf.Any` type and for places 33 | // where we need to distinguish between the absence of a primitive 34 | // typed field and its default value. 35 | // 36 | // These wrappers have no meaningful use within repeated fields as they lack 37 | // the ability to detect presence on individual elements. 38 | // These wrappers have no meaningful use within a map or a oneof since 39 | // individual entries of a map or fields of a oneof can already detect presence. 40 | 41 | syntax = "proto3"; 42 | 43 | package google.protobuf; 44 | 45 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 46 | option cc_enable_arenas = true; 47 | option go_package = "google.golang.org/protobuf/types/known/wrapperspb"; 48 | option java_package = "com.google.protobuf"; 49 | option java_outer_classname = "WrappersProto"; 50 | option java_multiple_files = true; 51 | option objc_class_prefix = "GPB"; 52 | 53 | // Wrapper message for `double`. 54 | // 55 | // The JSON representation for `DoubleValue` is JSON number. 56 | message DoubleValue { 57 | // The double value. 58 | double value = 1; 59 | } 60 | 61 | // Wrapper message for `float`. 62 | // 63 | // The JSON representation for `FloatValue` is JSON number. 64 | message FloatValue { 65 | // The float value. 66 | float value = 1; 67 | } 68 | 69 | // Wrapper message for `int64`. 70 | // 71 | // The JSON representation for `Int64Value` is JSON string. 72 | message Int64Value { 73 | // The int64 value. 74 | int64 value = 1; 75 | } 76 | 77 | // Wrapper message for `uint64`. 78 | // 79 | // The JSON representation for `UInt64Value` is JSON string. 80 | message UInt64Value { 81 | // The uint64 value. 82 | uint64 value = 1; 83 | } 84 | 85 | // Wrapper message for `int32`. 86 | // 87 | // The JSON representation for `Int32Value` is JSON number. 88 | message Int32Value { 89 | // The int32 value. 90 | int32 value = 1; 91 | } 92 | 93 | // Wrapper message for `uint32`. 94 | // 95 | // The JSON representation for `UInt32Value` is JSON number. 96 | message UInt32Value { 97 | // The uint32 value. 98 | uint32 value = 1; 99 | } 100 | 101 | // Wrapper message for `bool`. 102 | // 103 | // The JSON representation for `BoolValue` is JSON `true` and `false`. 104 | message BoolValue { 105 | // The bool value. 106 | bool value = 1; 107 | } 108 | 109 | // Wrapper message for `string`. 110 | // 111 | // The JSON representation for `StringValue` is JSON string. 112 | message StringValue { 113 | // The string value. 114 | string value = 1; 115 | } 116 | 117 | // Wrapper message for `bytes`. 118 | // 119 | // The JSON representation for `BytesValue` is JSON string. 120 | message BytesValue { 121 | // The bytes value. 122 | bytes value = 1; 123 | } 124 | -------------------------------------------------------------------------------- /third_party/openapi/v3/annotations.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2022 Google LLC. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package openapi.v3; 18 | 19 | import "openapi/v3/openapi.proto"; 20 | import "google/protobuf/descriptor.proto"; 21 | 22 | // This option lets the proto compiler generate Java code inside the package 23 | // name (see below) instead of inside an outer class. It creates a simpler 24 | // developer experience by reducing one-level of name nesting and be 25 | // consistent with most programming languages that don't support outer classes. 26 | option java_multiple_files = true; 27 | 28 | // The Java outer classname should be the filename in UpperCamelCase. This 29 | // class is only used to hold proto descriptor, so developers don't need to 30 | // work with it directly. 31 | option java_outer_classname = "AnnotationsProto"; 32 | 33 | // The Java package name must be proto package name with proper prefix. 34 | option java_package = "org.openapi_v3"; 35 | 36 | // A reasonable prefix for the Objective-C symbols generated from the package. 37 | // It should at a minimum be 3 characters long, all uppercase, and convention 38 | // is to use an abbreviation of the package name. Something short, but 39 | // hopefully unique enough to not conflict with things that may come along in 40 | // the future. 'GPB' is reserved for the protocol buffer implementation itself. 41 | option objc_class_prefix = "OAS"; 42 | 43 | // The Go package name. 44 | option go_package = "github.com/google/gnostic/openapiv3;openapi_v3"; 45 | 46 | extend google.protobuf.FileOptions { 47 | Document document = 1143; 48 | } 49 | 50 | extend google.protobuf.MethodOptions { 51 | Operation operation = 1143; 52 | } 53 | 54 | extend google.protobuf.MessageOptions { 55 | Schema schema = 1143; 56 | } 57 | 58 | extend google.protobuf.FieldOptions { 59 | Schema property = 1143; 60 | } -------------------------------------------------------------------------------- /third_party/validate/README.md: -------------------------------------------------------------------------------- 1 | # protoc-gen-validate (PGV) 2 | 3 | * https://github.com/envoyproxy/protoc-gen-validate 4 | --------------------------------------------------------------------------------