Skip to content

Commit

Permalink
Fix default value privateKeyPath resolves homeDir correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
iknite committed Nov 27, 2018
1 parent 6a732f0 commit d457f10
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 32 deletions.
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,47 +61,47 @@ Our work draws strongly from the **Balloon proposals**, with some modifications
- add event

```
go run \
main.go \
--apikey my-key \
client \
--endpoint http://localhost:8080 \
add \
--key 'test event' \
--value 2 \
--log info
go run \
main.go \
--apikey my-key \
client \
--endpoint http://localhost:8080 \
add \
--key 'test event' \
--value 2 \
--log info
```
- membership event
```
go run \
main.go \
--apikey my-key \
client \
--endpoint http://localhost:8080 \
membership \
--hyperDigest 10aa40be23fb739332e2b9c849f2f110b2d209346500c24f70db442022ef38f2 \
--historyDigest 776b33eab8ed829ecffab3d579bf7ccbcc126b94bac1aaca7d5d8b0a2687bdec \
--version 0 \
--key 'test event' \
--log info
go run \
main.go \
--apikey my-key \
client \
--endpoint http://localhost:8080 \
membership \
--hyperDigest 10aa40be23fb739332e2b9c849f2f110b2d209346500c24f70db442022ef38f2 \
--historyDigest 776b33eab8ed829ecffab3d579bf7ccbcc126b94bac1aaca7d5d8b0a2687bdec \
--version 0 \
--key 'test event' \
--log info
```
- verify event
```
go run \
main.go \
--apikey my-key \
client \
--endpoint http://localhost:8080 \
membership \
--hyperDigest 10aa40be23fb739332e2b9c849f2f110b2d209346500c24f70db442022ef38f2 \
--historyDigest 776b33eab8ed829ecffab3d579bf7ccbcc126b94bac1aaca7d5d8b0a2687bdec \
--version 0 \
--key 'test event' \
--log info
go run \
main.go \
--apikey my-key \
client \
--endpoint http://localhost:8080 \
membership \
--hyperDigest 10aa40be23fb739332e2b9c849f2f110b2d209346500c24f70db442022ef38f2 \
--historyDigest 776b33eab8ed829ecffab3d579bf7ccbcc126b94bac1aaca7d5d8b0a2687bdec \
--version 0 \
--key 'test event' \
--log info
```
## Useful commands
Expand Down
11 changes: 10 additions & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
package cmd

import (
"fmt"
"os"
"os/user"

"github.com/spf13/cobra"

Expand All @@ -26,6 +28,8 @@ import (
)

func newStartCommand() *cobra.Command {
const defaultKeyPath = "~/.ssh/id_ed25519"

var (
nodeId, httpAddr, raftAddr, mgmtAddr, joinAddr string
dbPath, raftPath, privateKeyPath string
Expand All @@ -42,6 +46,11 @@ func newStartCommand() *cobra.Command {

Run: func(cmd *cobra.Command, args []string) {

if privateKeyPath == defaultKeyPath {
usr, _ := user.Current()
privateKeyPath = fmt.Sprintf("%s/.ssh/id_ed25519", usr.HomeDir)
}

srv, err := server.NewServer(
nodeId,
httpAddr,
Expand Down Expand Up @@ -80,7 +89,7 @@ func newStartCommand() *cobra.Command {
cmd.Flags().StringSliceVarP(&gossipJoinAddr, "gossip-join-addr", "", []string{}, "Gossip: Comma-delimited list of nodes ([host]:port), through which a cluster can be joined")
cmd.Flags().StringVarP(&dbPath, "dbpath", "p", "/var/tmp/qed/data", "Set default storage path")
cmd.Flags().StringVarP(&raftPath, "raftpath", "", "/var/tmp/qed/raft", "Set raft storage path")
cmd.Flags().StringVarP(&privateKeyPath, "keypath", "y", "~/.ssh/id_ed25519", "Path to the ed25519 key file")
cmd.Flags().StringVarP(&privateKeyPath, "keypath", "y", defaultKeyPath, "Path to the ed25519 key file")
cmd.Flags().BoolVarP(&profiling, "profiling", "f", false, "Allow a pprof url (localhost:6060) for profiling purposes")

// INFO: testing purposes
Expand Down

0 comments on commit d457f10

Please sign in to comment.