Skip to content
Closed
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
14 changes: 13 additions & 1 deletion app/gitopia.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package app
import (
"context"

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/authz"
"github.com/gitopia/git-server/logger"
Expand All @@ -11,6 +12,8 @@ import (
"github.com/ignite/cli/ignite/pkg/cosmosclient"
"github.com/pkg/errors"
"github.com/spf13/viper"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

const (
Expand Down Expand Up @@ -38,12 +41,21 @@ func NewGitopiaClient(ctx context.Context, account string) (GitopiaClient, error
cosmosclient.WithKeyringBackend(cosmosaccount.KeyringTest),
cosmosclient.WithHome(viper.GetString("keyring_dir")),
cosmosclient.WithAddressPrefix(GITOPIA_ACC_ADDRESS_PREFIX),
cosmosclient.WithGasPrices(viper.GetString("gas_prices")),
)
if err != nil {
return GitopiaClient{}, errors.Wrap(err, "error creating cosmos client")
}

queryClient := types.NewQueryClient(client.Context().GRPCClient)
grpcConn, err := grpc.Dial(viper.GetString("gitopia_grpc_url"),
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(nil).GRPCCodec())),
)
if err != nil {
return GitopiaClient{}, errors.Wrap(err, "error creating grpc client")
}

queryClient := types.NewQueryClient(grpcConn)

return GitopiaClient{
accountName: account,
Expand Down
3 changes: 2 additions & 1 deletion config_dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ git_dir = "/var/repos"
attachment_dir = "/var/attachments"
tm_addr = "http://grpc.gitopia.dev:26657"
key_name = "git-server"
keyring_dir = "/home/ubuntu/git-server"
keyring_dir = "/home/ubuntu/git-server"
gas_prices = "0.001utlore"
3 changes: 2 additions & 1 deletion config_local.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ git_dir = "/var/repos"
attachment_dir = "/var/attachments"
tm_addr = "http://localhost:26657"
key_name = "git-server"
keyring_dir = ""
keyring_dir = ""
gas_prices = ""
3 changes: 2 additions & 1 deletion config_prod.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ git_dir = "/var/repos"
attachment_dir = "/var/attachments"
tm_addr = "http://grpc.gitopia.com:26657"
key_name = "git-server"
keyring_dir = "/home/ubuntu/git-server"
keyring_dir = "/home/ubuntu/git-server"
gas_prices = "0.001ulore"
2 changes: 2 additions & 0 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"strings"
"time"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/gitopia/git-server/utils"
"github.com/gitopia/gitopia/x/gitopia/types"
"github.com/spf13/viper"
Expand Down Expand Up @@ -119,6 +120,7 @@ func getAttachmentHandler(w http.ResponseWriter, r *http.Request) {
grpcUrl := viper.GetString("gitopia_grpc_url")
grpcConn, err := grpc.Dial(grpcUrl,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(nil).GRPCCodec())),
)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand Down
2 changes: 2 additions & 0 deletions handler/forkRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"sync"

"github.com/buger/jsonparser"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types/query"
"github.com/cosmos/cosmos-sdk/types/tx"
"github.com/gitopia/git-server/app"
Expand Down Expand Up @@ -286,6 +287,7 @@ func (h *InvokeForkRepositoryEventHandler) BackfillMissedEvents(ctx context.Cont

grpcConn, err := grpc.Dial(viper.GetString("gitopia_grpc_url"),
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(nil).GRPCCodec())),
)
if err != nil {
errChan <- errors.Wrap(err, "dial err")
Expand Down
2 changes: 2 additions & 0 deletions handler/mergePullRequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"time"

"github.com/buger/jsonparser"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types/query"
"github.com/cosmos/cosmos-sdk/types/tx"
"github.com/gitopia/git-server/app"
Expand Down Expand Up @@ -490,6 +491,7 @@ func (h *InvokeMergePullRequestEventHandler) BackfillMissedEvents(ctx context.Co

grpcConn, err := grpc.Dial(viper.GetString("gitopia_grpc_url"),
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(nil).GRPCCodec())),
)
if err != nil {
errChan <- errors.Wrap(err, "dial err")
Expand Down
2 changes: 2 additions & 0 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strconv"
"strings"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/gitopia/gitopia/x/gitopia/types"
"github.com/gitopia/gitopia/x/gitopia/utils"
"github.com/spf13/viper"
Expand Down Expand Up @@ -46,6 +47,7 @@ func HavePushPermission(repoId uint64, address string) (havePermission bool, err
grpcUrl := viper.GetString("gitopia_grpc_url")
grpcConn, err := grpc.Dial(grpcUrl,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(nil).GRPCCodec())),
)
if err != nil {
return false, err
Expand Down