From 026057fdad0ec483500a17f16ea6fe2bb61b1c44 Mon Sep 17 00:00:00 2001 From: David Kang Date: Wed, 25 Sep 2024 22:39:43 -0700 Subject: [PATCH] Migrate github.com/bufbuild/connect-go to connectrpc.com/connect --- cmd/lekko/main.go | 2 +- go.mod | 6 +++--- go.sum | 12 ++++++------ make/go/dep_protoc_gen_connect_go.mk | 11 +++++++---- pkg/apikey/apikey.go | 12 ++++++------ pkg/lekko/client.go | 18 +++++++++--------- pkg/oauth/lekko.go | 8 ++++---- pkg/oauth/oauth.go | 20 ++++++++++---------- pkg/repo/cmd.go | 12 ++++++------ pkg/team/team.go | 18 +++++++++--------- 10 files changed, 61 insertions(+), 58 deletions(-) diff --git a/cmd/lekko/main.go b/cmd/lekko/main.go index 6bb8467e..574cf1bb 100644 --- a/cmd/lekko/main.go +++ b/cmd/lekko/main.go @@ -21,8 +21,8 @@ import ( "os" "strconv" + "connectrpc.com/connect" "github.com/AlecAivazis/survey/v2" - "github.com/bufbuild/connect-go" "github.com/lainio/err2" "github.com/pkg/errors" "github.com/spf13/cobra" diff --git a/go.mod b/go.mod index ee0be1ba..6b2fc985 100644 --- a/go.mod +++ b/go.mod @@ -5,13 +5,13 @@ go 1.22 replace github.com/bazelbuild/buildtools => github.com/lekkodev/buildtools v0.0.0-20240325231538-96eefd799042 require ( - buf.build/gen/go/lekkodev/cli/bufbuild/connect-go v1.10.0-20240528213244-5fdc18b47eea.1 - buf.build/gen/go/lekkodev/cli/protocolbuffers/go v1.34.2-20240923164736-6b09ba83efbf.2 + buf.build/gen/go/lekkodev/cli/connectrpc/go v1.17.0-20240926040046-3e1042256cdf.1 + buf.build/gen/go/lekkodev/cli/protocolbuffers/go v1.34.2-20240926040046-3e1042256cdf.2 + connectrpc.com/connect v1.17.0 github.com/AlecAivazis/survey/v2 v2.3.6 github.com/atotto/clipboard v0.1.4 github.com/bazelbuild/buildtools v0.0.0-20220907133145-b9bfff5d7f91 github.com/briandowns/spinner v1.23.0 - github.com/bufbuild/connect-go v1.10.0 github.com/cli/browser v1.0.0 github.com/go-git/go-billy/v5 v5.5.0 github.com/go-git/go-git/v5 v5.12.0 diff --git a/go.sum b/go.sum index 62275806..a03fdbc1 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,12 @@ -buf.build/gen/go/lekkodev/cli/bufbuild/connect-go v1.10.0-20240528213244-5fdc18b47eea.1 h1:JqArhl+OClAdLQis1N2N6WmLv96CbOaNrQEYWL2ntlI= -buf.build/gen/go/lekkodev/cli/bufbuild/connect-go v1.10.0-20240528213244-5fdc18b47eea.1/go.mod h1:gkMKhhTCMDLJVmimyqao6P3g7jB7wDe3r7u8hV2iShE= -buf.build/gen/go/lekkodev/cli/protocolbuffers/go v1.34.2-20240923164736-6b09ba83efbf.2 h1:JEiSyCH0wTycYIeIpm8xs/HcyPgHtJpdKBrUer8Jq6E= -buf.build/gen/go/lekkodev/cli/protocolbuffers/go v1.34.2-20240923164736-6b09ba83efbf.2/go.mod h1:j/ek65dWz+D5GM7p9QUiHQj5X5gtRUMfGl1+GpSfm6g= +buf.build/gen/go/lekkodev/cli/connectrpc/go v1.17.0-20240926040046-3e1042256cdf.1 h1:agiFYCNijwOenKQtub2FQ3lUdZvXQTii7eVV7ByY6h4= +buf.build/gen/go/lekkodev/cli/connectrpc/go v1.17.0-20240926040046-3e1042256cdf.1/go.mod h1:1ia6DcIYiqkQNmSTA00+Kys2yObN8ByxgcLbaTY1hNo= +buf.build/gen/go/lekkodev/cli/protocolbuffers/go v1.34.2-20240926040046-3e1042256cdf.2 h1:sS7KHlg3fCpYqz52WrRAOEr7uxezWXoGM7gopqB2gYQ= +buf.build/gen/go/lekkodev/cli/protocolbuffers/go v1.34.2-20240926040046-3e1042256cdf.2/go.mod h1:j/ek65dWz+D5GM7p9QUiHQj5X5gtRUMfGl1+GpSfm6g= buf.build/gen/go/lekkodev/sdk/protocolbuffers/go v1.34.2-20230810202034-1c821065b9a0.2 h1:ZEir2Lbw+XH5Dlnqiv0FUc8hC7QdUMpGSCIiREMriJ0= buf.build/gen/go/lekkodev/sdk/protocolbuffers/go v1.34.2-20230810202034-1c821065b9a0.2/go.mod h1:YAvVDcY/tXuUXkpfm3LHCD6vz9SPv73CktuPGgqzJkI= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +connectrpc.com/connect v1.17.0 h1:W0ZqMhtVzn9Zhn2yATuUokDLO5N+gIuBWMOnsQrfmZk= +connectrpc.com/connect v1.17.0/go.mod h1:0292hj1rnx8oFrStN7cB4jjVBeqs+Yx5yDIC2prWDO8= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/AlecAivazis/survey/v2 v2.3.6 h1:NvTuVHISgTHEHeBFqt6BHOe4Ny/NwGZr7w+F8S9ziyw= @@ -31,8 +33,6 @@ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/briandowns/spinner v1.23.0 h1:alDF2guRWqa/FOZZYWjlMIx2L6H0wyewPxo/CH4Pt2A= github.com/briandowns/spinner v1.23.0/go.mod h1:rPG4gmXeN3wQV/TsAY4w8lPdIM6RX3yqeBQJSrbXjuE= -github.com/bufbuild/connect-go v1.10.0 h1:QAJ3G9A1OYQW2Jbk3DeoJbkCxuKArrvZgDt47mjdTbg= -github.com/bufbuild/connect-go v1.10.0/go.mod h1:CAIePUgkDR5pAFaylSMtNK45ANQjp9JvpluG20rhpV8= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= diff --git a/make/go/dep_protoc_gen_connect_go.mk b/make/go/dep_protoc_gen_connect_go.mk index 233ca5c3..ef32e3bc 100644 --- a/make/go/dep_protoc_gen_connect_go.mk +++ b/make/go/dep_protoc_gen_connect_go.mk @@ -7,13 +7,16 @@ $(call _assert_var,CACHE_VERSIONS) $(call _assert_var,CACHE_BIN) # Settable -# https://github.com/bufbuild/connect-go 20220531 checked 20220601 -CONNECT_VERSION ?= v0.1.0 +# https://github.com/connectrpc/connect-go 20240920 checked 20240920 +CONNECT_VERSION ?= v1.17.0 + +GO_GET_PKGS := $(GO_GET_PKGS) \ + connectrpc.com/connect@$(CONNECT_VERSION) PROTOC_GEN_CONNECT_GO := $(CACHE_VERSIONS)/connect-go/$(CONNECT_VERSION) $(PROTOC_GEN_CONNECT_GO): - @rm -f $(CACHE_BIN)/connect-go - GOBIN=$(CACHE_BIN) go install github.com/bufbuild/connect-go/cmd/protoc-gen-connect-go@$(CONNECT_VERSION) + @rm -f $(CACHE_BIN)/protoc-gen-connect-go + GOBIN=$(CACHE_BIN) go install connectrpc.com/connect/cmd/protoc-gen-connect-go@$(CONNECT_VERSION) @rm -rf $(dir $(PROTOC_GEN_CONNECT_GO)) @mkdir -p $(dir $(PROTOC_GEN_CONNECT_GO)) @touch $(PROTOC_GEN_CONNECT_GO) diff --git a/pkg/apikey/apikey.go b/pkg/apikey/apikey.go index 403746d3..c080fc52 100644 --- a/pkg/apikey/apikey.go +++ b/pkg/apikey/apikey.go @@ -17,10 +17,10 @@ package apikey import ( "context" - bffv1beta1connect "buf.build/gen/go/lekkodev/cli/bufbuild/connect-go/lekko/bff/v1beta1/bffv1beta1connect" + bffv1beta1connect "buf.build/gen/go/lekkodev/cli/connectrpc/go/lekko/bff/v1beta1/bffv1beta1connect" bffv1beta1 "buf.build/gen/go/lekkodev/cli/protocolbuffers/go/lekko/bff/v1beta1" + "connectrpc.com/connect" - connect_go "github.com/bufbuild/connect-go" "github.com/pkg/errors" ) @@ -34,7 +34,7 @@ func NewAPIKey(bff bffv1beta1connect.BFFServiceClient) *APIKeyManager { } func (a *APIKeyManager) Create(ctx context.Context, teamname, nickname string) (*bffv1beta1.GenerateAPIKeyResponse, error) { - resp, err := a.bff.GenerateAPIKey(ctx, connect_go.NewRequest(&bffv1beta1.GenerateAPIKeyRequest{ + resp, err := a.bff.GenerateAPIKey(ctx, connect.NewRequest(&bffv1beta1.GenerateAPIKeyRequest{ Nickname: nickname, TeamName: teamname, })) @@ -45,7 +45,7 @@ func (a *APIKeyManager) Create(ctx context.Context, teamname, nickname string) ( } func (a *APIKeyManager) List(ctx context.Context, teamname string) ([]*bffv1beta1.APIKey, error) { - resp, err := a.bff.ListAPIKeys(ctx, connect_go.NewRequest(&bffv1beta1.ListAPIKeysRequest{TeamName: teamname})) + resp, err := a.bff.ListAPIKeys(ctx, connect.NewRequest(&bffv1beta1.ListAPIKeysRequest{TeamName: teamname})) if err != nil { return nil, errors.Wrap(err, "list api keys") } @@ -53,7 +53,7 @@ func (a *APIKeyManager) List(ctx context.Context, teamname string) ([]*bffv1beta } func (a *APIKeyManager) Check(ctx context.Context, apikey string) (*bffv1beta1.APIKey, error) { - resp, err := a.bff.CheckAPIKey(ctx, connect_go.NewRequest(&bffv1beta1.CheckAPIKeyRequest{ + resp, err := a.bff.CheckAPIKey(ctx, connect.NewRequest(&bffv1beta1.CheckAPIKeyRequest{ ApiKey: apikey, })) if err != nil { @@ -63,7 +63,7 @@ func (a *APIKeyManager) Check(ctx context.Context, apikey string) (*bffv1beta1.A } func (a *APIKeyManager) Delete(ctx context.Context, nickname string) error { - _, err := a.bff.DeleteAPIKey(ctx, connect_go.NewRequest(&bffv1beta1.DeleteAPIKeyRequest{ + _, err := a.bff.DeleteAPIKey(ctx, connect.NewRequest(&bffv1beta1.DeleteAPIKeyRequest{ Nickname: nickname, })) return err diff --git a/pkg/lekko/client.go b/pkg/lekko/client.go index 840cca1f..e873d77a 100644 --- a/pkg/lekko/client.go +++ b/pkg/lekko/client.go @@ -19,8 +19,8 @@ import ( "fmt" "net/http" - bffv1beta1connect "buf.build/gen/go/lekkodev/cli/bufbuild/connect-go/lekko/bff/v1beta1/bffv1beta1connect" - connect_go "github.com/bufbuild/connect-go" + bffv1beta1connect "buf.build/gen/go/lekkodev/cli/connectrpc/go/lekko/bff/v1beta1/bffv1beta1connect" + "connectrpc.com/connect" ) const ( @@ -45,15 +45,15 @@ type AuthCredentials interface { func NewBFFClient(creds AuthCredentials) bffv1beta1connect.BFFServiceClient { interceptor := NewUserAuthInterceptor(creds) - return bffv1beta1connect.NewBFFServiceClient(http.DefaultClient, URL, connect_go.WithInterceptors(interceptor)) + return bffv1beta1connect.NewBFFServiceClient(http.DefaultClient, URL, connect.WithInterceptors(interceptor)) } -func NewUserAuthInterceptor(a AuthCredentials) connect_go.UnaryInterceptorFunc { - interceptor := func(next connect_go.UnaryFunc) connect_go.UnaryFunc { - return connect_go.UnaryFunc(func( +func NewUserAuthInterceptor(a AuthCredentials) connect.UnaryInterceptorFunc { + interceptor := func(next connect.UnaryFunc) connect.UnaryFunc { + return connect.UnaryFunc(func( ctx context.Context, - req connect_go.AnyRequest, - ) (connect_go.AnyResponse, error) { + req connect.AnyRequest, + ) (connect.AnyResponse, error) { if a.HasLekkoToken() { req.Header().Set(AuthorizationHeaderKey, fmt.Sprintf("Bearer %s", a.GetLekkoToken())) if lekkoTeam := a.GetLekkoTeam(); len(lekkoTeam) > 0 { @@ -69,5 +69,5 @@ func NewUserAuthInterceptor(a AuthCredentials) connect_go.UnaryInterceptorFunc { return next(ctx, req) }) } - return connect_go.UnaryInterceptorFunc(interceptor) + return connect.UnaryInterceptorFunc(interceptor) } diff --git a/pkg/oauth/lekko.go b/pkg/oauth/lekko.go index 47d1a882..6e9f21bb 100644 --- a/pkg/oauth/lekko.go +++ b/pkg/oauth/lekko.go @@ -23,9 +23,9 @@ import ( "os" "time" - bffv1beta1connect "buf.build/gen/go/lekkodev/cli/bufbuild/connect-go/lekko/bff/v1beta1/bffv1beta1connect" + bffv1beta1connect "buf.build/gen/go/lekkodev/cli/connectrpc/go/lekko/bff/v1beta1/bffv1beta1connect" bffv1beta1 "buf.build/gen/go/lekkodev/cli/protocolbuffers/go/lekko/bff/v1beta1" - connect_go "github.com/bufbuild/connect-go" + "connectrpc.com/connect" "github.com/cenkalti/backoff/v4" "github.com/cli/browser" "github.com/pkg/errors" @@ -56,7 +56,7 @@ type AuthCredentials struct { } func (f *DeviceFlow) Authorize(ctx context.Context) (*AuthCredentials, error) { - resp, err := f.lekkoAuthClient.GetDeviceCode(ctx, connect_go.NewRequest(&bffv1beta1.GetDeviceCodeRequest{ + resp, err := f.lekkoAuthClient.GetDeviceCode(ctx, connect.NewRequest(&bffv1beta1.GetDeviceCodeRequest{ ClientId: LekkoClientID, })) if err != nil { @@ -76,7 +76,7 @@ func (f *DeviceFlow) pollToken(ctx context.Context, deviceCode string, interval var ret *AuthCredentials operation := func() error { - resp, err := f.lekkoAuthClient.GetAccessToken(ctx, connect_go.NewRequest(&bffv1beta1.GetAccessTokenRequest{ + resp, err := f.lekkoAuthClient.GetAccessToken(ctx, connect.NewRequest(&bffv1beta1.GetAccessTokenRequest{ DeviceCode: deviceCode, ClientId: LekkoClientID, })) diff --git a/pkg/oauth/oauth.go b/pkg/oauth/oauth.go index b2e3d746..6cf928cd 100644 --- a/pkg/oauth/oauth.go +++ b/pkg/oauth/oauth.go @@ -23,10 +23,10 @@ import ( "sync" "time" - bffv1beta1connect "buf.build/gen/go/lekkodev/cli/bufbuild/connect-go/lekko/bff/v1beta1/bffv1beta1connect" + bffv1beta1connect "buf.build/gen/go/lekkodev/cli/connectrpc/go/lekko/bff/v1beta1/bffv1beta1connect" bffv1beta1 "buf.build/gen/go/lekkodev/cli/protocolbuffers/go/lekko/bff/v1beta1" + "connectrpc.com/connect" "github.com/briandowns/spinner" - connect_go "github.com/bufbuild/connect-go" ghauth "github.com/cli/oauth" "github.com/lekkodev/cli/pkg/gh" "github.com/lekkodev/cli/pkg/lekko" @@ -115,7 +115,7 @@ func (a *OAuth) PreRegister(ctx context.Context, username string, ws secrets.Wri s := spinner.New(spinner.CharSets[14], 100*time.Millisecond) s.Suffix = " Generating OAuth code..." s.Start() - dcResp, err := a.lekkoAuthClient.GetDeviceCode(ctx, connect_go.NewRequest(&bffv1beta1.GetDeviceCodeRequest{ + dcResp, err := a.lekkoAuthClient.GetDeviceCode(ctx, connect.NewRequest(&bffv1beta1.GetDeviceCodeRequest{ ClientId: LekkoClientID, })) s.Stop() @@ -124,7 +124,7 @@ func (a *OAuth) PreRegister(ctx context.Context, username string, ws secrets.Wri } s.Suffix = " Connecting to Lekko..." s.Start() - _, err = a.lekkoAuthClient.PreRegisterUser(ctx, connect_go.NewRequest(&bffv1beta1.PreRegisterUserRequest{ + _, err = a.lekkoAuthClient.PreRegisterUser(ctx, connect.NewRequest(&bffv1beta1.PreRegisterUserRequest{ Username: username, // We're passing in user code just because that's what backend handles better at the moment DeviceCode: dcResp.Msg.UserCode, @@ -155,7 +155,7 @@ func (a *OAuth) PreRegister(ctx context.Context, username string, ws secrets.Wri } func (a *OAuth) Register(ctx context.Context, username, password, confirmPassword string) error { - registerResp, err := a.lekkoAuthClient.RegisterUser(ctx, connect_go.NewRequest(&bffv1beta1.RegisterUserRequest{ + registerResp, err := a.lekkoAuthClient.RegisterUser(ctx, connect.NewRequest(&bffv1beta1.RegisterUserRequest{ Username: username, Password: password, ConfirmPassword: confirmPassword, @@ -170,7 +170,7 @@ func (a *OAuth) Register(ctx context.Context, username, password, confirmPasswor } func (a *OAuth) ConfirmUser(ctx context.Context, username, code string) error { - _, err := a.lekkoAuthClient.ConfirmUser(ctx, connect_go.NewRequest(&bffv1beta1.ConfirmUserRequest{ + _, err := a.lekkoAuthClient.ConfirmUser(ctx, connect.NewRequest(&bffv1beta1.ConfirmUserRequest{ Username: username, Code: code, })) @@ -188,7 +188,7 @@ func (a *OAuth) Tokens(ctx context.Context, rs secrets.ReadSecrets) []string { } func (a *OAuth) ForgotPassword(ctx context.Context, email string) error { - _, err := a.lekkoAuthClient.ForgotPassword(ctx, connect_go.NewRequest( + _, err := a.lekkoAuthClient.ForgotPassword(ctx, connect.NewRequest( &bffv1beta1.ForgotPasswordRequest{Username: email}), ) return err @@ -197,7 +197,7 @@ func (a *OAuth) ForgotPassword(ctx context.Context, email string) error { func (a *OAuth) ConfirmForgotPassword( ctx context.Context, email string, newPassword string, confirmNewPassword string, verificationCode string, ) error { - _, err := a.lekkoAuthClient.ConfirmForgotPassword(ctx, connect_go.NewRequest( + _, err := a.lekkoAuthClient.ConfirmForgotPassword(ctx, connect.NewRequest( &bffv1beta1.ConfirmForgotPasswordRequest{ Username: email, NewPassword: newPassword, @@ -209,7 +209,7 @@ func (a *OAuth) ConfirmForgotPassword( } func (a *OAuth) ResendVerification(ctx context.Context, email string) error { - _, err := a.lekkoAuthClient.ResendVerificationCode(ctx, connect_go.NewRequest( + _, err := a.lekkoAuthClient.ResendVerificationCode(ctx, connect.NewRequest( &bffv1beta1.ResendVerificationCodeRequest{Username: email}), ) return err @@ -338,7 +338,7 @@ func (a *OAuth) loginGithub(ctx context.Context, ws secrets.WriteSecrets) error } func (a *OAuth) checkLekkoAuth(ctx context.Context) (username string, err error) { - req := connect_go.NewRequest(&bffv1beta1.GetUserLoggedInInfoRequest{}) + req := connect.NewRequest(&bffv1beta1.GetUserLoggedInInfoRequest{}) resp, err := a.lekkoBFFClient.GetUserLoggedInInfo(ctx, req) if err != nil { return "", errors.Wrap(err, "check lekko auth") diff --git a/pkg/repo/cmd.go b/pkg/repo/cmd.go index e8f7f24f..7962bca0 100644 --- a/pkg/repo/cmd.go +++ b/pkg/repo/cmd.go @@ -21,10 +21,10 @@ import ( "os" "path/filepath" - bffv1beta1connect "buf.build/gen/go/lekkodev/cli/bufbuild/connect-go/lekko/bff/v1beta1/bffv1beta1connect" + bffv1beta1connect "buf.build/gen/go/lekkodev/cli/connectrpc/go/lekko/bff/v1beta1/bffv1beta1connect" bffv1beta1 "buf.build/gen/go/lekkodev/cli/protocolbuffers/go/lekko/bff/v1beta1" + "connectrpc.com/connect" "github.com/AlecAivazis/survey/v2" - connect_go "github.com/bufbuild/connect-go" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/config" "github.com/go-git/go-git/v5/plumbing" @@ -61,7 +61,7 @@ var ErrRemoteHasChanges = errors.New("Remote repository has new changes, " + fmt.Sprintf("please run %s to merge them locally and try again.", logging.Bold("lekko pull"))) func (r *RepoCmd) List(ctx context.Context) ([]*Repository, error) { - resp, err := r.lekkoBFFClient.ListRepositories(ctx, connect_go.NewRequest(&bffv1beta1.ListRepositoriesRequest{})) + resp, err := r.lekkoBFFClient.ListRepositories(ctx, connect.NewRequest(&bffv1beta1.ListRepositoriesRequest{})) if err != nil { return nil, errors.Wrap(err, "list repos") } @@ -85,7 +85,7 @@ func repoFromProto(repo *bffv1beta1.Repository) *Repository { } func (r *RepoCmd) Create(ctx context.Context, owner, repo, description string) (string, error) { - resp, err := r.lekkoBFFClient.CreateRepository(ctx, connect_go.NewRequest(&bffv1beta1.CreateRepositoryRequest{ + resp, err := r.lekkoBFFClient.CreateRepository(ctx, connect.NewRequest(&bffv1beta1.CreateRepositoryRequest{ RepoKey: &bffv1beta1.RepositoryKey{ OwnerName: owner, RepoName: repo, @@ -99,7 +99,7 @@ func (r *RepoCmd) Create(ctx context.Context, owner, repo, description string) ( } func (r *RepoCmd) Delete(ctx context.Context, owner, repo string, deleteOnRemote bool) error { - _, err := r.lekkoBFFClient.DeleteRepository(ctx, connect_go.NewRequest(&bffv1beta1.DeleteRepositoryRequest{ + _, err := r.lekkoBFFClient.DeleteRepository(ctx, connect.NewRequest(&bffv1beta1.DeleteRepositoryRequest{ RepoKey: &bffv1beta1.RepositoryKey{ OwnerName: owner, RepoName: repo, @@ -342,7 +342,7 @@ func (r *RepoCmd) Import(ctx context.Context, repoPath, owner, repoName, descrip } // Import new repo into Lekko - _, err = r.lekkoBFFClient.ImportRepository(ctx, connect_go.NewRequest(&bffv1beta1.ImportRepositoryRequest{ + _, err = r.lekkoBFFClient.ImportRepository(ctx, connect.NewRequest(&bffv1beta1.ImportRepositoryRequest{ RepoKey: &bffv1beta1.RepositoryKey{ OwnerName: owner, RepoName: repoName, diff --git a/pkg/team/team.go b/pkg/team/team.go index 7937d37b..7b0b00c4 100644 --- a/pkg/team/team.go +++ b/pkg/team/team.go @@ -18,9 +18,9 @@ import ( "context" "strings" - bffv1beta1connect "buf.build/gen/go/lekkodev/cli/bufbuild/connect-go/lekko/bff/v1beta1/bffv1beta1connect" + bffv1beta1connect "buf.build/gen/go/lekkodev/cli/connectrpc/go/lekko/bff/v1beta1/bffv1beta1connect" bffv1beta1 "buf.build/gen/go/lekkodev/cli/protocolbuffers/go/lekko/bff/v1beta1" - connect_go "github.com/bufbuild/connect-go" + "connectrpc.com/connect" "github.com/pkg/errors" ) @@ -49,7 +49,7 @@ func (t *Team) Show(ts TeamStore) string { } func (t *Team) Use(ctx context.Context, team string, wts WriteTeamStore) error { - if _, err := t.lekkoBFFClient.UseTeam(ctx, connect_go.NewRequest(&bffv1beta1.UseTeamRequest{ + if _, err := t.lekkoBFFClient.UseTeam(ctx, connect.NewRequest(&bffv1beta1.UseTeamRequest{ Name: team, })); err != nil { return errors.Wrap(err, "use team") @@ -91,7 +91,7 @@ type TeamMembership struct { } func (t *Team) List(ctx context.Context) ([]*TeamMembership, error) { - resp, err := t.lekkoBFFClient.ListUserMemberships(ctx, connect_go.NewRequest(&bffv1beta1.ListUserMembershipsRequest{})) + resp, err := t.lekkoBFFClient.ListUserMemberships(ctx, connect.NewRequest(&bffv1beta1.ListUserMembershipsRequest{})) if err != nil { return nil, errors.Wrap(err, "list team memberships") } @@ -131,7 +131,7 @@ func roleToProto(role MemberRole) bffv1beta1.MembershipRole { } func (t *Team) Create(ctx context.Context, name, domainName string, wts WriteTeamStore) error { - if _, err := t.lekkoBFFClient.CreateTeam(ctx, connect_go.NewRequest(&bffv1beta1.CreateTeamRequest{ + if _, err := t.lekkoBFFClient.CreateTeam(ctx, connect.NewRequest(&bffv1beta1.CreateTeamRequest{ Name: name, DomainName: domainName, })); err != nil { @@ -142,7 +142,7 @@ func (t *Team) Create(ctx context.Context, name, domainName string, wts WriteTea } func (t *Team) AddMember(ctx context.Context, email string, role MemberRole) error { - if _, err := t.lekkoBFFClient.UpsertMembership(ctx, connect_go.NewRequest(&bffv1beta1.UpsertMembershipRequest{ + if _, err := t.lekkoBFFClient.UpsertMembership(ctx, connect.NewRequest(&bffv1beta1.UpsertMembershipRequest{ Username: email, Role: roleToProto(role), })); err != nil { @@ -152,7 +152,7 @@ func (t *Team) AddMember(ctx context.Context, email string, role MemberRole) err } func (t *Team) ListMemberships(ctx context.Context) ([]*TeamMembership, error) { - resp, err := t.lekkoBFFClient.ListTeamMemberships(ctx, connect_go.NewRequest(&bffv1beta1.ListTeamMembershipsRequest{})) + resp, err := t.lekkoBFFClient.ListTeamMemberships(ctx, connect.NewRequest(&bffv1beta1.ListTeamMembershipsRequest{})) if err != nil { return nil, errors.Wrap(err, "list team memberships") } @@ -164,7 +164,7 @@ func (t *Team) ListMemberships(ctx context.Context) ([]*TeamMembership, error) { } func (t *Team) RemoveMember(ctx context.Context, email string) error { - if _, err := t.lekkoBFFClient.RemoveMembership(ctx, connect_go.NewRequest(&bffv1beta1.RemoveMembershipRequest{ + if _, err := t.lekkoBFFClient.RemoveMembership(ctx, connect.NewRequest(&bffv1beta1.RemoveMembershipRequest{ Username: email, })); err != nil { return errors.Wrap(err, "remove membership") @@ -173,7 +173,7 @@ func (t *Team) RemoveMember(ctx context.Context, email string) error { } func (t *Team) Delete(ctx context.Context, name string) error { - if _, err := t.lekkoBFFClient.DeleteTeam(ctx, connect_go.NewRequest(&bffv1beta1.DeleteTeamRequest{ + if _, err := t.lekkoBFFClient.DeleteTeam(ctx, connect.NewRequest(&bffv1beta1.DeleteTeamRequest{ TeamName: name, })); err != nil { return errors.Wrap(err, "delete team")