Skip to content

Commit

Permalink
Merge pull request #4816 from ipfs/fix/t0063-test-profile
Browse files Browse the repository at this point in the history
Fix t0063-daemon-init.sh by adding test profile to daemon
  • Loading branch information
whyrusleeping authored Mar 23, 2018
2 parents 1be6513 + 6b67125 commit b0ac2b8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 5 additions & 1 deletion cmd/ipfs/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
adjustFDLimitKwd = "manage-fdlimit"
enableGCKwd = "enable-gc"
initOptionKwd = "init"
initProfileOptionKwd = "init-profile"
ipfsMountKwd = "mount-ipfs"
ipnsMountKwd = "mount-ipns"
migrateKwd = "migrate"
Expand Down Expand Up @@ -148,6 +149,7 @@ Headers.

Options: []cmdkit.Option{
cmdkit.BoolOption(initOptionKwd, "Initialize ipfs with default settings if not already initialized"),
cmdkit.StringOption(initProfileOptionKwd, "Configuration profiles to apply for --init. See ipfs init --help for more"),
cmdkit.StringOption(routingOptionKwd, "Overrides the routing option").WithDefault("dht"),
cmdkit.BoolOption(mountKwd, "Mounts IPFS to the filesystem"),
cmdkit.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)"),
Expand Down Expand Up @@ -222,7 +224,9 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment

cfg := cctx.ConfigRoot
if !fsrepo.IsInitialized(cfg) {
err := initWithDefaults(os.Stdout, cfg)
profiles, _ := req.Options[initProfileOptionKwd].(string)

err := initWithDefaults(os.Stdout, cfg, profiles)
if err != nil {
re.SetError(err, cmdkit.ErrNormal)
return
Expand Down
9 changes: 7 additions & 2 deletions cmd/ipfs/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,13 @@ var errRepoExists = errors.New(`ipfs configuration file already exists!
Reinitializing would overwrite your keys.
`)

func initWithDefaults(out io.Writer, repoRoot string) error {
return doInit(out, repoRoot, false, nBitsForKeypairDefault, nil, nil)
func initWithDefaults(out io.Writer, repoRoot string, profile string) error {
var profiles []string
if profile != "" {
profiles = strings.Split(profile, ",")
}

return doInit(out, repoRoot, false, nBitsForKeypairDefault, profiles, nil)
}

func doInit(out io.Writer, repoRoot string, empty bool, nBitsForKeypair int, confProfiles []string, conf *config.Config) error {
Expand Down
2 changes: 1 addition & 1 deletion test/sharness/t0063-daemon-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test_ipfs_daemon_init() {
# server.

test_expect_success "'ipfs daemon --init' succeeds" '
ipfs daemon --init >actual_daemon 2>daemon_err &
ipfs daemon --init --init-profile=test >actual_daemon 2>daemon_err &
IPFS_PID=$!
sleep 2 &&
if ! kill -0 $IPFS_PID; then cat daemon_err; return 1; fi
Expand Down

0 comments on commit b0ac2b8

Please sign in to comment.