Remove ROVE_HOST
No need for two ways to set this
This commit is contained in:
parent
b2f6c1a0b1
commit
4a343f36a8
2 changed files with 8 additions and 22 deletions
|
@ -34,7 +34,6 @@ func printUsage() {
|
|||
fmt.Fprintln(os.Stderr, "\tversion outputs version info")
|
||||
fmt.Fprintln(os.Stderr, "\nEnvironment")
|
||||
fmt.Fprintln(os.Stderr, "\tUSER_DATA path to user data, defaults to "+defaultDataPath)
|
||||
fmt.Fprintln(os.Stderr, "\tROVE_HOST path to rove host server")
|
||||
}
|
||||
|
||||
const gRPCport = 9090
|
||||
|
@ -130,23 +129,16 @@ func InnerMain(command string, args ...string) error {
|
|||
|
||||
// Run config command before server needed
|
||||
if command == "config" {
|
||||
if len(args) > 1 {
|
||||
config.Host = args[1]
|
||||
SaveConfig(config)
|
||||
if len(args) > 0 {
|
||||
config.Host = args[0]
|
||||
}
|
||||
fmt.Printf("host: %s\taccount: %s\n", config.Host, config.Accounts[config.Host])
|
||||
return nil
|
||||
}
|
||||
|
||||
// Allow overriding the host
|
||||
hostOverride := os.Getenv("ROVE_HOST")
|
||||
if len(hostOverride) > 0 {
|
||||
config.Host = hostOverride
|
||||
return SaveConfig(config)
|
||||
}
|
||||
|
||||
// If there's still no host, bail
|
||||
if len(config.Host) == 0 {
|
||||
return fmt.Errorf("no host set, set one with '%s config {HOST}'", os.Args[0])
|
||||
return fmt.Errorf("no host set in %s, set one with '%s config {HOST}'", ConfigPath(), os.Args[0])
|
||||
}
|
||||
|
||||
// Set up the server
|
||||
|
@ -278,8 +270,7 @@ func InnerMain(command string, args ...string) error {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
SaveConfig(config)
|
||||
return nil
|
||||
return SaveConfig(config)
|
||||
}
|
||||
|
||||
// Simple main
|
||||
|
@ -291,7 +282,7 @@ func main() {
|
|||
}
|
||||
|
||||
// Run the inner main
|
||||
if err := InnerMain(os.Args[1], os.Args[1:]...); err != nil {
|
||||
if err := InnerMain(os.Args[1], os.Args[2:]...); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
func Test_InnerMain(t *testing.T) {
|
||||
|
||||
// Use temporary local user data
|
||||
tmp, err := ioutil.TempDir(os.TempDir(), "rove-*")
|
||||
tmp, err := ioutil.TempDir(os.TempDir(), "rove-")
|
||||
assert.NoError(t, err)
|
||||
os.Setenv("USER_DATA", tmp)
|
||||
|
||||
|
@ -25,14 +25,9 @@ func Test_InnerMain(t *testing.T) {
|
|||
log.Fatal("Must set $ROVE_GRPC")
|
||||
}
|
||||
|
||||
// First attempt should error
|
||||
// First attempt should error without a host
|
||||
assert.Error(t, InnerMain("status"))
|
||||
|
||||
// Then set the host
|
||||
// No error now as we have a host
|
||||
os.Setenv("ROVE_HOST", address)
|
||||
assert.NoError(t, InnerMain("status"))
|
||||
|
||||
// Set the host in the config
|
||||
assert.NoError(t, InnerMain("config", address))
|
||||
assert.NoError(t, InnerMain("status"))
|
||||
|
|
Loading…
Add table
Reference in a new issue