Skip to content

Commit

Permalink
Can now pass gateway var using environment (#70, #71)
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Jul 18, 2015
1 parent 0782d9f commit 99b210a
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions commands/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ func TarFromSource(apiClient *api.ScalewayAPI, source string) (*io.ReadCloser, e
remoteCommand = append(remoteCommand, base)

// Resolve gateway
if cpGateway == "" {
cpGateway = os.Getenv("SCW_GATEWAY")
}
var gateway string
if cpGateway == serverID || cpGateway == serverParts[0] {
gateway = ""
Expand Down Expand Up @@ -178,6 +181,9 @@ func UntarToDest(apiClient *api.ScalewayAPI, sourceStream *io.ReadCloser, destin
remoteCommand = append(remoteCommand, "-xf", "-")

// Resolve gateway
if cpGateway == "" {
cpGateway = os.Getenv("SCW_GATEWAY")
}
var gateway string
if cpGateway == serverID || cpGateway == serverParts[0] {
gateway = ""
Expand Down
3 changes: 3 additions & 0 deletions commands/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func runExec(cmd *types.Command, args []string) {
serverID := cmd.API.GetServerID(args[0])

// Resolve gateway
if execGateway == "" {
execGateway = os.Getenv("SCW_GATEWAY")
}
var gateway string
var err error
if execGateway == serverID || execGateway == args[0] {
Expand Down
3 changes: 3 additions & 0 deletions commands/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func runKill(cmd *types.Command, args []string) {
}

// Resolve gateway
if killGateway == "" {
killGateway = os.Getenv("SCW_GATEWAY")
}
var gateway string
if killGateway == serverID || killGateway == args[0] {
gateway = ""
Expand Down
5 changes: 5 additions & 0 deletions commands/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
package commands

import (
"os"

log "github.com/Sirupsen/logrus"

"github.com/scaleway/scaleway-cli/api"
Expand Down Expand Up @@ -45,6 +47,9 @@ func runLogs(cmd *types.Command, args []string) {
// FIXME: switch to serial history when API is ready

// Resolve gateway
if logsGateway == "" {
logsGateway = os.Getenv("SCW_GATEWAY")
}
var gateway string
if logsGateway == serverID || logsGateway == args[0] {
gateway = ""
Expand Down
5 changes: 5 additions & 0 deletions commands/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
package commands

import (
"os"

log "github.com/Sirupsen/logrus"

"github.com/scaleway/scaleway-cli/api"
Expand Down Expand Up @@ -43,6 +45,9 @@ func runPort(cmd *types.Command, args []string) {
}

// Resolve gateway
if portGateway == "" {
portGateway = os.Getenv("SCW_GATEWAY")
}
var gateway string
if portGateway == serverID || portGateway == args[0] {
gateway = ""
Expand Down
3 changes: 3 additions & 0 deletions commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ func runRun(cmd *types.Command, args []string) {
}
} else {
// Resolve gateway
if runGateway == "" {
runGateway = os.Getenv("SCW_GATEWAY")
}
gateway, err := api.ResolveGateway(cmd.API, runGateway)
if err != nil {
log.Fatalf("Cannot resolve Gateway '%s': %v", runGateway, err)
Expand Down
4 changes: 4 additions & 0 deletions commands/top.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package commands

import (
"fmt"
"os"
"os/exec"
"strings"

Expand Down Expand Up @@ -48,6 +49,9 @@ func runTop(cmd *types.Command, args []string) {
}

// Resolve gateway
if topGateway == "" {
topGateway = os.Getenv("SCW_GATEWAY")
}
var gateway string
if topGateway == serverID || topGateway == args[0] {
gateway = ""
Expand Down

0 comments on commit 99b210a

Please sign in to comment.