diff --git a/README.md b/README.md index f75f12a5..09a75861 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Minimalistic S3 gateway setup needs: `S3_GW_PEERS__WEIGHT` environment variables (gateway supports multiple NeoFS nodes with weighted load balancing). * 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 backend node, some keys and otherwise default settings: diff --git a/cmd/s3-gw/app.go b/cmd/s3-gw/app.go index 393499f8..039e1a62 100644 --- a/cmd/s3-gw/app.go +++ b/cmd/s3-gw/app.go @@ -102,7 +102,7 @@ func newApp(ctx context.Context, l *zap.Logger, v *viper.Viper) *App { } 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)) } diff --git a/cmd/s3-gw/app_settings.go b/cmd/s3-gw/app_settings.go index 077f0f12..29cf8c36 100644 --- a/cmd/s3-gw/app_settings.go +++ b/cmd/s3-gw/app_settings.go @@ -34,9 +34,11 @@ const ( // Settings. cfgLoggerLevel = "logger.level" // Wallet. - cfgWallet = "wallet" - cfgAddress = "address" + cfgWalletPath = "wallet.path" + cfgWalletAddress = "wallet.address" cfgWalletPassphrase = "wallet.passphrase" + cmdWallet = "wallet" + cmdAddress = "address" // HTTPS/TLS. cfgTLSKeyFile = "tls.key_file" @@ -187,8 +189,8 @@ func newSettings() *viper.Viper { help := flags.BoolP(cmdHelp, "h", false, "show help") versionFlag := flags.BoolP(cmdVersion, "v", false, "show version") - flags.StringP(cfgWallet, "w", "", `path to the wallet`) - flags.String(cfgAddress, "", `address of wallet account`) + flags.StringP(cmdWallet, "w", "", `path to the wallet`) + flags.String(cmdAddress, "", `address of wallet account`) config := flags.String(cmdConfig, "", "config path") flags.Duration(cfgHealthcheckTimeout, defaultHealthcheckTimeout, "set timeout to check node health during rebalance") @@ -232,6 +234,13 @@ func newSettings() *viper.Viper { 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 { panic(err) } diff --git a/config/config.env b/config/config.env index 88f8ecb8..60bfd3e0 100644 --- a/config/config.env +++ b/config/config.env @@ -1,8 +1,8 @@ # 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. -S3_GW_ADDRESS=NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP +S3_GW_WALLET_ADDRESS=NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP # Passphrase to decrypt wallet. S3_GW_WALLET_PASSPHRASE=s3 diff --git a/config/config.yaml b/config/config.yaml index d645dad0..d421b23b 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -1,9 +1,8 @@ # Wallet address, path to the wallet must be set as cli parameter or environment variable wallet: - passphrase: "" # Passphrase to decrypt wallet. - -# Account address. If omitted default one will be used. -address: NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP + path: /path/to/wallet.json # Path to wallet + passphrase: "" # Passphrase to decrypt wallet. If you're using a wallet without a password, place '' here. + address: NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP # Account address. If omitted default one will be used. # Nodes configuration # This configuration makes the gateway use the first node (grpc://s01.neofs.devenv:8080) diff --git a/docs/configuration.md b/docs/configuration.md index d5b6c455..0de45e1a 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -137,8 +137,6 @@ There are some custom types used for brevity: ### General section ```yaml -address: NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP - listen_address: 0.0.0.0:8084 rpc_endpoint: http://morph-chain.neofs.devenv:30333 @@ -159,7 +157,6 @@ default_policy: REP 3 | 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. | | `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`. | | @@ -175,12 +172,16 @@ default_policy: REP 3 ```yaml wallet: - passphrase: "password" + path: /path/to/wallet.json # Path to wallet + passphrase: "" # Passphrase to decrypt wallet. + address: NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP ``` -| Parameter | Type | Default value | Description | -|--------------|----------|---------------|-------------------------------| -| `passphrase` | `string` | | Passphrase to decrypt wallet. | +| Parameter | Type | Default value | Description | +|--------------|----------|---------------|---------------------------------------------------------------------------| +| `path` | `string` | | Path to wallet | +| `passphrase` | `string` | | Passphrase to decrypt wallet. | +| `address` | `string` | | Account address to get from wallet. If omitted default one will be used. | ### `peers` section