Skip to content

Commit

Permalink
Allow to override the network name from CLI
Browse files Browse the repository at this point in the history
Signed-off-by: Minh-Quan TRAN <[email protected]>
  • Loading branch information
itscaro authored and alexellis committed Sep 15, 2017
1 parent e71ae41 commit a2c488e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion commands/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func init() {
deployCmd.Flags().StringVar(&image, "image", "", "Docker image name to build")
deployCmd.Flags().StringVar(&language, "lang", "node", "Programming language template")
deployCmd.Flags().StringVar(&functionName, "name", "", "Name of the deployed function")
deployCmd.Flags().StringVar(&network, "network", defaultNetwork, "Name of the network")

// Setup flags that are used only by this command (variables defined above)
deployCmd.Flags().StringArrayVarP(&envvarOpts, "env", "e", []string{}, "Set one or more environment variables (ENVVAR=VALUE)")
Expand All @@ -50,6 +51,7 @@ var deployCmd = &cobra.Command{
--name FUNCTION_NAME
[--lang <ruby|python|node|csharp>]
[--gateway GATEWAY_URL]
[--network NETWORK_NAME]
[--handler HANDLER_DIR]
[--fprocess PROCESS]
[--env ENVVAR=VALUE ...]
Expand Down Expand Up @@ -88,6 +90,11 @@ func runDeploy(cmd *cobra.Command, args []string) {
parsedServices.Provider.GatewayURL = gateway
}

// Override network if passed
if len(network) > 0 && network != defaultNetwork {
parsedServices.Provider.Network = network
}

if parsedServices != nil {
services = *parsedServices
}
Expand Down Expand Up @@ -123,7 +130,7 @@ func runDeploy(cmd *cobra.Command, args []string) {
os.Exit(1)
}

proxy.DeployFunction(fprocess, gateway, functionName, image, language, replace, envvars, defaultNetwork, constraints)
proxy.DeployFunction(fprocess, gateway, functionName, image, language, replace, envvars, network, constraints)
}
}

Expand Down
1 change: 1 addition & 0 deletions commands/faas.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var (
var (
fprocess string
functionName string
network string
gateway string
handler string
image string
Expand Down
2 changes: 1 addition & 1 deletion proxy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func DeployFunction(fprocess string, gateway string, functionName string, image
req := requests.CreateFunctionRequest{
EnvProcess: fprocessTemplate,
Image: image,
Network: "func_functions", // todo: specify network as an override
Network: network,
Service: functionName,
EnvVars: envVars,
Constraints: constraints,
Expand Down

0 comments on commit a2c488e

Please sign in to comment.