cmd/uplink: remove non-interactive mode from setup

Change-Id: I7934cfd0ef06e009a6ff38694ba0dd1806ffcdd8
This commit is contained in:
Bryan White 2020-01-23 15:08:10 +01:00 committed by Kaloyan Raev
parent 524da4d2db
commit f917fecc61
2 changed files with 2 additions and 45 deletions

View File

@ -34,7 +34,6 @@ const advancedFlagName = "advanced"
// UplinkFlags configuration flags
type UplinkFlags struct {
NonInteractive bool `help:"disable interactive mode" default:"false" setup:"true"`
Config
Version checker.Config

View File

@ -38,6 +38,8 @@ func init() {
}
func cmdSetup(cmd *cobra.Command, args []string) (err error) {
ctx, _ := process.Ctx(cmd)
if cmd.Flag("access").Changed {
return ErrAccessFlag
}
@ -47,50 +49,6 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
return err
}
if setupCfg.NonInteractive {
return cmdSetupNonInteractive(cmd, setupDir)
}
return cmdSetupInteractive(cmd, setupDir)
}
// cmdSetupNonInteractive sets up uplink non-interactively.
func cmdSetupNonInteractive(cmd *cobra.Command, setupDir string) error {
// ensure we're using the access for the setup
access, err := setupCfg.GetAccess()
if err != nil {
return err
}
// apply helpful default host and port to the address
vip, err := process.Viper(cmd)
if err != nil {
return err
}
access.SatelliteAddr, err = ApplyDefaultHostAndPortToAddr(
access.SatelliteAddr, vip.GetString("satellite-addr"))
if err != nil {
return err
}
accessData, err := access.Serialize()
if err != nil {
return err
}
err = os.MkdirAll(setupDir, 0700)
if err != nil {
return err
}
return Error.Wrap(process.SaveConfig(cmd, filepath.Join(setupDir, process.DefaultCfgFilename),
process.SaveConfigWithOverride("access", accessData),
process.SaveConfigRemovingDeprecated()))
}
// cmdSetupInteractive sets up uplink interactively.
func cmdSetupInteractive(cmd *cobra.Command, setupDir string) error {
ctx, _ := process.Ctx(cmd)
satelliteAddress, err := wizard.PromptForSatellite(cmd)
if err != nil {
return Error.Wrap(err)