Skip to content

Commit

Permalink
chore: add ability to skip generating sdks
Browse files Browse the repository at this point in the history
  • Loading branch information
markphelps committed Nov 6, 2023
1 parent 7baf908 commit a2390a3
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 60 deletions.
15 changes: 15 additions & 0 deletions internal/cmd/protoc-gen-go-flipt-sdk/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ func generateGRPC(gen *protogen.Plugin) {
)

if len(file.Services) < 2 {
srv := file.Services[0]
if srv.Comments.Leading != "" {
leading := strings.TrimPrefix(string(srv.Comments.Leading), "//")
if strings.TrimSpace(leading) == ignoreDecl {
continue
}
}

returnType := file.Services[0].GoName + "Client"
g.P("func (t Transport) ", method, "() ", relativeImport(g, file, returnType), "{")
g.P("return ", relativeImport(g, file, "New"+returnType), "(t.cc)")
Expand All @@ -52,6 +60,13 @@ func generateGRPC(gen *protogen.Plugin) {
g.P("}\n")

for _, srv := range file.Services {
if srv.Comments.Leading != "" {
leading := strings.TrimPrefix(string(srv.Comments.Leading), "//")
if strings.TrimSpace(leading) == ignoreDecl {
continue
}
}

returnType := srv.GoName + "Client"
g.P("func (t ", groupType, ") ", returnType, "() ", relativeImport(g, file, returnType), " {")
g.P("return ", relativeImport(g, file, "New"+returnType), "(t.cc)")
Expand Down
14 changes: 14 additions & 0 deletions internal/cmd/protoc-gen-go-flipt-sdk/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ func generateHTTP(gen *protogen.Plugin, grpcAPIConfig string) {

if len(file.Services) < 2 {
srv := file.Services[0]
if srv.Comments.Leading != "" {
leading := strings.TrimPrefix(string(srv.Comments.Leading), "//")
if strings.TrimSpace(leading) == ignoreDecl {
continue
}
}

returnType := srv.GoName + "Client"

g.P("type ", returnType, " struct {")
Expand Down Expand Up @@ -168,6 +175,13 @@ func generateHTTP(gen *protogen.Plugin, grpcAPIConfig string) {
g.P("}\n")

for _, srv := range file.Services {
if srv.Comments.Leading != "" {
leading := strings.TrimPrefix(string(srv.Comments.Leading), "//")
if strings.TrimSpace(leading) == ignoreDecl {
continue
}
}

var (
returnType = srv.GoName + "Client"
unexportedReturnType = unexport(returnType)
Expand Down
10 changes: 10 additions & 0 deletions internal/cmd/protoc-gen-go-flipt-sdk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
const (
importPath = "go.flipt.io/flipt/sdk/go"
emptyImport = "google.golang.org/protobuf/types/known/emptypb"

ignoreDecl = "flipt:sdk:ignore"
)

func main() {
Expand All @@ -30,6 +32,7 @@ func main() {
// warning.
gen.SupportedFeatures |= uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
for _, f := range gen.Files {

if !f.Generate {
continue
}
Expand Down Expand Up @@ -129,6 +132,13 @@ func generateSubSDK(gen *protogen.Plugin, file *protogen.File) (typ, client stri
}

for _, srv := range file.Services {
if srv.Comments.Leading != "" {
leading := strings.TrimPrefix(string(srv.Comments.Leading), "//")
if strings.TrimSpace(leading) == ignoreDecl {
continue
}
}

serviceName := srv.GoName
if oneServicePackage {
serviceName = typ
Expand Down
1 change: 1 addition & 0 deletions rpc/flipt/evaluation/evaluation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ message EvaluationNamespaceSnapshotRequest {
string key = 1;
}

// flipt:sdk:ignore
service DataService {
rpc EvaluationSnapshotNamespace(EvaluationNamespaceSnapshotRequest) returns (EvaluationNamespaceSnapshot);
}
19 changes: 0 additions & 19 deletions sdk/go/evaluation.sdk.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions sdk/go/grpc/grpc.sdk.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 0 additions & 37 deletions sdk/go/http/evaluation.sdk.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a2390a3

Please sign in to comment.