Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix t0063-daemon-init.sh by adding test profile to daemon #4816

Merged
merged 1 commit into from
Mar 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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