/// <summary> /// Constructs a new instance of the InfoCollectionDialog class /// </summary> /// <param name="dialogId">dialog id</param> public UserInputDialog(PromptManager <TContext> promptManager) : base($"UserInput_{typeof(TContext).Name}") { // Set prompt Manager if (promptManager == null) { throw new ArgumentNullException(nameof(promptManager)); } this.promptManager = promptManager; // Add dialogs required by prompt this.AddDialog(new ConfirmPrompt(nameof(ConfirmPrompt))); this.promptManager.Dialogs.ToList().ForEach(p => this.AddDialog(p)); // Add waterfall dialog and steps for user input collection as well as confirm step and final step var waterfallSteps = new List <WaterfallStep>(); waterfallSteps.AddRange(this.promptManager.WaterfallSteps); waterfallSteps.Add(this.ConfirmStepAsync); waterfallSteps.Add(this.FinalStepAsync); this.AddDialog(new WaterfallDialog(nameof(WaterfallDialog), waterfallSteps)); // Set the initial child Dialog to run to be the waterfall dialog this.InitialDialogId = nameof(WaterfallDialog); }
// Constructor. public CommandSettings(IHostContext context, string[] args) { ArgUtil.NotNull(context, nameof(context)); _context = context; _promptManager = context.GetService <IPromptManager>(); _trace = context.GetTrace(nameof(CommandSettings)); // Parse the command line args. _parser = new CommandLineParser( hostContext: context, secretArgNames: Constants.Agent.CommandLine.Args.Secrets); _parser.Parse(args); }
// Constructor. public CommandSettings(IHostContext context, string[] args) { ArgUtil.NotNull(context, nameof(context)); _context = context; _promptManager = context.GetService<IPromptManager>(); _trace = context.GetTrace(nameof(CommandSettings)); // Parse the command line args. _parser = new CommandLineParser( hostContext: context, secretArgNames: Constants.Agent.CommandLine.Args.Secrets); _parser.Parse(args); }
// Constructor. public CommandSettings(IHostContext context, string[] args, IScopedEnvironment environmentScope = null) { ArgUtil.NotNull(context, nameof(context)); _promptManager = context.GetService <IPromptManager>(); _trace = context.GetTrace(nameof(CommandSettings)); // Parse the command line args. _parser = new CommandLineParser( hostContext: context, secretArgNames: Constants.Agent.CommandLine.Args.Secrets); _parser.Parse(args); if (environmentScope == null) { environmentScope = new SystemEnvironment(); } // Store and remove any args passed via environment variables. var environment = environmentScope.GetEnvironmentVariables(); string envPrefix = "VSTS_AGENT_INPUT_"; foreach (DictionaryEntry entry in environment) { // Test if starts with VSTS_AGENT_INPUT_. string fullKey = entry.Key as string ?? string.Empty; if (fullKey.StartsWith(envPrefix, StringComparison.OrdinalIgnoreCase)) { string val = (entry.Value as string ?? string.Empty).Trim(); if (!string.IsNullOrEmpty(val)) { // Extract the name. string name = fullKey.Substring(envPrefix.Length); // Mask secrets. bool secret = Constants.Agent.CommandLine.Args.Secrets.Any(x => string.Equals(x, name, StringComparison.OrdinalIgnoreCase)); if (secret) { context.SecretMasker.AddValue(val); } // Store the value. _envArgs[name] = val; } // Remove from the environment block. _trace.Info($"Removing env var: '{fullKey}'"); environmentScope.SetEnvironmentVariable(fullKey, null); } } }
// Constructor. public CommandSettings(IHostContext context, string[] args, IScopedEnvironment environmentScope = null) { ArgUtil.NotNull(context, nameof(context)); _promptManager = context.GetService <IPromptManager>(); _trace = context.GetTrace(nameof(CommandSettings)); ParseArguments(args); if (environmentScope == null) { environmentScope = new SystemEnvironment(); } // Mask secret arguments if (Configure != null) { context.SecretMasker.AddValue(Configure.Password, WellKnownSecretAliases.ConfigurePassword); context.SecretMasker.AddValue(Configure.ProxyPassword, WellKnownSecretAliases.ConfigureProxyPassword); context.SecretMasker.AddValue(Configure.SslClientCert, WellKnownSecretAliases.ConfigureSslClientCert); context.SecretMasker.AddValue(Configure.Token, WellKnownSecretAliases.ConfigureToken); context.SecretMasker.AddValue(Configure.WindowsLogonPassword, WellKnownSecretAliases.ConfigureWindowsLogonPassword); } if (Remove != null) { context.SecretMasker.AddValue(Remove.Password, WellKnownSecretAliases.RemovePassword); context.SecretMasker.AddValue(Remove.Token, WellKnownSecretAliases.RemoveToken); } PrintArguments(); // Store and remove any args passed via environment variables. var environment = environmentScope.GetEnvironmentVariables(); string envPrefix = "VSTS_AGENT_INPUT_"; foreach (DictionaryEntry entry in environment) { // Test if starts with VSTS_AGENT_INPUT_. string fullKey = entry.Key as string ?? string.Empty; if (fullKey.StartsWith(envPrefix, StringComparison.OrdinalIgnoreCase)) { string val = (entry.Value as string ?? string.Empty).Trim(); if (!string.IsNullOrEmpty(val)) { // Extract the name. string name = fullKey.Substring(envPrefix.Length); // Mask secrets. bool secret = Constants.Agent.CommandLine.Args.Secrets.Any(x => string.Equals(x, name, StringComparison.OrdinalIgnoreCase)); if (secret) { context.SecretMasker.AddValue(val, $"CommandSettings_{fullKey}"); } // Store the value. _envArgs[name] = val; } // Remove from the environment block. _trace.Info($"Removing env var: '{fullKey}'"); environmentScope.SetEnvironmentVariable(fullKey, null); } } }