Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/lekko/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand All @@ -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=
Expand Down
11 changes: 7 additions & 4 deletions make/go/dep_protoc_gen_connect_go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions pkg/apikey/apikey.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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,
}))
Expand All @@ -45,15 +45,15 @@ 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")
}
return resp.Msg.GetApiKeys(), nil
}

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 {
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions pkg/lekko/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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 {
Expand All @@ -69,5 +69,5 @@ func NewUserAuthInterceptor(a AuthCredentials) connect_go.UnaryInterceptorFunc {
return next(ctx, req)
})
}
return connect_go.UnaryInterceptorFunc(interceptor)
return connect.UnaryInterceptorFunc(interceptor)
}
8 changes: 4 additions & 4 deletions pkg/oauth/lekko.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
}))
Expand Down
20 changes: 10 additions & 10 deletions pkg/oauth/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
}))
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand Down
12 changes: 6 additions & 6 deletions pkg/repo/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
}
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading