From 720accd4c22523db33f2268e0061766d26ebe2de Mon Sep 17 00:00:00 2001 From: Mark Phelps <209477+markphelps@users.noreply.github.com> Date: Fri, 3 Nov 2023 11:31:58 -0400 Subject: [PATCH] chore: dont generate interface method --- internal/cmd/protoc-gen-go-flipt-sdk/grpc.go | 14 ++++---------- internal/cmd/protoc-gen-go-flipt-sdk/http.go | 14 ++++---------- internal/cmd/protoc-gen-go-flipt-sdk/main.go | 19 ++++++++++++++----- sdk/go/evaluation.sdk.gen.go | 1 - 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/internal/cmd/protoc-gen-go-flipt-sdk/grpc.go b/internal/cmd/protoc-gen-go-flipt-sdk/grpc.go index f3fe0fb46f..f3878c2efa 100644 --- a/internal/cmd/protoc-gen-go-flipt-sdk/grpc.go +++ b/internal/cmd/protoc-gen-go-flipt-sdk/grpc.go @@ -37,11 +37,8 @@ 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 - } + if shouldIgnoreService(srv) { + continue } returnType := file.Services[0].GoName + "Client" @@ -60,11 +57,8 @@ 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 - } + if shouldIgnoreService(srv) { + continue } returnType := srv.GoName + "Client" diff --git a/internal/cmd/protoc-gen-go-flipt-sdk/http.go b/internal/cmd/protoc-gen-go-flipt-sdk/http.go index 5ee1f5d930..e2c310c8eb 100644 --- a/internal/cmd/protoc-gen-go-flipt-sdk/http.go +++ b/internal/cmd/protoc-gen-go-flipt-sdk/http.go @@ -141,11 +141,8 @@ 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 - } + if shouldIgnoreService(srv) { + continue } returnType := srv.GoName + "Client" @@ -175,11 +172,8 @@ 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 - } + if shouldIgnoreService(srv) { + continue } var ( diff --git a/internal/cmd/protoc-gen-go-flipt-sdk/main.go b/internal/cmd/protoc-gen-go-flipt-sdk/main.go index 9a78c5fcc6..8c7b9dfcd0 100644 --- a/internal/cmd/protoc-gen-go-flipt-sdk/main.go +++ b/internal/cmd/protoc-gen-go-flipt-sdk/main.go @@ -121,6 +121,10 @@ func generateSubSDK(gen *protogen.Plugin, file *protogen.File) (typ, client stri g.P("type ", typ, "Client interface {") for _, srv := range file.Services { + if shouldIgnoreService(srv) { + continue + } + g.P(srv.GoName+"Client", "()", relativeImport(g, file, srv.GoName+"Client")) } g.P("}\n") @@ -132,11 +136,8 @@ 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 - } + if shouldIgnoreService(srv) { + continue } serviceName := srv.GoName @@ -271,3 +272,11 @@ func New(t Transport, opts ...Option) SDK { return sdk }` + +func shouldIgnoreService(srv *protogen.Service) bool { + if srv.Comments.Leading != "" { + leading := strings.TrimPrefix(string(srv.Comments.Leading), "//") + return strings.TrimSpace(leading) == ignoreDecl + } + return false +} diff --git a/sdk/go/evaluation.sdk.gen.go b/sdk/go/evaluation.sdk.gen.go index 0dac688afd..208f23986c 100644 --- a/sdk/go/evaluation.sdk.gen.go +++ b/sdk/go/evaluation.sdk.gen.go @@ -9,7 +9,6 @@ import ( type EvaluationClient interface { EvaluationServiceClient() evaluation.EvaluationServiceClient - DataServiceClient() evaluation.DataServiceClient } type Evaluation struct {