public FortunesController(IFortuneRepository fortunes, ILogger <FortunesController> logger, IOptions <CloudFoundryApplicationOptions> applicationOptions) { _fortunes = fortunes; _logger = logger; _applicationOptions = applicationOptions.Value; }
public CloudFoundryViewModel(CloudFoundryApplicationOptions appOptions, CloudFoundryServicesOptions servOptions, ConfigServerData configData, Dictionary <string, string> connectionStrings) { CloudFoundryServices = servOptions; CloudFoundryApplication = appOptions; ConfigData = configData; ConnectionStrings = connectionStrings; }
public ValuesController(IConfigurationRoot config, IOptionsSnapshot <ConfigServerData> configServerData, IOptions <CloudFoundryApplicationOptions> appOptions, IOptions <CloudFoundryServicesOptions> servOptions, IOptions <ConfigServerClientSettingsOptions> confgServerSettings) { // The ASP.NET DI mechanism injects the data retrieved from the // Spring Cloud Config Server as an IOptionsSnapshot<ConfigServerData> // since we added "services.Configure<ConfigServerData>(Configuration);" // in the StartUp class if (configServerData != null) { IConfigServerData = configServerData; } // The ASP.NET DI mechanism injects these as well, see // public void ConfigureServices(IServiceCollection services) in Startup class if (servOptions != null) { CloudFoundryServices = servOptions.Value; } if (appOptions != null) { CloudFoundryApplication = appOptions.Value; } // Inject the settings used in communicating with the Spring Cloud Config Server if (confgServerSettings != null) { ConfigServerClientSettingsOptions = confgServerSettings.Value; } Config = config; }
public FooService(ILoggerFactory loggerFactory, IOptions <CloudFoundryApplicationOptions> appInfo, IOptions <CloudFoundryServicesOptions> serviceInfo) { _logger = loggerFactory.CreateLogger <FooService>(); _appInfo = appInfo.Value; _serviceInfo = serviceInfo.Value; }
public SecretController( IOptions <CloudFoundryApplicationOptions> appOptions, IOptions <CloudFoundryServicesOptions> servOptions) { CloudFoundryServices = servOptions.Value; CloudFoundryApplication = appOptions.Value; }
private void BuildServiceInfos() { _serviceInfos.Clear(); CloudFoundryApplicationOptions appOpts = new CloudFoundryApplicationOptions(); _config.Bind(appOpts); ApplicationInstanceInfo appInfo = new ApplicationInstanceInfo(appOpts); CloudFoundryServicesOptions serviceOpts = new CloudFoundryServicesOptions(); _config.Bind(serviceOpts); foreach (Service s in serviceOpts.Services) { IServiceInfoFactory factory = FindFactory(s); if (factory != null) { var info = factory.Create(s) as ServiceInfo; if (info != null) { info.ApplicationInfo = appInfo; _serviceInfos.Add(info); } } } }
private void BuildServiceInfos() { _serviceInfos.Clear(); CloudFoundryApplicationOptions appOpts = new CloudFoundryApplicationOptions(); var aopSection = _config.GetSection(CloudFoundryApplicationOptions.CONFIGURATION_PREFIX); aopSection.Bind(appOpts); ApplicationInstanceInfo appInfo = new ApplicationInstanceInfo(appOpts); var serviceSection = _config.GetSection(CloudFoundryServicesOptions.CONFIGURATION_PREFIX); CloudFoundryServicesOptions serviceOpts = new CloudFoundryServicesOptions(); serviceSection.Bind(serviceOpts); foreach (KeyValuePair <string, Service[]> serviceopt in serviceOpts.Services) { foreach (Service s in serviceopt.Value) { IServiceInfoFactory factory = FindFactory(s); if (factory != null) { if (factory.Create(s) is ServiceInfo info) { info.ApplicationInfo = appInfo; _serviceInfos.Add(info); } } } } }
public static CloudFoundryApplicationOptions MakeCloudFoundryApplicationOptions() { CloudFoundryApplicationOptions opts = new CloudFoundryApplicationOptions() { Vcap = new Vcap() { Application = new Application() { Application_Id = "Application_Id", Application_Name = "Application_Name", Application_Uris = new string[] { "Application_Uris" }, Application_Version = "Application_Version", Instance_Id = "Instance_Id", Instance_Index = "Instance_Index", Limits = new Limits() { Disk = "1", Fds = "1", Mem = "1" }, Name = "Name", Port = "Port", Space_Id = "Space_Id", Space_Name = "Space_Name", Start = "Start", Uris = new string[] { "uris" }, Version = "Version", } } }; return(opts); }
internal string GetApplicationName(string defaultName, IConfiguration config) { var section = config.GetSection(CloudFoundryApplicationOptions.CONFIGURATION_PREFIX); if (section != null) { CloudFoundryApplicationOptions appOptions = new CloudFoundryApplicationOptions(section); if (!string.IsNullOrEmpty(appOptions.Name)) { return(appOptions.Name); } } section = config.GetSection(SPRING_APPLICATION_PREFIX); if (section != null) { var name = section["name"]; if (!string.IsNullOrEmpty(name)) { return(name); } } if (!string.IsNullOrEmpty(defaultName)) { return(defaultName); } return("Unknown"); }
public EurekaController( IOptions <CloudFoundryApplicationOptions> appOptions, IEurekaService eurekaService) { this.appOptions = appOptions.Value; this.eurekaService = eurekaService; }
public static CloudFoundryApplicationOptions MakeCloudFoundryApplicationOptions() { CloudFoundryApplicationOptions opts = new CloudFoundryApplicationOptions() { Application_Id = "Application_Id", Application_Name = "Application_Name", Application_Uris = new string[] { "Application_Uris" }, Application_Version = "Application_Version", Instance_Id = "Instance_Id", Limits = new Limits() { Disk = 1, Fds = 1, Mem = 1 }, Name = "Name", Space_Id = "Space_Id", Space_Name = "Space_Name", Start = "Start", Uris = new string[] { "uris" }, Version = "Version", }; return(opts); }
public OptionsController( IOptions <CloudFoundryApplicationOptions> appOptions, IOptions <CloudFoundryServicesOptions> serviceOptions) { this.appOptions = appOptions.Value; this.serviceOptions = serviceOptions.Value; }
private string GetInstanceId(CloudFoundryApplicationOptions opts) { if (!string.IsNullOrEmpty(opts.InstanceId)) { return(opts.InstanceId); } return(Environment.GetEnvironmentVariable("CF_INSTANCE_GUID")); }
public HomeController( IOptions <CloudFoundryApplicationOptions> appOptions, IOptions <CloudFoundryServicesOptions> serviceOptions, DemoContext context) { CloudFoundryServices = serviceOptions.Value; CloudFoundryApplication = appOptions.Value; _context = context; }
public OptionsController( IOptions <CloudFoundryApplicationOptions> appOptions, IOptions <CloudFoundryServicesOptions> serviceOptions, IOptionsSnapshot <CupsOptions> cupsOptions) { this.appOptions = appOptions.Value; this.serviceOptions = serviceOptions.Value; this.cupsOptions = cupsOptions.Get("tas-cups-database"); }
public ServicesViewModel(CloudFoundryApplicationOptions appOptions, CloudFoundryServicesOptions servOptions, ConfigServerData configData, IDiscoveryClient client, SortedList <int, int> appCounts, SortedList <int, int> srvCounts, List <string> fortunes) { CloudFoundryServices = servOptions; CloudFoundryApplication = appOptions; ConfigData = configData; discoveryClient = client; ServiceInstanceCounts = srvCounts; FortuneHistory = fortunes; AppInstanceCounts = appCounts; }
public FortunesController(ILogger <FortunesController> logger, IFortuneRepository fortunes, IOptions <CloudFoundryApplicationOptions> appOptions, IOptions <CloudFoundryServicesOptions> servOptions) { _logger = logger; _fortunes = fortunes; CloudFoundryServices = servOptions.Value; CloudFoundryApplication = appOptions.Value; }
public PaymentController(PaymentCalculator paymentCalculator, IOptions <CloudFoundryApplicationOptions> appOptions, IHitCountService hitCountService, ILogger <PaymentController> logger) { PaymentCalculator = paymentCalculator; AppOptions = appOptions.Value; HitCountService = hitCountService; _logger = logger; }
public CredhubController( ILogger <CredhubController> logger, IConfiguration configuration, IOptions <CloudFoundryApplicationOptions> appOptions, IOptions <CloudFoundryServicesOptions> serviceOptions) { _logger = logger; _configuration = configuration; _appOptions = appOptions.Value; _serviceOptions = serviceOptions.Value; }
public LoanApplicationController(IOptions <CloudFoundryApplicationOptions> appOptions, IOptions <CloudFoundryServicesOptions> serviceOptions, ILogger <LoanApplicationController> logger, Models.ILoanApplicationRepository loans, Services.ILoanCheckerService loanCheckerService, IHostingEnvironment env) { _appOptions = appOptions.Value; _serviceOptions = serviceOptions.Value; _logger = logger; _loans = loans; _loanCheckerservice = loanCheckerService; _env = env; }
internal ApplicationInstanceInfo(CloudFoundryApplicationOptions opts) { InstanceId = GetInstanceId(opts); ApplicationId = opts.ApplicationId; ApplicationName = opts.ApplicationName; ApplicationUris = opts.ApplicationUris; ApplicationVersion = opts.ApplicationVersion; InstanceIndex = opts.InstanceIndex; Port = opts.Port; SpaceId = opts.SpaceId; SpaceName = opts.SpaceName; Uris = opts.Uris; Version = opts.Version; DiskLimit = opts.DiskLimit; MemoryLimit = opts.MemoryLimit; FileDescriptorLimit = opts.FileDescriptorLimit; }
public ValuesController() { _appOptions = ApplicationConfig.CloudFoundryApplication; _serviceOptions = ApplicationConfig.CloudFoundryServices; _logger = LoggingConfig.LoggerFactory.CreateLogger <ValuesController>(); _logger.LogInformation("Hi there, this is a {LogLevel} log", LogLevel.Information.ToString()); /* * _logger.LogTrace("This is a {LogLevel} log", LogLevel.Trace.ToString()); * _logger.LogDebug("This is a {LogLevel} log", LogLevel.Debug.ToString()); * _logger.LogInformation("This is a {LogLevel} log", LogLevel.Information.ToString()); * _logger.LogWarning("This is a {LogLevel} log", LogLevel.Warning.ToString()); * _logger.LogError("This is a {LogLevel} log", LogLevel.Error.ToString()); * _logger.LogCritical("This is a {LogLevel} log", LogLevel.Critical.ToString()); */ }
public ValuesController(IOptions <CloudFoundryApplicationOptions> appOptions, IOptions <CloudFoundryServicesOptions> serviceOptions, ILogger <ValuesController> logger) { _appOptions = appOptions.Value; _serviceOptions = serviceOptions.Value; _logger = logger; _logger.LogInformation("Hi There"); /* * _logger.LogCritical("Test Critical message"); * _logger.LogError("Test Error message"); * _logger.LogWarning("Test Warning message"); * _logger.LogInformation("Test Informational message"); * _logger.LogDebug("Test Debug message"); * _logger.LogTrace("Test Trace message"); */ }
public void Constructor_WithNoVcapApplicationConfiguration() { var builder = new ConfigurationBuilder(); var config = builder.Build(); var options = new CloudFoundryApplicationOptions(); var appSection = config.GetSection(CloudFoundryApplicationOptions.CONFIGURATION_PREFIX); appSection.Bind(options); Assert.Null(options.CF_Api); Assert.Null(options.ApplicationId); Assert.Null(options.Application_Id); Assert.Null(options.ApplicationName); Assert.Null(options.Application_Name); Assert.Null(options.ApplicationUris); Assert.Null(options.Application_Uris); Assert.Null(options.ApplicationVersion); Assert.Null(options.Application_Version); Assert.Null(options.InstanceId); Assert.Null(options.Instance_Id); Assert.Equal(-1, options.InstanceIndex); Assert.Equal(-1, options.Instance_Index); Assert.Null(options.Limits); Assert.Null(options.Name); Assert.Null(options.SpaceId); Assert.Null(options.Space_Id); Assert.Null(options.SpaceName); Assert.Null(options.Space_Name); Assert.Null(options.Start); Assert.Null(options.Uris); Assert.Null(options.Version); Assert.Null(options.Instance_IP); Assert.Null(options.InstanceIP); Assert.Null(options.Internal_IP); Assert.Null(options.InternalIP); Assert.Equal(-1, options.DiskLimit); Assert.Equal(-1, options.FileDescriptorLimit); Assert.Equal(-1, options.InstanceIndex); Assert.Equal(-1, options.MemoryLimit); Assert.Equal(-1, options.Port); }
private void BuildServiceInfos() { ServiceInfos.Clear(); var appInfo = new CloudFoundryApplicationOptions(_config); var serviceOpts = new CloudFoundryServicesOptions(_config); foreach (var serviceopt in serviceOpts.Services) { foreach (var s in serviceopt.Value) { var factory = FindFactory(s); if (factory != null && factory.Create(s) is ServiceInfo info) { info.ApplicationInfo = appInfo; ServiceInfos.Add(info); } } } }
public void Constructor_BuildsExpectedFromOpts() { CloudFoundryApplicationOptions opts = MakeCloudFoundryApplicationOptions(); ApplicationInstanceInfo info = new ApplicationInstanceInfo(opts); Assert.Equal(opts.ApplicationId, info.ApplicationId); Assert.Equal(opts.ApplicationName, info.ApplicationName); Assert.Equal(opts.ApplicationUris[0], info.ApplicationUris[0]); Assert.Equal(opts.ApplicationVersion, info.ApplicationVersion); Assert.Equal(opts.DiskLimit, info.DiskLimit); Assert.Equal(opts.FileDescriptorLimit, info.FileDescriptorLimit); Assert.Equal(opts.InstanceId, info.InstanceId); Assert.Equal(opts.InstanceIndex, info.InstanceIndex); Assert.Equal(opts.MemoryLimit, info.MemoryLimit); Assert.Equal(opts.Port, info.Port); Assert.Equal(opts.SpaceId, info.SpaceId); Assert.Equal(opts.SpaceName, info.SpaceName); Assert.Equal(opts.Uris[0], info.Uris[0]); Assert.Equal(opts.Version, info.Version); }
public CloudFoundryForwarderOptions(IConfiguration config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } var section = config.GetSection(CONFIG_PREFIX); if (section != null) { section.Bind(this); } section = config.GetSection(CloudFoundryApplicationOptions.CONFIGURATION_PREFIX); if (section != null) { CloudFoundryApplicationOptions appOptions = new CloudFoundryApplicationOptions(section); if (string.IsNullOrEmpty(ApplicationId)) { ApplicationId = appOptions.ApplicationId; } if (string.IsNullOrEmpty(InstanceId)) { InstanceId = appOptions.InstanceId; } if (string.IsNullOrEmpty(InstanceIndex)) { InstanceIndex = appOptions.InstanceIndex.ToString(); } } section = config.GetSection(CloudFoundryServicesOptions.CONFIGURATION_PREFIX); if (section != null) { CloudFoundryServicesOptions servOptions = new CloudFoundryServicesOptions(section); if (servOptions.Services.TryGetValue(FORWARDER_NAME, out Service[] services))
public ActionResult Index() { CloudFoundryApplicationOptions applicationOptions = ProviderConfig.ApplicationOptions; CloudFoundryServicesOptions servicesOptions = ProviderConfig.ServicesOptions; ViewData["ApplicationName"] = applicationOptions.ApplicationName; ViewData["ApplicationUris"] = applicationOptions.ApplicationUris == null ? "" : String.Join(", ", applicationOptions.ApplicationUris); ViewData["InstanceIndex"] = applicationOptions.InstanceIndex; ViewData["InstanceId"] = applicationOptions.InstanceId; string serviceList = ""; foreach (var service in servicesOptions.Services) { if (serviceList.Length > 0) { serviceList += ", "; } serviceList += service.Name; } ViewData["BoundServices"] = serviceList; return(View()); }
public CloudFoundryViewModel(CloudFoundryApplicationOptions appOptions, CloudFoundryServicesOptions servOptions) { CloudFoundryServices = servOptions; CloudFoundryApplication = appOptions; }
public void Constructor_WithVcapApplicationConfiguration() { // Arrange var configJson = @" { ""vcap"": { ""application"" : { ""cf_api"": ""https://api.system.testcloud.com"", ""application_id"": ""fa05c1a9-0fc1-4fbd-bae1-139850dec7a3"", ""application_name"": ""my-app"", ""application_uris"": [ ""my-app.10.244.0.34.xip.io"" ], ""application_version"": ""fb8fbcc6-8d58-479e-bcc7-3b4ce5a7f0ca"", ""limits"": { ""disk"": 1024, ""fds"": 16384, ""mem"": 256 }, ""name"": ""my-app"", ""space_id"": ""06450c72-4669-4dc6-8096-45f9777db68a"", ""space_name"": ""my-space"", ""uris"": [ ""my-app.10.244.0.34.xip.io"", ""my-app2.10.244.0.34.xip.io"" ], ""users"": null, ""version"": ""fb8fbcc6-8d58-479e-bcc7-3b4ce5a7f0ca"" } } }"; var memStream = CloudFoundryConfigurationProvider.GetMemoryStream(configJson); var jsonSource = new JsonStreamConfigurationSource(memStream); var builder = new ConfigurationBuilder().Add(jsonSource); var config = builder.Build(); var options = new CloudFoundryApplicationOptions(config); Assert.Equal("https://api.system.testcloud.com", options.CF_Api); Assert.Equal("fa05c1a9-0fc1-4fbd-bae1-139850dec7a3", options.ApplicationId); Assert.Equal("my-app", options.ApplicationName); Assert.NotNull(options.ApplicationUris); Assert.NotNull(options.Application_Uris); Assert.Single(options.ApplicationUris); Assert.Single(options.Application_Uris); Assert.Equal("my-app.10.244.0.34.xip.io", options.ApplicationUris.First()); Assert.Equal("my-app.10.244.0.34.xip.io", options.Application_Uris.First()); Assert.Equal("fb8fbcc6-8d58-479e-bcc7-3b4ce5a7f0ca", options.ApplicationVersion); Assert.Equal("my-app", options.Name); Assert.Equal("06450c72-4669-4dc6-8096-45f9777db68a", options.SpaceId); Assert.Equal("06450c72-4669-4dc6-8096-45f9777db68a", options.Space_Id); Assert.Equal("my-space", options.SpaceName); Assert.Equal("my-space", options.Space_Name); Assert.NotNull(options.Uris); Assert.Equal(2, options.Uris.Count()); Assert.Contains("my-app.10.244.0.34.xip.io", options.Uris); Assert.Contains("my-app2.10.244.0.34.xip.io", options.Uris); Assert.Equal("fb8fbcc6-8d58-479e-bcc7-3b4ce5a7f0ca", options.Version); }