Skip to content

Commit

Permalink
Revert "Implements repository initialization with default config"
Browse files Browse the repository at this point in the history
See #2748

This reverts commit 6989686.

License: MIT
Signed-off-by: Lars Gierth <larsg@systemli.org>
  • Loading branch information
Lars Gierth committed May 19, 2016
1 parent 0f58ceb commit 77ef391
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 85 deletions.
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.

0 comments on commit 77ef391

Please sign in to comment.