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, "\tversion outputs version info")
|
||||||
fmt.Fprintln(os.Stderr, "\nEnvironment")
|
fmt.Fprintln(os.Stderr, "\nEnvironment")
|
||||||
fmt.Fprintln(os.Stderr, "\tUSER_DATA path to user data, defaults to "+defaultDataPath)
|
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
|
const gRPCport = 9090
|
||||||
|
@ -130,23 +129,16 @@ func InnerMain(command string, args ...string) error {
|
||||||
|
|
||||||
// Run config command before server needed
|
// Run config command before server needed
|
||||||
if command == "config" {
|
if command == "config" {
|
||||||
if len(args) > 1 {
|
if len(args) > 0 {
|
||||||
config.Host = args[1]
|
config.Host = args[0]
|
||||||
SaveConfig(config)
|
|
||||||
}
|
}
|
||||||
fmt.Printf("host: %s\taccount: %s\n", config.Host, config.Accounts[config.Host])
|
fmt.Printf("host: %s\taccount: %s\n", config.Host, config.Accounts[config.Host])
|
||||||
return nil
|
return SaveConfig(config)
|
||||||
}
|
|
||||||
|
|
||||||
// Allow overriding the host
|
|
||||||
hostOverride := os.Getenv("ROVE_HOST")
|
|
||||||
if len(hostOverride) > 0 {
|
|
||||||
config.Host = hostOverride
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there's still no host, bail
|
// If there's still no host, bail
|
||||||
if len(config.Host) == 0 {
|
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
|
// Set up the server
|
||||||
|
@ -278,8 +270,7 @@ func InnerMain(command string, args ...string) error {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveConfig(config)
|
return SaveConfig(config)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple main
|
// Simple main
|
||||||
|
@ -291,7 +282,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the inner 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)
|
fmt.Fprintf(os.Stderr, "Error: %s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
func Test_InnerMain(t *testing.T) {
|
func Test_InnerMain(t *testing.T) {
|
||||||
|
|
||||||
// Use temporary local user data
|
// Use temporary local user data
|
||||||
tmp, err := ioutil.TempDir(os.TempDir(), "rove-*")
|
tmp, err := ioutil.TempDir(os.TempDir(), "rove-")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
os.Setenv("USER_DATA", tmp)
|
os.Setenv("USER_DATA", tmp)
|
||||||
|
|
||||||
|
@ -25,14 +25,9 @@ func Test_InnerMain(t *testing.T) {
|
||||||
log.Fatal("Must set $ROVE_GRPC")
|
log.Fatal("Must set $ROVE_GRPC")
|
||||||
}
|
}
|
||||||
|
|
||||||
// First attempt should error
|
// First attempt should error without a host
|
||||||
assert.Error(t, InnerMain("status"))
|
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
|
// Set the host in the config
|
||||||
assert.NoError(t, InnerMain("config", address))
|
assert.NoError(t, InnerMain("config", address))
|
||||||
assert.NoError(t, InnerMain("status"))
|
assert.NoError(t, InnerMain("status"))
|
||||||
|
|
Loading…
Add table
Reference in a new issue