forked from TrueCloudLab/frostfs-s3-gw
[#607] Improve wallet path param
Made it configurable in yaml Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
parent
57ce0f25bf
commit
7bd824f3fa
6 changed files with 28 additions and 19 deletions
|
@ -34,7 +34,7 @@ Minimalistic S3 gateway setup needs:
|
||||||
`S3_GW_PEERS_<N>_WEIGHT` environment variables (gateway supports multiple
|
`S3_GW_PEERS_<N>_WEIGHT` environment variables (gateway supports multiple
|
||||||
NeoFS nodes with weighted load balancing).
|
NeoFS nodes with weighted load balancing).
|
||||||
* a wallet used to fetch key and communicate with NeoFS nodes
|
* a wallet used to fetch key and communicate with NeoFS nodes
|
||||||
Passed via `--wallet` parameter or `S3_GW_WALLET` environment variable.
|
Passed via `--wallet` parameter or `S3_GW_WALLET_PATH` environment variable.
|
||||||
|
|
||||||
These two commands are functionally equivalent, they run the gate with one
|
These two commands are functionally equivalent, they run the gate with one
|
||||||
backend node, some keys and otherwise default settings:
|
backend node, some keys and otherwise default settings:
|
||||||
|
|
|
@ -102,7 +102,7 @@ func newApp(ctx context.Context, l *zap.Logger, v *viper.Viper) *App {
|
||||||
}
|
}
|
||||||
|
|
||||||
password := wallet.GetPassword(v, cfgWalletPassphrase)
|
password := wallet.GetPassword(v, cfgWalletPassphrase)
|
||||||
if key, err = wallet.GetKeyFromPath(v.GetString(cfgWallet), v.GetString(cfgAddress), password); err != nil {
|
if key, err = wallet.GetKeyFromPath(v.GetString(cfgWalletPath), v.GetString(cfgWalletAddress), password); err != nil {
|
||||||
l.Fatal("could not load NeoFS private key", zap.Error(err))
|
l.Fatal("could not load NeoFS private key", zap.Error(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,11 @@ const ( // Settings.
|
||||||
cfgLoggerLevel = "logger.level"
|
cfgLoggerLevel = "logger.level"
|
||||||
|
|
||||||
// Wallet.
|
// Wallet.
|
||||||
cfgWallet = "wallet"
|
cfgWalletPath = "wallet.path"
|
||||||
cfgAddress = "address"
|
cfgWalletAddress = "wallet.address"
|
||||||
cfgWalletPassphrase = "wallet.passphrase"
|
cfgWalletPassphrase = "wallet.passphrase"
|
||||||
|
cmdWallet = "wallet"
|
||||||
|
cmdAddress = "address"
|
||||||
|
|
||||||
// HTTPS/TLS.
|
// HTTPS/TLS.
|
||||||
cfgTLSKeyFile = "tls.key_file"
|
cfgTLSKeyFile = "tls.key_file"
|
||||||
|
@ -187,8 +189,8 @@ func newSettings() *viper.Viper {
|
||||||
help := flags.BoolP(cmdHelp, "h", false, "show help")
|
help := flags.BoolP(cmdHelp, "h", false, "show help")
|
||||||
versionFlag := flags.BoolP(cmdVersion, "v", false, "show version")
|
versionFlag := flags.BoolP(cmdVersion, "v", false, "show version")
|
||||||
|
|
||||||
flags.StringP(cfgWallet, "w", "", `path to the wallet`)
|
flags.StringP(cmdWallet, "w", "", `path to the wallet`)
|
||||||
flags.String(cfgAddress, "", `address of wallet account`)
|
flags.String(cmdAddress, "", `address of wallet account`)
|
||||||
config := flags.String(cmdConfig, "", "config path")
|
config := flags.String(cmdConfig, "", "config path")
|
||||||
|
|
||||||
flags.Duration(cfgHealthcheckTimeout, defaultHealthcheckTimeout, "set timeout to check node health during rebalance")
|
flags.Duration(cfgHealthcheckTimeout, defaultHealthcheckTimeout, "set timeout to check node health during rebalance")
|
||||||
|
@ -232,6 +234,13 @@ func newSettings() *viper.Viper {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := v.BindPFlag(cfgWalletPath, flags.Lookup(cmdWallet)); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if err := v.BindPFlag(cfgWalletAddress, flags.Lookup(cmdAddress)); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
if err := flags.Parse(os.Args); err != nil {
|
if err := flags.Parse(os.Args); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# Wallet
|
# Wallet
|
||||||
# Path to wallet
|
# Path to wallet
|
||||||
S3_GW_WALLET=/path/to/wallet.json
|
S3_GW_WALLET_PATH=/path/to/wallet.json
|
||||||
# Account address. If omitted default one will be used.
|
# Account address. If omitted default one will be used.
|
||||||
S3_GW_ADDRESS=NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP
|
S3_GW_WALLET_ADDRESS=NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP
|
||||||
# Passphrase to decrypt wallet.
|
# Passphrase to decrypt wallet.
|
||||||
S3_GW_WALLET_PASSPHRASE=s3
|
S3_GW_WALLET_PASSPHRASE=s3
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
# Wallet address, path to the wallet must be set as cli parameter or environment variable
|
# Wallet address, path to the wallet must be set as cli parameter or environment variable
|
||||||
wallet:
|
wallet:
|
||||||
passphrase: "" # Passphrase to decrypt wallet.
|
path: /path/to/wallet.json # Path to wallet
|
||||||
|
passphrase: "" # Passphrase to decrypt wallet. If you're using a wallet without a password, place '' here.
|
||||||
# Account address. If omitted default one will be used.
|
address: NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP # Account address. If omitted default one will be used.
|
||||||
address: NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP
|
|
||||||
|
|
||||||
# Nodes configuration
|
# Nodes configuration
|
||||||
# This configuration makes the gateway use the first node (grpc://s01.neofs.devenv:8080)
|
# This configuration makes the gateway use the first node (grpc://s01.neofs.devenv:8080)
|
||||||
|
|
|
@ -137,8 +137,6 @@ There are some custom types used for brevity:
|
||||||
### General section
|
### General section
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
address: NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP
|
|
||||||
|
|
||||||
listen_address: 0.0.0.0:8084
|
listen_address: 0.0.0.0:8084
|
||||||
|
|
||||||
rpc_endpoint: http://morph-chain.neofs.devenv:30333
|
rpc_endpoint: http://morph-chain.neofs.devenv:30333
|
||||||
|
@ -159,7 +157,6 @@ default_policy: REP 3
|
||||||
|
|
||||||
| Parameter | Type | Default value | Description |
|
| Parameter | Type | Default value | Description |
|
||||||
|------------------------|------------|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|------------------------|------------|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `address` | `string` | | Account address to get from wallet. If omitted default one will be used. |
|
|
||||||
| `listen_address` | `string` | `0.0.0.0:8080` | The address that the gateway is listening on. |
|
| `listen_address` | `string` | `0.0.0.0:8080` | The address that the gateway is listening on. |
|
||||||
| `rpc_endpoint` | `string` | | The address of the RPC host to which the gateway connects to resolve bucket names (required to use the `nns` resolver). |
|
| `rpc_endpoint` | `string` | | The address of the RPC host to which the gateway connects to resolve bucket names (required to use the `nns` resolver). |
|
||||||
| `resolve_order` | `[]string` | `[dns]` | Order of bucket name resolvers to use. Available resolvers: `dns`, `nns`. | |
|
| `resolve_order` | `[]string` | `[dns]` | Order of bucket name resolvers to use. Available resolvers: `dns`, `nns`. | |
|
||||||
|
@ -175,12 +172,16 @@ default_policy: REP 3
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
wallet:
|
wallet:
|
||||||
passphrase: "password"
|
path: /path/to/wallet.json # Path to wallet
|
||||||
|
passphrase: "" # Passphrase to decrypt wallet.
|
||||||
|
address: NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP
|
||||||
```
|
```
|
||||||
|
|
||||||
| Parameter | Type | Default value | Description |
|
| Parameter | Type | Default value | Description |
|
||||||
|--------------|----------|---------------|-------------------------------|
|
|--------------|----------|---------------|---------------------------------------------------------------------------|
|
||||||
|
| `path` | `string` | | Path to wallet |
|
||||||
| `passphrase` | `string` | | Passphrase to decrypt wallet. |
|
| `passphrase` | `string` | | Passphrase to decrypt wallet. |
|
||||||
|
| `address` | `string` | | Account address to get from wallet. If omitted default one will be used. |
|
||||||
|
|
||||||
### `peers` section
|
### `peers` section
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue