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

Revert "Implements repository initialization with default config" #2749

Merged
merged 1 commit into from
May 20, 2016
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
37 changes: 7 additions & 30 deletions cmd/ipfs/init.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"encoding/json"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -33,9 +32,7 @@ at ~/.ipfs. To change the repo location, set the $IPFS_PATH environment variable
export IPFS_PATH=/path/to/ipfsrepo
`,
},
Arguments: []cmds.Argument{
cmds.FileArg("default-config", false, false, "Initialize with the given configuration.").EnableStdin(),
},

Options: []cmds.Option{
cmds.IntOption("bits", "b", "Number of bits to use in the generated RSA private key.").Default(nBitsForKeypairDefault),
cmds.BoolOption("empty-repo", "e", "Don't add and pin help files to the local storage.").Default(false),
Expand Down Expand Up @@ -78,24 +75,7 @@ at ~/.ipfs. To change the repo location, set the $IPFS_PATH environment variable
return
}

var conf *config.Config

f := req.Files()
if f != nil {
confFile, err := f.NextFile()
if err != nil {
res.SetError(err, cmds.ErrNormal)
return
}

conf = &config.Config{}
if err := json.NewDecoder(confFile).Decode(conf); err != nil {
res.SetError(err, cmds.ErrNormal)
return
}
}

if err := doInit(os.Stdout, req.InvocContext().ConfigRoot, empty, nBitsForKeypair, conf); err != nil {
if err := doInit(os.Stdout, req.InvocContext().ConfigRoot, empty, nBitsForKeypair); err != nil {
res.SetError(err, cmds.ErrNormal)
return
}
Expand All @@ -107,10 +87,10 @@ Reinitializing would overwrite your keys.
`)

func initWithDefaults(out io.Writer, repoRoot string) error {
return doInit(out, repoRoot, false, nBitsForKeypairDefault, nil)
return doInit(out, repoRoot, false, nBitsForKeypairDefault)
}

func doInit(out io.Writer, repoRoot string, empty bool, nBitsForKeypair int, conf *config.Config) error {
func doInit(out io.Writer, repoRoot string, empty bool, nBitsForKeypair int) error {
if _, err := fmt.Fprintf(out, "initializing ipfs node at %s\n", repoRoot); err != nil {
return err
}
Expand All @@ -123,12 +103,9 @@ func doInit(out io.Writer, repoRoot string, empty bool, nBitsForKeypair int, con
return errRepoExists
}

if conf == nil {
var err error
conf, err = config.Init(out, nBitsForKeypair)
if err != nil {
return err
}
conf, err := config.Init(out, nBitsForKeypair)
if err != nil {
return err
}

if err := fsrepo.Init(repoRoot, conf); err != nil {
Expand Down
55 changes: 0 additions & 55 deletions test/sharness/t0022-init-default.sh

This file was deleted.