Skip to content

Commit

Permalink
apply feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
fredcarle committed Sep 18, 2024
1 parent 2c542a8 commit aab3f33
Show file tree
Hide file tree
Showing 66 changed files with 1,071 additions and 1,063 deletions.
54 changes: 27 additions & 27 deletions cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,31 @@ var configPaths = []string{

// configFlags is a mapping of cli flag names to config keys to bind.
var configFlags = map[string]string{
"log-level": "log.level",
"log-output": "log.output",
"log-format": "log.format",
"log-stacktrace": "log.stacktrace",
"log-source": "log.source",
"log-overrides": "log.overrides",
"no-log-color": "log.colordisabled",
"url": "api.address",
"max-txn-retries": "datastore.maxtxnretries",
"store": "datastore.store",
"valuelogfilesize": "datastore.badger.valuelogfilesize",
"peers": "net.peers",
"p2paddr": "net.p2paddresses",
"no-p2p": "net.p2pdisabled",
"allowed-origins": "api.allowed-origins",
"pubkeypath": "api.pubkeypath",
"privkeypath": "api.privkeypath",
"keyring-namespace": "keyring.namespace",
"keyring-backend": "keyring.backend",
"keyring-path": "keyring.path",
"no-keyring": "keyring.disabled",
"no-encryption-key": "keyring.noencryptionkey",
"keyring-secret-file": "keyring.secretfile",
"source-hub-address": "acp.sourceHub.address",
"development": "development",
"log-level": "log.level",
"log-output": "log.output",
"log-format": "log.format",
"log-stacktrace": "log.stacktrace",
"log-source": "log.source",
"log-overrides": "log.overrides",
"no-log-color": "log.colordisabled",
"url": "api.address",
"max-txn-retries": "datastore.maxtxnretries",
"store": "datastore.store",
"no-encryption": "datastore.noencryption",
"valuelogfilesize": "datastore.badger.valuelogfilesize",
"peers": "net.peers",
"p2paddr": "net.p2paddresses",
"no-p2p": "net.p2pdisabled",
"allowed-origins": "api.allowed-origins",
"pubkeypath": "api.pubkeypath",
"privkeypath": "api.privkeypath",
"keyring-namespace": "keyring.namespace",
"keyring-backend": "keyring.backend",
"keyring-path": "keyring.path",
"no-keyring": "keyring.disabled",
"source-hub-address": "acp.sourceHub.address",
"development": "development",
"secret-file": "secretfile",
}

// configDefaults contains default values for config entries.
Expand All @@ -88,14 +88,14 @@ var configDefaults = map[string]any{
"keyring.disabled": false,
"keyring.namespace": "defradb",
"keyring.path": "keys",
"keyring.secretfile": ".env",
"log.caller": false,
"log.colordisabled": false,
"log.format": "text",
"log.level": "info",
"log.output": "stderr",
"log.source": false,
"log.stacktrace": false,
"secretfile": ".env",
}

// defaultConfig returns a new config with default values.
Expand Down Expand Up @@ -164,7 +164,7 @@ func loadConfig(rootdir string, flags *pflag.FlagSet) (*viper.Viper, error) {
}

// load environment variables from .env file if one exists
_ = godotenv.Load(cfg.GetString("keyring.secretfile"))
_ = godotenv.Load(cfg.GetString("secretfile"))

// set logging config
corelog.SetConfig(corelog.Config{
Expand Down
4 changes: 2 additions & 2 deletions cli/keyring_generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Example:
defradb keyring generate
Example: with no encryption key
defradb keyring generate --no-encryption-key
defradb keyring generate --no-encryption
Example: with no peer key
defradb keyring generate --no-peer-key
Expand Down Expand Up @@ -73,7 +73,7 @@ Example: with system keyring
return nil
},
}
cmd.Flags().BoolVar(&noEncryptionKey, "no-encryption-key", false,
cmd.Flags().BoolVar(&noEncryptionKey, "no-encryption", false,
"Skip generating an encryption key. Encryption at rest will be disabled")
cmd.Flags().BoolVar(&noPeerKey, "no-peer-key", false,
"Skip generating a peer key.")
Expand Down
2 changes: 1 addition & 1 deletion cli/keyring_generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestKeyringGenerateNoEncryptionKey(t *testing.T) {
require.NoError(t, err)

cmd := NewDefraCommand()
cmd.SetArgs([]string{"keyring", "generate", "--no-encryption-key", "--rootdir", rootdir})
cmd.SetArgs([]string{"keyring", "generate", "--no-encryption", "--rootdir", rootdir})

err = cmd.Execute()
require.NoError(t, err)
Expand Down
8 changes: 4 additions & 4 deletions cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ Start a DefraDB node, interact with a local or remote node, and much more.
cfg.GetString(configFlags["keyring-path"]),
"Path to store encrypted keys when using the file backend",
)
cmd.PersistentFlags().String(
"keyring-secret-file",
cfg.GetString(configFlags["keyring-secret-file"]),
"Path to the file containing the keyring secret")
cmd.PersistentFlags().Bool(
"no-keyring",
cfg.GetBool(configFlags["no-keyring"]),
Expand All @@ -106,5 +102,9 @@ Start a DefraDB node, interact with a local or remote node, and much more.
cfg.GetString(configFlags["source-hub-address"]),
"The SourceHub address authorized by the client to make SourceHub transactions on behalf of the actor",
)
cmd.PersistentFlags().String(
"secret-file",
cfg.GetString(configFlags["secret-file"]),
"Path to the file containing secrets")
return cmd
}
6 changes: 3 additions & 3 deletions cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func MakeStartCommand() *cobra.Command {

// load the optional encryption key
encryptionKey, err := kr.Get(encryptionKeyName)
if err != nil && errors.Is(err, keyring.ErrNotFound) && !cfg.GetBool("keyring.noencryptionkey") {
if err != nil && errors.Is(err, keyring.ErrNotFound) && !cfg.GetBool("datastore.noencryption") {
encryptionKey, err = crypto.GenerateAES256()
if err != nil {
return err

Check warning on line 125 in cli/start.go

View check run for this annotation

Codecov / codecov/patch

cli/start.go#L122-L125

Added lines #L122 - L125 were not covered by tests
Expand Down Expand Up @@ -247,8 +247,8 @@ func MakeStartCommand() *cobra.Command {
"Enables a set of features that make development easier but should not be enabled in production",
)
cmd.Flags().Bool(
"no-encryption-key",
cfg.GetBool(configFlags["no-encryption-key"]),
"no-encryption",
cfg.GetBool(configFlags["no-encryption"]),
"Skip generating an encryption key. Encryption at rest will be disabled. WARNING: This cannot be undone.")
return cmd
}
8 changes: 8 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ The number of retries to make in the event of a transaction conflict. Defaults t

Currently this is only used within the P2P system and will not affect operations initiated by users.

## `datastore.noencryption`

Skip generating an encryption key. Encryption at rest will be disabled. **WARNING**: This cannot be undone.

## `datastore.badger.path`

The path to the database data file(s). Defaults to `data`.
Expand Down Expand Up @@ -156,3 +160,7 @@ transactions created by the node is stored. Required when using `acp.type`:`sour
The SourceHub address of the actor that client-side actions should permit to make SourceHub actions on
their behalf. This is a client-side only config param. It is required if the client wishes to make
SourceHub ACP requests in order to create protected data.

## `secretfile`

Path to the file containing secrets. Defaults to `.env`.
32 changes: 16 additions & 16 deletions docs/website/references/cli/defradb.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ Start a DefraDB node, interact with a local or remote node, and much more.
### Options

```
-h, --help help for defradb
--keyring-backend string Keyring backend to use. Options are file or system (default "file")
--keyring-namespace string Service name to use when using the system backend (default "defradb")
--keyring-path string Path to store encrypted keys when using the file backend (default "keys")
--keyring-secret-file string Path to the file containing the keyring secret (default ".env")
--log-format string Log format to use. Options are text or json (default "text")
--log-level string Log level to use. Options are debug, info, error, fatal (default "info")
--log-output string Log output path. Options are stderr or stdout. (default "stderr")
--log-overrides string Logger config overrides. Format <name>,<key>=<val>,...;<name>,...
--log-source Include source location in logs
--log-stacktrace Include stacktrace in error and fatal logs
--no-keyring Disable the keyring and generate ephemeral keys
--no-log-color Disable colored log output
--rootdir string Directory for persistent data (default: $HOME/.defradb)
--source-hub-address string The SourceHub address authorized by the client to make SourceHub transactions on behalf of the actor
--url string URL of HTTP endpoint to listen on or connect to (default "127.0.0.1:9181")
-h, --help help for defradb
--keyring-backend string Keyring backend to use. Options are file or system (default "file")
--keyring-namespace string Service name to use when using the system backend (default "defradb")
--keyring-path string Path to store encrypted keys when using the file backend (default "keys")
--log-format string Log format to use. Options are text or json (default "text")
--log-level string Log level to use. Options are debug, info, error, fatal (default "info")
--log-output string Log output path. Options are stderr or stdout. (default "stderr")
--log-overrides string Logger config overrides. Format <name>,<key>=<val>,...;<name>,...
--log-source Include source location in logs
--log-stacktrace Include stacktrace in error and fatal logs
--no-keyring Disable the keyring and generate ephemeral keys
--no-log-color Disable colored log output
--rootdir string Directory for persistent data (default: $HOME/.defradb)
--secret-file string Path to the file containing secrets (default ".env")
--source-hub-address string The SourceHub address authorized by the client to make SourceHub transactions on behalf of the actor
--url string URL of HTTP endpoint to listen on or connect to (default "127.0.0.1:9181")
```

### SEE ALSO
Expand Down
30 changes: 15 additions & 15 deletions docs/website/references/cli/defradb_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ Execute queries, add schema types, obtain node info, etc.
### Options inherited from parent commands

```
--keyring-backend string Keyring backend to use. Options are file or system (default "file")
--keyring-namespace string Service name to use when using the system backend (default "defradb")
--keyring-path string Path to store encrypted keys when using the file backend (default "keys")
--keyring-secret-file string Path to the file containing the keyring secret (default ".env")
--log-format string Log format to use. Options are text or json (default "text")
--log-level string Log level to use. Options are debug, info, error, fatal (default "info")
--log-output string Log output path. Options are stderr or stdout. (default "stderr")
--log-overrides string Logger config overrides. Format <name>,<key>=<val>,...;<name>,...
--log-source Include source location in logs
--log-stacktrace Include stacktrace in error and fatal logs
--no-keyring Disable the keyring and generate ephemeral keys
--no-log-color Disable colored log output
--rootdir string Directory for persistent data (default: $HOME/.defradb)
--source-hub-address string The SourceHub address authorized by the client to make SourceHub transactions on behalf of the actor
--url string URL of HTTP endpoint to listen on or connect to (default "127.0.0.1:9181")
--keyring-backend string Keyring backend to use. Options are file or system (default "file")
--keyring-namespace string Service name to use when using the system backend (default "defradb")
--keyring-path string Path to store encrypted keys when using the file backend (default "keys")
--log-format string Log format to use. Options are text or json (default "text")
--log-level string Log level to use. Options are debug, info, error, fatal (default "info")
--log-output string Log output path. Options are stderr or stdout. (default "stderr")
--log-overrides string Logger config overrides. Format <name>,<key>=<val>,...;<name>,...
--log-source Include source location in logs
--log-stacktrace Include stacktrace in error and fatal logs
--no-keyring Disable the keyring and generate ephemeral keys
--no-log-color Disable colored log output
--rootdir string Directory for persistent data (default: $HOME/.defradb)
--secret-file string Path to the file containing secrets (default ".env")
--source-hub-address string The SourceHub address authorized by the client to make SourceHub transactions on behalf of the actor
--url string URL of HTTP endpoint to listen on or connect to (default "127.0.0.1:9181")
```

### SEE ALSO
Expand Down
34 changes: 17 additions & 17 deletions docs/website/references/cli/defradb_client_acp.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ Learn more about [ACP](/acp/README.md)
### Options inherited from parent commands

```
-i, --identity string Hex formatted private key used to authenticate with ACP
--keyring-backend string Keyring backend to use. Options are file or system (default "file")
--keyring-namespace string Service name to use when using the system backend (default "defradb")
--keyring-path string Path to store encrypted keys when using the file backend (default "keys")
--keyring-secret-file string Path to the file containing the keyring secret (default ".env")
--log-format string Log format to use. Options are text or json (default "text")
--log-level string Log level to use. Options are debug, info, error, fatal (default "info")
--log-output string Log output path. Options are stderr or stdout. (default "stderr")
--log-overrides string Logger config overrides. Format <name>,<key>=<val>,...;<name>,...
--log-source Include source location in logs
--log-stacktrace Include stacktrace in error and fatal logs
--no-keyring Disable the keyring and generate ephemeral keys
--no-log-color Disable colored log output
--rootdir string Directory for persistent data (default: $HOME/.defradb)
--source-hub-address string The SourceHub address authorized by the client to make SourceHub transactions on behalf of the actor
--tx uint Transaction ID
--url string URL of HTTP endpoint to listen on or connect to (default "127.0.0.1:9181")
-i, --identity string Hex formatted private key used to authenticate with ACP
--keyring-backend string Keyring backend to use. Options are file or system (default "file")
--keyring-namespace string Service name to use when using the system backend (default "defradb")
--keyring-path string Path to store encrypted keys when using the file backend (default "keys")
--log-format string Log format to use. Options are text or json (default "text")
--log-level string Log level to use. Options are debug, info, error, fatal (default "info")
--log-output string Log output path. Options are stderr or stdout. (default "stderr")
--log-overrides string Logger config overrides. Format <name>,<key>=<val>,...;<name>,...
--log-source Include source location in logs
--log-stacktrace Include stacktrace in error and fatal logs
--no-keyring Disable the keyring and generate ephemeral keys
--no-log-color Disable colored log output
--rootdir string Directory for persistent data (default: $HOME/.defradb)
--secret-file string Path to the file containing secrets (default ".env")
--source-hub-address string The SourceHub address authorized by the client to make SourceHub transactions on behalf of the actor
--tx uint Transaction ID
--url string URL of HTTP endpoint to listen on or connect to (default "127.0.0.1:9181")
```

### SEE ALSO
Expand Down
34 changes: 17 additions & 17 deletions docs/website/references/cli/defradb_client_acp_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ Interact with the acp policy features of DefraDB instance
### Options inherited from parent commands

```
-i, --identity string Hex formatted private key used to authenticate with ACP
--keyring-backend string Keyring backend to use. Options are file or system (default "file")
--keyring-namespace string Service name to use when using the system backend (default "defradb")
--keyring-path string Path to store encrypted keys when using the file backend (default "keys")
--keyring-secret-file string Path to the file containing the keyring secret (default ".env")
--log-format string Log format to use. Options are text or json (default "text")
--log-level string Log level to use. Options are debug, info, error, fatal (default "info")
--log-output string Log output path. Options are stderr or stdout. (default "stderr")
--log-overrides string Logger config overrides. Format <name>,<key>=<val>,...;<name>,...
--log-source Include source location in logs
--log-stacktrace Include stacktrace in error and fatal logs
--no-keyring Disable the keyring and generate ephemeral keys
--no-log-color Disable colored log output
--rootdir string Directory for persistent data (default: $HOME/.defradb)
--source-hub-address string The SourceHub address authorized by the client to make SourceHub transactions on behalf of the actor
--tx uint Transaction ID
--url string URL of HTTP endpoint to listen on or connect to (default "127.0.0.1:9181")
-i, --identity string Hex formatted private key used to authenticate with ACP
--keyring-backend string Keyring backend to use. Options are file or system (default "file")
--keyring-namespace string Service name to use when using the system backend (default "defradb")
--keyring-path string Path to store encrypted keys when using the file backend (default "keys")
--log-format string Log format to use. Options are text or json (default "text")
--log-level string Log level to use. Options are debug, info, error, fatal (default "info")
--log-output string Log output path. Options are stderr or stdout. (default "stderr")
--log-overrides string Logger config overrides. Format <name>,<key>=<val>,...;<name>,...
--log-source Include source location in logs
--log-stacktrace Include stacktrace in error and fatal logs
--no-keyring Disable the keyring and generate ephemeral keys
--no-log-color Disable colored log output
--rootdir string Directory for persistent data (default: $HOME/.defradb)
--secret-file string Path to the file containing secrets (default ".env")
--source-hub-address string The SourceHub address authorized by the client to make SourceHub transactions on behalf of the actor
--tx uint Transaction ID
--url string URL of HTTP endpoint to listen on or connect to (default "127.0.0.1:9181")
```

### SEE ALSO
Expand Down
Loading

0 comments on commit aab3f33

Please sign in to comment.