cmd/uplink: remove non-interactive mode from setup
Change-Id: I7934cfd0ef06e009a6ff38694ba0dd1806ffcdd8
This commit is contained in:
parent
524da4d2db
commit
f917fecc61
@ -34,7 +34,6 @@ const advancedFlagName = "advanced"
|
|||||||
|
|
||||||
// UplinkFlags configuration flags
|
// UplinkFlags configuration flags
|
||||||
type UplinkFlags struct {
|
type UplinkFlags struct {
|
||||||
NonInteractive bool `help:"disable interactive mode" default:"false" setup:"true"`
|
|
||||||
Config
|
Config
|
||||||
|
|
||||||
Version checker.Config
|
Version checker.Config
|
||||||
|
@ -38,6 +38,8 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func cmdSetup(cmd *cobra.Command, args []string) (err error) {
|
func cmdSetup(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx, _ := process.Ctx(cmd)
|
||||||
|
|
||||||
if cmd.Flag("access").Changed {
|
if cmd.Flag("access").Changed {
|
||||||
return ErrAccessFlag
|
return ErrAccessFlag
|
||||||
}
|
}
|
||||||
@ -47,50 +49,6 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
|
|||||||
return err
|
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)
|
satelliteAddress, err := wizard.PromptForSatellite(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Error.Wrap(err)
|
return Error.Wrap(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user