public void SingleAppendEnv() { var logger = new TestToolLogger(); var assembly = this.GetType().GetTypeInfo().Assembly; var fullPath = Path.GetFullPath(Path.GetDirectoryName(assembly.Location) + "../../../../../../testapps/TestServerlessWebApp"); var command = new UpdateFunctionConfigCommand(logger, fullPath, new string[0]); command.EnvironmentVariables = null; command.AppendEnvironmentVariables = new Dictionary <string, string> { { "foo", "bar" } }; var combinedEnv = command.GetEnvironmentVariables(null); Assert.Single(combinedEnv); Assert.Equal("bar", combinedEnv["foo"]); }
public void CombinedEnvAndAppendEnvIgnoreExisting() { var logger = new TestToolLogger(); var assembly = this.GetType().GetTypeInfo().Assembly; var fullPath = Path.GetFullPath(Path.GetDirectoryName(assembly.Location) + "../../../../../../testapps/TestServerlessWebApp"); var command = new UpdateFunctionConfigCommand(logger, fullPath, new string[0]); command.EnvironmentVariables = new Dictionary <string, string> { { "service", "s3" } }; command.AppendEnvironmentVariables = new Dictionary <string, string> { { "foo", "bar" } }; var combinedEnv = command.GetEnvironmentVariables(new Dictionary <string, string> { { "service", "lambda" } }); Assert.Equal(2, combinedEnv.Count); Assert.Equal("bar", combinedEnv["foo"]); Assert.Equal("s3", combinedEnv["service"]); }
public static void Main(string[] args) { try { if (args.Length == 0) { PrintUsage(); Environment.Exit(-1); } ICommand command = null; switch (args[0]) { case DeployFunctionCommand.COMMAND_DEPLOY_NAME: command = new DeployFunctionCommand(new ConsoleToolLogger(), Directory.GetCurrentDirectory(), args.Skip(1).ToArray()); break; case InvokeFunctionCommand.COMMAND_NAME: command = new InvokeFunctionCommand(new ConsoleToolLogger(), Directory.GetCurrentDirectory(), args.Skip(1).ToArray()); break; case ListFunctionCommand.COMMAND_NAME: command = new ListFunctionCommand(new ConsoleToolLogger(), Directory.GetCurrentDirectory(), args.Skip(1).ToArray()); break; case DeleteFunctionCommand.COMMAND_NAME: command = new DeleteFunctionCommand(new ConsoleToolLogger(), Directory.GetCurrentDirectory(), args.Skip(1).ToArray()); break; case GetFunctionConfigCommand.COMMAND_NAME: command = new GetFunctionConfigCommand(new ConsoleToolLogger(), Directory.GetCurrentDirectory(), args.Skip(1).ToArray()); break; case UpdateFunctionConfigCommand.COMMAND_NAME: command = new UpdateFunctionConfigCommand(new ConsoleToolLogger(), Directory.GetCurrentDirectory(), args.Skip(1).ToArray()); break; case DeployServerlessCommand.COMMAND_NAME: command = new DeployServerlessCommand(new ConsoleToolLogger(), Directory.GetCurrentDirectory(), args.Skip(1).ToArray()); break; case ListServerlessCommand.COMMAND_NAME: command = new ListServerlessCommand(new ConsoleToolLogger(), Directory.GetCurrentDirectory(), args.Skip(1).ToArray()); break; case DeleteServerlessCommand.COMMAND_NAME: command = new DeleteServerlessCommand(new ConsoleToolLogger(), Directory.GetCurrentDirectory(), args.Skip(1).ToArray()); break; case PackageCommand.COMMAND_NAME: command = new PackageCommand(new ConsoleToolLogger(), Directory.GetCurrentDirectory(), args.Skip(1).ToArray()); break; case "--help": case "--h": case "help": PrintUsageHeader(); if (args.Length > 1) { PrintUsage(args[1]); } else { PrintUsage(); } break; default: Console.Error.WriteLine($"Unknown command {args[0]}"); PrintUsage(); Environment.Exit(-1); break; } if (command != null) { command.EnableInteractive = true; var success = command.ExecuteAsync().Result; if (!success) { Environment.Exit(-1); } } } catch (LambdaToolsException e) { Console.Error.WriteLine(e.Message); Environment.Exit(-1); } catch (Exception e) { Console.Error.WriteLine($"Unknown error: {e.Message}"); Console.Error.WriteLine(e.StackTrace); Environment.Exit(-1); } }