Skip to content

Commit d8ee6b3

Browse files
author
gitopia1c2zfrmhra3spfrc2m5ft64hef30guf60lvtcm3
committed
Merge pull request #19 from git-remote-gitopia/cvconfigvar
2 parents 8cd134d + 04417af commit d8ee6b3

File tree

7 files changed

+80
-4
lines changed

7 files changed

+80
-4
lines changed

cmd/git-remote-gitopia/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ import (
77
"os"
88

99
sdk "github.com/cosmos/cosmos-sdk/types"
10+
"github.com/gitopia/git-remote-gitopia/config"
1011
core "github.com/gitopia/git-remote-gitopia/core"
1112
)
1213

1314
func Main(args []string, reader io.Reader, writer io.Writer, logger *log.Logger) error {
15+
config.LoadGitConfig()
16+
1417
conf := sdk.GetConfig()
1518
conf.SetBech32PrefixForAccount(AccountAddressPrefix, AccountPubKeyPrefix)
1619
// cannot seal the config

config/config.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package config
2+
3+
import (
4+
"fmt"
5+
"os/exec"
6+
"strings"
7+
)
8+
9+
const (
10+
AppName = "git-remote-gitopia"
11+
gitopiaConfigSection = "gitopia"
12+
)
13+
14+
func gitConfigGet(key string) (string, error) {
15+
cmd := exec.Command("git", "config", "--get", fmt.Sprintf("gitopia.%s", key))
16+
stdout, err := cmd.Output()
17+
18+
if err != nil {
19+
return "", err
20+
}
21+
22+
res := strings.TrimSpace(string(stdout))
23+
return res, nil
24+
}
25+
26+
func LoadGitConfig() error {
27+
if res, err := gitConfigGet("chainId"); err == nil {
28+
ChainId = res
29+
}
30+
if res, err := gitConfigGet("grpcHost"); err == nil {
31+
GRPCHost = res
32+
}
33+
if res, err := gitConfigGet("gitServerHost"); err == nil {
34+
GitServerHost = res
35+
}
36+
if res, err := gitConfigGet("tmAddr"); err == nil {
37+
TmAddr = res
38+
}
39+
if res, err := gitConfigGet("gasPrices"); err == nil {
40+
GasPrices = res
41+
}
42+
if res, err := gitConfigGet("feeGranter"); err == nil {
43+
FeeGranterAddr = res
44+
}
45+
if res, err := gitConfigGet("denom"); err == nil {
46+
Denom = res
47+
}
48+
return nil
49+
}

config/config_dev.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package config
44

5-
const (
5+
var (
66
ChainId = "gitopia"
77
GRPCHost = "grpc.devnet.gitopia.com:9090"
88
GitServerHost = "https://server.devnet.gitopia.com"

config/config_prod.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package config
44

5-
const (
5+
var (
66
ChainId = "gitopia"
77
GRPCHost = "grpc.gitopia.com:9090"
88
GitServerHost = "https://server.gitopia.com"

config/config_testing.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package config
44

5-
const (
5+
var (
66
ChainId = "gitopia"
77
GRPCHost = "localhost:9090"
88
GitServerHost = "http://localhost:5001"

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/gitopia/git-remote-gitopia
33
go 1.19
44

55
require (
6+
cosmossdk.io/errors v1.0.0-beta.7
67
github.com/cosmos/cosmos-sdk v0.46.12
78
github.com/gitopia/gitopia-go v0.5.0
89
github.com/gitopia/gitopia/v2 v2.0.1
@@ -20,7 +21,6 @@ require (
2021
cloud.google.com/go/compute/metadata v0.2.3 // indirect
2122
cloud.google.com/go/iam v0.11.0 // indirect
2223
cloud.google.com/go/storage v1.27.0 // indirect
23-
cosmossdk.io/errors v1.0.0-beta.7 // indirect
2424
cosmossdk.io/math v1.0.0-beta.3 // indirect
2525
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
2626
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect

readme.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,30 @@ For pushing git repositories to gitopia, you would require a gitopia wallet with
4949
export GITOPIA_WALLET=/path/to/wallet.json
5050
```
5151

52+
## Custom Endpoint Configuration Example
53+
54+
### Testnet
55+
```
56+
git config --global gitopia.chainId "gitopia"
57+
git config --global gitopia.grpcHost "localhost:9090"
58+
git config --global gitopia.gitServerhHst "http://localhost:5001"
59+
git config --global gitopia.tmAddr "http://localhost:26657"
60+
git config --global gitopia.gasPrices "0.001ulore"
61+
git config --global gitopia.feeGranter ""
62+
git config --global gitopia.denom "ulore"
63+
```
64+
65+
### Mainnet
66+
```
67+
git config --global gitopia.chainId "gitopia"
68+
git config --global gitopia.grpcHost "grpc.gitopia.com:9090"
69+
git config --global gitopia.gitServerHost "https://server.gitopia.com"
70+
git config --global gitopia.tmAddr "https://rpc.gitopia.com:443"
71+
git config --global gitopia.gasPrices "0.001ulore"
72+
git config --global gitopia.feeGranter "gitopia13ashgc6j5xle4m47kqyn5psavq0u3klmscfxql"
73+
git config --global gitopia.denom "ulore"
74+
```
75+
5276
## Troubleshooting
5377

5478
If you encounter the following error after installation, make sure to add `$GOBIN` to your `$PATH`

0 commit comments

Comments
 (0)