Update Wizard to allow more easily addition of satellites and move package to cmd folder (#2340)
This commit is contained in:
parent
2cc01c7899
commit
57ef352b3c
@ -18,6 +18,7 @@ import (
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/storj/cmd/internal/wizard"
|
||||
"storj.io/storj/internal/fpath"
|
||||
libuplink "storj.io/storj/lib/uplink"
|
||||
"storj.io/storj/pkg/cfgstruct"
|
||||
@ -275,17 +276,17 @@ func (flags GatewayFlags) openProject(ctx context.Context) (*libuplink.Project,
|
||||
func (flags GatewayFlags) interactive(
|
||||
cmd *cobra.Command, setupDir string, encryptionKeyFilepath string, overrides map[string]interface{},
|
||||
) error {
|
||||
satelliteAddress, err := cfgstruct.PromptForSatellite(cmd)
|
||||
satelliteAddress, err := wizard.PromptForSatellite(cmd)
|
||||
if err != nil {
|
||||
return Error.Wrap(err)
|
||||
}
|
||||
|
||||
apiKey, err := cfgstruct.PromptForAPIKey()
|
||||
apiKey, err := wizard.PromptForAPIKey()
|
||||
if err != nil {
|
||||
return Error.Wrap(err)
|
||||
}
|
||||
|
||||
humanReadableKey, err := cfgstruct.PromptForEncryptionKey()
|
||||
humanReadableKey, err := wizard.PromptForEncryptionKey()
|
||||
if err != nil {
|
||||
return Error.Wrap(err)
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Copyright (C) 2019 Storj Labs, Inc.
|
||||
// See LICENSE for copying information
|
||||
|
||||
package cfgstruct
|
||||
package wizard
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -54,16 +54,25 @@ func applyDefaultHostAndPortToAddr(address, defaultAddress string) (string, erro
|
||||
|
||||
// PromptForSatellite handles user input for a satellite address to be used with wizards
|
||||
func PromptForSatellite(cmd *cobra.Command) (string, error) {
|
||||
_, err := fmt.Print(`
|
||||
Pick satellite to use:
|
||||
[1] us-central-1.tardigrade.io
|
||||
[2] europe-west-1.tardigrade.io
|
||||
[3] asia-east-1.tardigrade.io
|
||||
Please enter numeric choice or enter satellite address manually [1]: `)
|
||||
satellites := []string{"us-central-1.tardigrade.io", "europe-west-1.tardigrade.io", "asia-east-1.tardigrade.io"}
|
||||
|
||||
_, err := fmt.Print("Pick a satellite to use:\n")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
satellites := []string{"us-central-1.tardigrade.io", "europe-west-1.tardigrade.io", "asia-east-1.tardigrade.io"}
|
||||
|
||||
for iterator, value := range satellites {
|
||||
_, err := fmt.Printf("\t[%d] %s\n", iterator+1, value)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
}
|
||||
}
|
||||
|
||||
_, err = fmt.Print("Please enter numeric choice or enter satellite address manually [1]: ")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var satelliteAddress string
|
||||
n, err := fmt.Scanln(&satelliteAddress)
|
||||
if err != nil {
|
@ -14,6 +14,7 @@ import (
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/storj/cmd/internal/wizard"
|
||||
"storj.io/storj/internal/fpath"
|
||||
"storj.io/storj/pkg/cfgstruct"
|
||||
"storj.io/storj/pkg/process"
|
||||
@ -116,17 +117,17 @@ func cmdSetupNonInteractive(cmd *cobra.Command, setupDir string, encryptionKeyFi
|
||||
// or to a default path whose directory tree exists.
|
||||
func cmdSetupInteractive(cmd *cobra.Command, setupDir string, encryptionKeyFilepath string) error {
|
||||
|
||||
satelliteAddress, err := cfgstruct.PromptForSatellite(cmd)
|
||||
satelliteAddress, err := wizard.PromptForSatellite(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
apiKey, err := cfgstruct.PromptForAPIKey()
|
||||
apiKey, err := wizard.PromptForAPIKey()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
humanReadableKey, err := cfgstruct.PromptForEncryptionKey()
|
||||
humanReadableKey, err := wizard.PromptForEncryptionKey()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user