storyicon / powerproto Goto Github PK
View Code? Open in Web Editor NEW🎉 An awesome version control tool for protoc and its related plugins.
License: Apache License 2.0
🎉 An awesome version control tool for protoc and its related plugins.
License: Apache License 2.0
protoc-gen-doc argument --doc_out must include filename, ex. --doc_out=json,"{filename}".json,source_relative:.
so, a variable representing the file name is required. ex. $SOURCE_NAME
我觉得作者应该再ReadMe中指出golang的版本依赖的问题 io/fs 是1.16提出的东西 。go install 也是1.16才给定下载的功能。
我当前版本是1.15.6 里面没有io/fs源码而报错。
搜索了网上的信息才知道。
options:
- --go_out=paths=source_relative:/home/admin/proto
options:
- --go_out=paths=source_relative:$GEN_PATH
powerproto --gen_path=/home/admin/proto
在使用插件github.com/google/gnostic/cmd/protoc-gen-openapi
或者github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2
的时候存在需要将文件全部输入插件的情况;
按照目前powerproto build -r {dir}
的逻辑,会将所有的文件分拆成多个指令一次执行;
我需要powerproto build {1.proto} {2.proto} ...
可以输入多个proto文件,执行一条指令即可;
Hello!
I have a separate config file for grpc-gw config, so a directory structure looks like this:
.
├── powerproto.yaml
├── service_1
│ ├── service_1.proto
│ └── service_1.yaml
└── service_2
├── service_2.proto
└── service_2.yaml
I need to pass --grpc-gateway_opt=grpc_api_configuration=service_1/service_1.yaml
option, but looks like an option array does not have variable parsing support.
So i can't specify options like this: --grpc-gateway_opt=grpc_api_configuration=$SOURCE_RELATIVE/grpc_api_config.yaml
It would be great if powerproto will have support of variables inside of options array. Thanks!
目前测试存在这样的问题
比如在 a目录下存在b c 两个proto文件 里面的package是a/b a/c 采用 --go_out=paths=source_relative:./apis/ 会把a/b 和a/c 生成在a的目录下,但是 a/b a/c是两个service文件就会造成 同一个包下有两个 包名称
存在bug 同一个目录下的proto必须是一个package 否则生成出来的就是不对的
failed to tidy config err=failed to download https://github.com/protocolbuffers/protobuf/releases/download/v4.23.4/protoc-4.23.4-linux-x86_64.zip, code: 404, err: unexpected code 404 for url: https://github.com/protocolbuffers/protobuf/releases/download/v4.23.4/protoc-4.23.4-linux-x86_64.zip path=/home/develop/GolandProjects/home_work/powerproto.yaml
Seems to be an issue with the URLs that are being used by this version, I can't run tidy command because of it
https://github.com/grpc/grpc-java
panic: failed to execute /.gvm/gos/go1.17.5/bin/go install github.com/grpc/[email protected] in , stderr: go install: github.com/grpc/[email protected]: module github.com/grpc/[email protected] found, but does not contain package github.com/grpc/grpc-java
, exit code 1, exit status 1
how to use protoc-gen-grpc-java , help .
protoc vertion 3.13.0
配置文件这样:
scopes:
- ./
protoc: 3.13.0
protocWorkDir: ""
plugins:
protoc-gen-go: google.golang.org/protobuf/cmd/[email protected]
protoc-gen-grpc-gateway: github.com/grpc-ecosystem/grpc-gateway/v2/[email protected]
protoc-gen-micro: github.com/asim/go-micro/cmd/protoc-gen-micro/v3@bba3107ae13f
protoc-gen-openapiv2: github.com/grpc-ecosystem/grpc-gateway/v2/[email protected]
repositories:
GOOGLE_APIS: https://github.com/googleapis/googleapis@75e9812478607db997376ccea247dd6928f70f45
options:
- --grpc-gateway_out=.
- --grpc-gateway_opt=paths=source_relative
- --openapiv2_out=.
importPaths:
- .
- $GOPATH
- $POWERPROTO_INCLUDE
- $SOURCE_RELATIVE
- $GOOGLE_APIS/github.com/googleapis/googleapis
postActions: []
postShell: ""
xxx.proto里import了google/api下的proto文件:
import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
执行powerproto build xxx.proto
报错:
google/protobuf/descriptor.proto: File not found.
google/api/annotations.proto:20:1: Import "google/protobuf/descriptor.proto" was not found or had errors.
google/api/annotations.proto:28:8: "google.protobuf.MethodOptions" is not defined.
google/api/field_behavior.proto:19:1: Import "google/protobuf/descriptor.proto" was not found or had errors.
google/api/field_behavior.proto:27:8: "google.protobuf.FieldOptions" is not defined.
建议executeTimeout可以通过传入参数控制
修改protoc-gen-go
为github.com/golang/protobuf/[email protected]
,生成的文件版本不一致。
scopes:
- ./
protoc: v3.17.3
protocWorkDir: ""
plugins:
protoc-gen-go: github.com/golang/protobuf/[email protected]
repositories:
GOGO_PROTOBUF: https://github.com/gogo/protobuf@226206f39bd7276e88ec684ea0028c18ec2c91ae
GOOGLE_APIS: https://github.com/googleapis/googleapis@75e9812478607db997376ccea247dd6928f70f45
options:
- --go_out=.
- --go_opt=paths=source_relative
- --go-grpc_out=.
- --go-grpc_opt=paths=source_relative
importPaths:
- .
- $GOPATH
- $POWERPROTO_INCLUDE
- $SOURCE_RELATIVE
- $GOOGLE_APIS/github.com/googleapis/googleapis
- $GOGO_PROTOBUF
postActions: []
postShell: ""
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.26.0
// protoc v3.17.3
// source: app/model/type.proto
package model
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
anypb "google.golang.org/protobuf/types/known/anypb"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type Type struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
Data *anypb.Any `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,omitempty"`
}
func (x *Type) Reset() {
*x = Type{}
if protoimpl.UnsafeEnabled {
mi := &file_app_model_type_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Type) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Type) ProtoMessage() {}
func (x *Type) ProtoReflect() protoreflect.Message {
mi := &file_app_model_type_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Type.ProtoReflect.Descriptor instead.
func (*Type) Descriptor() ([]byte, []int) {
return file_app_model_type_proto_rawDescGZIP(), []int{0}
}
func (x *Type) GetType() string {
if x != nil {
return x.Type
}
return ""
}
func (x *Type) GetData() *anypb.Any {
if x != nil {
return x.Data
}
return nil
}
var File_app_model_type_proto protoreflect.FileDescriptor
var file_app_model_type_proto_rawDesc = []byte{
0x0a, 0x14, 0x61, 0x70, 0x70, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x74, 0x79, 0x70, 0x65,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x1a, 0x19, 0x67,
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61,
0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x44, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65,
0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x74, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x42, 0x14,
0x5a, 0x12, 0x76, 0x6e, 0x65, 0x74, 0x2d, 0x63, 0x74, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x6d,
0x6f, 0x64, 0x65, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_app_model_type_proto_rawDescOnce sync.Once
file_app_model_type_proto_rawDescData = file_app_model_type_proto_rawDesc
)
func file_app_model_type_proto_rawDescGZIP() []byte {
file_app_model_type_proto_rawDescOnce.Do(func() {
file_app_model_type_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_model_type_proto_rawDescData)
})
return file_app_model_type_proto_rawDescData
}
var file_app_model_type_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_app_model_type_proto_goTypes = []interface{}{
(*Type)(nil), // 0: model.Type
(*anypb.Any)(nil), // 1: google.protobuf.Any
}
var file_app_model_type_proto_depIdxs = []int32{
1, // 0: model.Type.Data:type_name -> google.protobuf.Any
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_app_model_type_proto_init() }
func file_app_model_type_proto_init() {
if File_app_model_type_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_app_model_type_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Type); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_app_model_type_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_app_model_type_proto_goTypes,
DependencyIndexes: file_app_model_type_proto_depIdxs,
MessageInfos: file_app_model_type_proto_msgTypes,
}.Build()
File_app_model_type_proto = out.File
file_app_model_type_proto_rawDesc = nil
file_app_model_type_proto_goTypes = nil
file_app_model_type_proto_depIdxs = nil
}
执行的命令以及输出
ovo@LAPTOP-QCQS7H3D:/mnt/c/Users/ovo/workspace/openwrt/vnet-ctl$ powerproto.exe build -r .
search proto files...
[ ● ] tidy configs [=============] 100% (1/1) success!
[ ● ] Lookup configs of proto files [=============] 100% (2/2) success!
the following 1 configurations will be used:
C:\Users\ovo\workspace\openwrt\vnet-ctl\powerproto.yaml
[ ● ] Install protoc [=============] 100% (1/1) the v3.17.3 version of protoc is already cached
the following versions of protoc will be used: [v3.17.3]
[ ● ] Install repositories [=============] 100% (2/2) all repositories have been installed
the following versions of googleapis will be used:
https://github.com/gogo/protobuf@226206f39bd7276e88ec684ea0028c18ec2c91ae
https://github.com/googleapis/googleapis@75e9812478607db997376ccea247dd6928f70f45
[ ● ] Install plugins [=============] 100% (1/1) all plugins have been installed
the following plugins will be used:
github.com/golang/protobuf/[email protected]
[ ● ] Compile Proto Files [=============] 100% (2/2) C:\Users\ovo\workspace\openwrt\vnet-ctl\app\model\type.proto
PostAction and PostShell is skipped. If you need to allow execution, please append '-p' to command flags to enable
Good job! you are ready to go :)
succeed! you are ready to go :)
If I attempt to add github.com/grpc/grpc-web
to my plugins
directive, powerproto
attempts to go install
it, which (of course) fails.
panic: failed to execute /usr/bin/go install github.com/grpc/grpc-web@master in , stderr: go: downloading github.com/grpc/grpc-web v0.0.0-20211119232535-3fcc2a2a8a04
go install github.com/grpc/grpc-web@master: module github.com/grpc/grpc-web@master found (v0.0.0-20211119232535-3fcc2a2a8a04), but does not contain package github.com/grpc/grpc-web
, exit code 1, exit status 1
goroutine 1 [running]:
github.com/storyicon/powerproto/pkg/bootstraps.StepInstallPlugins(0xb5a5c0, 0xc00011db00, 0xb603a8, 0xc00022e300, 0xc000274020, 0x1, 0x1, 0x0, 0x0)
github.com/storyicon/[email protected]/pkg/bootstraps/build.go:215 +0xc88
When I install protoc-gen-grpc-web
, powerproto
won't detect it, because it's not passed to the plugin list (due to above.)
I also didn't see it in the output option list shown during init
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.