Skip to content

Commit

Permalink
Rename generateSecret -> customSecret
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrisham committed Jul 28, 2017
1 parent 73d4b1f commit 110a3e7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ipfs-cluster-service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import (
// ProgramName of this application
const programName = `ipfs-cluster-service`

// name of the environment variable that may store cluster secret
const clusterEnvVar = `CLUSTER_SECRET`

// We store a commit id here
var commit string

Expand Down Expand Up @@ -214,9 +217,9 @@ configuration.
Action: func(c *cli.Context) error {
envSecret, envSecretDefined := os.LookupEnv("CLUSTER_SECRET")
if envSecretDefined {
initConfig(c.GlobalBool("force"), !c.Bool("custom-secret"), &envSecret)
initConfig(c.GlobalBool("force"), c.Bool("custom-secret"), &envSecret)
} else {
initConfig(c.GlobalBool("force"), !c.Bool("custom-secret"), nil)
initConfig(c.GlobalBool("force"), c.Bool("custom-secret"), nil)
}
return nil
},
Expand Down Expand Up @@ -369,7 +372,7 @@ func setupDebug() {
//SetFacilityLogLevel("libp2p-raft", l)
}

func initConfig(force bool, generateSecret bool, envSecret *string) {
func initConfig(force bool, customSecret bool, envSecret *string) {
if _, err := os.Stat(configPath); err == nil && !force {
err := fmt.Errorf("%s exists. Try running with -f", configPath)
checkErr("", err)
Expand All @@ -382,7 +385,7 @@ func initConfig(force bool, generateSecret bool, envSecret *string) {
// read cluster secret from env variable
fmt.Println("Reading cluster secret from CLUSTER_SECRET environment variable.")
cfg.ClusterSecret, err = ipfscluster.DecodeClusterSecret(*envSecret)
} else if !generateSecret {
} else if customSecret {
// get cluster secret from user
cfg.ClusterSecret, err = ipfscluster.DecodeClusterSecret(promptUser("Enter cluster secret (32-byte hex string): "))

Expand Down

0 comments on commit 110a3e7

Please sign in to comment.