Skip to content

Commit

Permalink
Allow gateway override for invoke/list commands
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis <[email protected]>
  • Loading branch information
alexellis committed Oct 26, 2017
1 parent 93b510d commit baa728f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 5 additions & 3 deletions commands/invoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func runInvoke(cmd *cobra.Command, args []string) {
fmt.Println("Please provide a name for the function")
return
}

var yamlGateway string
functionName = args[0]

if len(yamlFile) > 0 {
Expand All @@ -59,10 +59,12 @@ func runInvoke(cmd *cobra.Command, args []string) {

if parsedServices != nil {
services = *parsedServices
gateway = services.Provider.GatewayURL
yamlGateway = services.Provider.GatewayURL
}
}

gatewayAddress := getGatewayURL(gateway, defaultGateway, yamlGateway)

stat, _ := os.Stdin.Stat()
if (stat.Mode() & os.ModeCharDevice) != 0 {
fmt.Fprintf(os.Stderr, "Reading from STDIN - hit (Control + D) to stop.\n")
Expand All @@ -74,7 +76,7 @@ func runInvoke(cmd *cobra.Command, args []string) {
return
}

response, err := proxy.InvokeFunction(gateway, functionName, &functionInput, contentType, query)
response, err := proxy.InvokeFunction(gatewayAddress, functionName, &functionInput, contentType, query)
if err != nil {
fmt.Println(err)
return
Expand Down
9 changes: 4 additions & 5 deletions commands/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var listCmd = &cobra.Command{
func runList(cmd *cobra.Command, args []string) {
var services stack.Services
var gatewayAddress string

var yamlGateway string
if len(yamlFile) > 0 {
parsedServices, err := stack.ParseYAMLFile(yamlFile, regex, filter)
if err != nil {
Expand All @@ -48,12 +48,11 @@ func runList(cmd *cobra.Command, args []string) {

if parsedServices != nil {
services = *parsedServices
gatewayAddress = services.Provider.GatewayURL
yamlGateway = services.Provider.GatewayURL
}
}
if len(gatewayAddress) == 0 {
gatewayAddress = gateway
}

gatewayAddress = getGatewayURL(gateway, defaultGateway, yamlGateway)

// fmt.Println(gatewayAddress)
functions, err := proxy.ListFunctions(gatewayAddress)
Expand Down

0 comments on commit baa728f

Please sign in to comment.