public AzureDnsOptions(IOptionsService options) { TenantId = options.TryGetRequiredOption(nameof(options.Options.AzureTenantId), options.Options.AzureTenantId); ClientId = options.TryGetRequiredOption(nameof(options.Options.AzureTenantId), options.Options.AzureClientId); Secret = options.TryGetRequiredOption(nameof(options.Options.AzureTenantId), options.Options.AzureSecret); SubscriptionId = options.TryGetRequiredOption(nameof(options.Options.AzureTenantId), options.Options.AzureSubscriptionId); ResourceGroupName = options.TryGetRequiredOption(nameof(options.Options.AzureTenantId), options.Options.AzureResourceGroupName); }
public DnsScriptOptions(IOptionsService options, ILogService log) { CreateScript = options.TryGetRequiredOption(nameof(options.Options.DnsCreateScript), options.Options.DnsCreateScript); if (!CreateScript.ValidFile(log)) { throw new ArgumentException(nameof(options.Options.DnsCreateScript)); } DeleteScript = options.TryGetRequiredOption(nameof(options.Options.DnsDeleteScript), options.Options.DnsDeleteScript); if (!DeleteScript.ValidFile(log)) { throw new ArgumentException(nameof(options.Options.DnsDeleteScript)); } }
public override AzureOptions Default(Target target, IOptionsService options) { var az = options.GetArguments <AzureArguments>(); return(new AzureOptions() { TenantId = options.TryGetRequiredOption(nameof(az.AzureTenantId), az.AzureTenantId), ClientId = options.TryGetRequiredOption(nameof(az.AzureTenantId), az.AzureClientId), Secret = options.TryGetRequiredOption(nameof(az.AzureTenantId), az.AzureSecret), SubscriptionId = options.TryGetRequiredOption(nameof(az.AzureTenantId), az.AzureSubscriptionId), ResourceGroupName = options.TryGetRequiredOption(nameof(az.AzureTenantId), az.AzureResourceGroupName) }); }
/// <summary> /// Remove renewal from the list of scheduled items /// </summary> private void CancelRenewal(RunLevel runLevel) { if (runLevel.HasFlag(RunLevel.Unattended)) { var friendlyName = _optionsService.TryGetRequiredOption(nameof(MainArguments.FriendlyName), _arguments.FriendlyName); foreach (var r in _renewalService.FindByFriendlyName(friendlyName)) { _renewalService.Cancel(r); } } else { var renewal = _input.ChooseFromList("Which renewal would you like to cancel?", _renewalService.Renewals.OrderBy(x => x.Date), x => Choice.Create(x), true); if (renewal != null) { if (_input.PromptYesNo($"Are you sure you want to cancel the renewal for {renewal}")) { _renewalService.Cancel(renewal); } } } }
public override IISBindingOptions Default(IOptionsService optionsService) { var ret = new IISBindingOptions(); var args = optionsService.GetArguments <IISBindingArguments>(); var hostName = optionsService.TryGetRequiredOption(nameof(args.Host), args.Host).ToLower(); var rawSiteId = args.SiteId; var filterSet = _helper.GetBindings(false, false); if (!string.IsNullOrEmpty(rawSiteId)) { if (long.TryParse(rawSiteId, out long siteId)) { filterSet = filterSet.Where(x => x.SiteId == siteId).ToList(); } else { _log.Error("Invalid SiteId {siteId}", rawSiteId); return(null); } } var chosenTarget = filterSet.Where(x => x.HostUnicode == hostName || x.HostPunycode == hostName).FirstOrDefault(); if (chosenTarget != null) { ret.SiteId = chosenTarget.SiteId; ret.Host = chosenTarget.HostUnicode; ret.FriendlyNameSuggestion = chosenTarget.HostUnicode; return(ret); } else { return(null); } }
public override IISSitesOptions Default(IOptionsService optionsService) { var ret = new IISSitesOptions(); var args = optionsService.GetArguments <IISSiteArguments>(); var sites = _helper.GetSites(false, false); var rawSiteIds = optionsService.TryGetRequiredOption(nameof(args.SiteId), args.SiteId); sites = ProcessSiteIds(ret, sites, rawSiteIds); if (sites == null) { return(null); } ret.ExcludeBindings = args.ExcludeBindings.ParseCsv(); if (ret.ExcludeBindings != null) { ret.ExcludeBindings = ret.ExcludeBindings.Select(x => x.ConvertPunycode()).ToList(); } var commonName = args.CommonName; if (!string.IsNullOrWhiteSpace(commonName)) { commonName = commonName.ToLower().Trim().ConvertPunycode(); if (sites.Any(s => s.Hosts.Contains(commonName)) && (ret.ExcludeBindings == null || !ret.ExcludeBindings.Contains(commonName))) { ret.CommonName = commonName; } else { _log.Error("Common name {commonName} not found or excluded", commonName); return(null); } } return(ret); }
Target ITargetPlugin.Default(IOptionsService optionsService) { var rawSiteId = optionsService.TryGetRequiredOption(nameof(optionsService.Options.SiteId), optionsService.Options.SiteId); long siteId = 0; if (long.TryParse(rawSiteId, out siteId)) { var found = GetSites(false, false).FirstOrDefault(binding => binding.TargetSiteId == siteId); if (found != null) { found.ExcludeBindings = optionsService.Options.ExcludeBindings; found.CommonName = optionsService.Options.CommonName; if (!found.IsCommonNameValid(_log)) { return(null); } return(found); } else { _log.Error("Unable to find SiteId {siteId}", siteId); } } else { _log.Error("Invalid SiteId {siteId}", optionsService.Options.SiteId); } return(null); }
Target ITargetPlugin.Default(IOptionsService optionsService) { var rawSiteId = optionsService.TryGetRequiredOption(nameof(optionsService.Options.SiteId), optionsService.Options.SiteId); var totalTarget = GetCombinedTarget(GetSites(false, false), rawSiteId); totalTarget.ExcludeBindings = optionsService.Options.ExcludeBindings; return(totalTarget); }
public override DreamhostOptions Default(Target target, IOptionsService options) { var az = options.GetArguments <DreamhostArguments>(); return(new DreamhostOptions() { ApiKey = options.TryGetRequiredOption(nameof(az.ApiKey), az.ApiKey), }); }
public override void Default(ScheduledRenewal renewal, IOptionsService optionsService) { renewal.Script = optionsService.TryGetRequiredOption(nameof(optionsService.Options.Script), optionsService.Options.Script); if (!renewal.Script.ValidFile(_log)) { throw new ArgumentException(nameof(optionsService.Options.Script)); } renewal.ScriptParameters = optionsService.Options.ScriptParameters; }
public override ScriptOptions Default(Target target, IOptionsService options) { var args = options.GetArguments <ScriptArguments>(); var ret = new ScriptOptions { CreateScript = options.TryGetRequiredOption(nameof(args.DnsCreateScript), args.DnsCreateScript), DeleteScript = options.TryGetRequiredOption(nameof(args.DnsDeleteScript), args.DnsDeleteScript) }; if (!ret.CreateScript.ValidFile(_log)) { throw new ArgumentException(nameof(args.DnsCreateScript)); } if (!ret.DeleteScript.ValidFile(_log)) { throw new ArgumentException(nameof(args.DnsDeleteScript)); } return(ret); }
Target ITargetPlugin.Default(IOptionsService optionsService) { var input = optionsService.TryGetRequiredOption(nameof(optionsService.Options.ManualHost), optionsService.Options.ManualHost); var target = Create(input); target.CommonName = optionsService.Options.CommonName; if (!target.IsCommonNameValid(_log)) { return(null); } return(target); }
Target ITargetPlugin.Default(IOptionsService optionsService) { var rawSiteId = optionsService.TryGetRequiredOption(nameof(optionsService.Options.SiteId), optionsService.Options.SiteId); var totalTarget = GetCombinedTarget(GetSites(false, false), rawSiteId); totalTarget.ExcludeBindings = optionsService.Options.ExcludeBindings; totalTarget.CommonName = optionsService.Options.CommonName; if (!totalTarget.IsCommonNameValid(_log)) { return(null); } return(totalTarget); }
public override ScriptOptions Default(Target target, IOptionsService optionsService) { var args = optionsService.GetArguments <ScriptArguments>(); var ret = new ScriptOptions { Script = optionsService.TryGetRequiredOption(nameof(args.Script), args.Script) }; if (!ret.Script.ValidFile(_log)) { throw new ArgumentException(nameof(args.Script)); } ret.ScriptParameters = args.ScriptParameters; return(ret); }
/// <summary> /// Check information need for validation (unattended) /// </summary> /// <param name="target"></param> public override void Default(Target target, IOptionsService optionsService) { if (target.IIS == null) { target.IIS = optionsService.Options.ManualTargetIsIIS; } if (string.IsNullOrEmpty(target.WebRootPath)) { target.WebRootPath = optionsService.TryGetRequiredOption(nameof(optionsService.Options.WebRoot), optionsService.Options.WebRoot); } if (!ValidateWebroot(target)) { throw new ArgumentException($"Invalid --webroot {target.WebRootPath}: {WebrootHint()[0]}"); } }
Target ITargetPlugin.Default(IOptionsService optionsService) { var hostName = optionsService.TryGetRequiredOption(nameof(optionsService.Options.ManualHost), optionsService.Options.ManualHost); var rawSiteId = optionsService.Options.SiteId; long siteId = 0; var filterSet = GetBindings(false, false); if (long.TryParse(rawSiteId, out siteId)) { filterSet = filterSet.Where(x => x.TargetSiteId == siteId).ToList(); } return(filterSet. Where(x => x.Host == hostName). FirstOrDefault()); }
public override IISSiteOptions Default(IOptionsService optionsService) { var ret = new IISSiteOptions(); var args = optionsService.GetArguments <IISSiteArguments>(); var rawSiteId = optionsService.TryGetRequiredOption(nameof(args.SiteId), args.SiteId); if (long.TryParse(rawSiteId, out long siteId)) { var site = _helper.GetSites(false, false).FirstOrDefault(binding => binding.Id == siteId); if (site != null) { ret.SiteId = site.Id; ret.ExcludeBindings = args.ExcludeBindings.ParseCsv(); if (ret.ExcludeBindings != null) { ret.ExcludeBindings = ret.ExcludeBindings.Select(x => x.ConvertPunycode()).ToList(); } ret.FriendlyNameSuggestion = $"Site-{ret.SiteId}"; var commonName = args.CommonName; if (!string.IsNullOrWhiteSpace(commonName)) { commonName = commonName.ToLower().Trim().ConvertPunycode(); if (site.Hosts.Contains(commonName) && (ret.ExcludeBindings == null || !ret.ExcludeBindings.Contains(commonName))) { ret.CommonName = commonName; } else { _log.Error("Common name {commonName} not found or excluded", commonName); return(null); } } return(ret); } else { _log.Error("Unable to find SiteId {siteId}", siteId); } } else { _log.Error("Invalid SiteId {siteId}", args.SiteId); } return(null); }
public override ManualOptions Default(IOptionsService optionsService) { var args = optionsService.GetArguments <ManualArguments>(); var input = optionsService.TryGetRequiredOption(nameof(args.Host), args.Host); var ret = Create(input); var commonName = args.CommonName; if (!string.IsNullOrWhiteSpace(commonName)) { commonName = commonName.ToLower().Trim().ConvertPunycode(); ret.CommonName = commonName; if (!ret.AlternativeNames.Contains(commonName)) { ret.AlternativeNames.Insert(0, commonName); } } return(ret); }
public override CentralSslOptions Default(IOptionsService optionsService) { var args = optionsService.GetArguments <CentralSslArguments>(); var path = optionsService.TryGetRequiredOption(nameof(args.CentralSslStore), args.CentralSslStore); if (path.ValidPath(_log)) { return(new CentralSslOptions { Path = path, KeepExisting = args.KeepExisting, PfxPassword = args.PfxPassword }); } else { throw new Exception("Invalid path specified"); } }
/// <summary> /// Get webroot automatically /// </summary> public HttpValidationOptions <TPlugin> BaseDefault(Target target, IOptionsService options) { string path = null; var allowEmpty = AllowEmtpy(target); var args = options.GetArguments <HttpValidationArguments>(); if (string.IsNullOrEmpty(path) && !allowEmpty) { path = options.TryGetRequiredOption(nameof(args.WebRoot), args.WebRoot); } if (!string.IsNullOrEmpty(path) && !PathIsValid(path)) { throw new ArgumentException($"Invalid webroot {path}: {WebrootHint(false)[0]}"); } return(new TOptions { Path = path, CopyWebConfig = target.IIS || args.ManualTargetIsIIS }); }
Target ITargetPlugin.Default(IOptionsService optionsService) { var input = optionsService.TryGetRequiredOption(nameof(optionsService.Options.ManualHost), optionsService.Options.ManualHost); return(Create(input)); }
public NetworkCredentialOptions(IOptionsService options) { UserName = options.TryGetRequiredOption(nameof(options.Options.UserName), options.Options.UserName); Password = options.TryGetRequiredOption(nameof(options.Options.Password), options.Options.Password); }