Placeholder data
This commit is contained in:
Родитель
3715d3b839
Коммит
61e1612060
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace {{ProjectNameSpace}}.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class PlaceholderDataController : ControllerBase
|
||||
{
|
||||
IOptionsMonitor<SampleOptions> _opts;
|
||||
|
||||
private SampleOptions Options
|
||||
{
|
||||
get
|
||||
{
|
||||
return _opts.CurrentValue;
|
||||
}
|
||||
}
|
||||
|
||||
public PlaceholderDataController(IOptionsMonitor<SampleOptions> opts)
|
||||
{
|
||||
_opts = opts;
|
||||
}
|
||||
|
||||
// GET api/values
|
||||
[HttpGet]
|
||||
public ActionResult<IDictionary<string, string>> Get()
|
||||
{
|
||||
return Ok(GetPlaceholderData());
|
||||
}
|
||||
|
||||
private IDictionary<string, string> GetPlaceholderData()
|
||||
{
|
||||
|
||||
var configData = new Dictionary<string, string>();
|
||||
configData["ResolvedPlaceholderFromEnvVariables"] = Options.ResolvedPlaceholderFromEnvVariables;
|
||||
configData["ResolvedPlaceholderFromJson"] = Options.ResolvedPlaceholderFromJson;
|
||||
configData["UnresolvedPlaceholder"] = Options.UnresolvedPlaceholder;
|
||||
return configData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,9 @@ using Steeltoe.Extensions.Configuration.CloudFoundry;
|
|||
{{#ConfigServer}}
|
||||
using Steeltoe.Extensions.Configuration.ConfigServer;
|
||||
{{/ConfigServer}}
|
||||
|
||||
{{#PlaceholderConfig}}
|
||||
using Steeltoe.Extensions.Configuration.PlaceholderCore;
|
||||
{{/PlaceholderConfig}}
|
||||
namespace {{ProjectNameSpace}}
|
||||
{
|
||||
public class Program
|
||||
|
@ -28,7 +30,10 @@ namespace {{ProjectNameSpace}}
|
|||
CreateWebHostBuilder(args)
|
||||
{{#ConfigServer}}
|
||||
.AddConfigServer()
|
||||
{{/ConfigServer}}
|
||||
{{/ConfigServer}}
|
||||
{{#PlaceholderConfig}}
|
||||
.AddPlaceholderResolver()
|
||||
{{/PlaceholderConfig}}
|
||||
.Build()
|
||||
{{#AnyEFCore}}
|
||||
.InitializeDbContexts()
|
||||
|
@ -41,18 +46,18 @@ namespace {{ProjectNameSpace}}
|
|||
{
|
||||
var builder = WebHost.CreateDefaultBuilder(args)
|
||||
.UseDefaultServiceProvider(configure => configure.ValidateScopes = false)
|
||||
{{#CloudFoundry}}
|
||||
{{#CloudFoundry}}
|
||||
.UseCloudFoundryHosting(5555) //Enable listening on a Env provided port
|
||||
.AddCloudFoundry() //Add cloudfoundry environment variables as a configuration source
|
||||
{{/CloudFoundry}}
|
||||
{{/CloudFoundry}}
|
||||
.UseStartup<Startup>();
|
||||
{{#ActuatorsOrDynamicLogger}}
|
||||
{{#ActuatorsOrDynamicLogger}}
|
||||
builder.ConfigureLogging((hostingContext, loggingBuilder) =>
|
||||
{
|
||||
loggingBuilder.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
|
||||
loggingBuilder.AddDynamicConsole();
|
||||
});
|
||||
{{/ActuatorsOrDynamicLogger}}
|
||||
{{/ActuatorsOrDynamicLogger}}
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,9 @@
|
|||
{{#ConfigServer}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.ConfigServerCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/ConfigServer}}
|
||||
|
||||
{{#PlaceholderConfig}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.PlaceholderCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/PlaceholderConfig}}
|
||||
{{#ActuatorsOrCloudFoundry}}
|
||||
<PackageReference Include="Steeltoe.Management.ExporterCore" Version="{{SteeltoeVersion}}"/>
|
||||
<PackageReference Include="Steeltoe.Management.CloudFoundryCore" Version="{{SteeltoeVersion}}" />
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace {{ProjectNameSpace}}
|
||||
{
|
||||
public class SampleOptions
|
||||
{
|
||||
public string ResolvedPlaceholderFromEnvVariables { get; set; }
|
||||
public string UnresolvedPlaceholder { get; set; }
|
||||
public string ResolvedPlaceholderFromJson { get; set; }
|
||||
}
|
||||
}
|
|
@ -87,6 +87,9 @@ namespace {{ProjectNameSpace}}
|
|||
services.AddAuthentication(AzureADB2CDefaults.BearerAuthenticationScheme)
|
||||
.AddAzureADB2CBearer(options => Configuration.Bind("AzureAdB2C", options));
|
||||
{{/IndividualB2CAuth}}
|
||||
{{#PlaceholderConfig}}
|
||||
services.Configure<SampleOptions>(Configuration);
|
||||
{{/PlaceholderConfig}}
|
||||
{{#MySql}}
|
||||
services.AddMySqlConnection(Configuration);
|
||||
{{/MySql}}
|
||||
|
|
|
@ -5,28 +5,28 @@
|
|||
"System": "Information",
|
||||
"Microsoft": "Information"
|
||||
}
|
||||
},
|
||||
"spring": {
|
||||
"application": {
|
||||
"name": "{{ProjectNameSpace}}"
|
||||
}{{"#ConfigServer"}},
|
||||
"cloud": {
|
||||
"config": {
|
||||
"uri": "http://localhost:8888",
|
||||
"validate_certifates": false
|
||||
}
|
||||
}
|
||||
{{"/ConfigServer"}}
|
||||
}
|
||||
{{#SQLServer}}
|
||||
{{"#SQLServer"}},
|
||||
"sqlserver": {
|
||||
"credentials": {
|
||||
// "connectionString": "Server=(localdb)\\mssqllocaldb;database=Steeltoe;Trusted_Connection=True;"
|
||||
"connectionString": "Server=127.0.0.1;database=Master; User Id=SA;Password=YourStrongP@ssw0rd"
|
||||
}
|
||||
},
|
||||
{{/SQLServer}}
|
||||
{{#Discovery}},
|
||||
"spring": {
|
||||
"application": {
|
||||
"name": "fortuneService"
|
||||
}
|
||||
// Remove comments to enable Container to Container (C2C)
|
||||
// requests on Cloud Foundry
|
||||
// ,"cloud" : {
|
||||
// "discovery" : {
|
||||
// "registrationMethod" : "direct"
|
||||
// }
|
||||
// }
|
||||
},
|
||||
}
|
||||
{{"/SQLServer"}}
|
||||
{{"#Discovery"}},
|
||||
"eureka": {
|
||||
"client": {
|
||||
"serviceUrl": "http://localhost:8761/eureka/",
|
||||
|
@ -41,5 +41,6 @@
|
|||
//,"securePortEnabled": true
|
||||
}
|
||||
},
|
||||
{{/Discovery}}
|
||||
}
|
||||
{{"/Discovery"}}
|
||||
|
||||
}
|
|
@ -1,31 +1,13 @@
|
|||
{
|
||||
{{#IndividualB2CAuth}}
|
||||
// "AzureAdB2C": {
|
||||
// "Instance": "https:////login.microsoftonline.com/tfp/",
|
||||
// "ClientId": "11111111-1111-1111-11111111111111111",
|
||||
// "Domain": "qualified.domain.name",
|
||||
// "SignUpSignInPolicyId": "MySignUpSignInPolicyId"
|
||||
// },
|
||||
{{/IndividualB2CAuth}}
|
||||
{{#OrganizationalAuth}}
|
||||
// "AzureAd": {
|
||||
|
||||
{{#SingleOrgAuth}}
|
||||
// "Instance": "https:////login.microsoftonline.com/common",
|
||||
{{/SingleOrgAuth}}
|
||||
{{^SingleOrgAuth}}
|
||||
// "Instance": "https:////login.microsoftonline.com/",
|
||||
// "Domain": "qualified.domain.name",
|
||||
// "TenantId": "22222222-2222-2222-2222-222222222222",
|
||||
{{/SingleOrgAuth}}
|
||||
// "ClientId": "11111111-1111-1111-11111111111111111"
|
||||
// },
|
||||
{{/OrganizationalAuth}}
|
||||
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
{{"#PlaceholderConfig"}}
|
||||
"ResolvedPlaceholderFromEnvVariables": "${PATH?NotFound}",
|
||||
"UnresolvedPlaceholder": "${SomKeyNotFound?NotFound}",
|
||||
"ResolvedPlaceholderFromJson": "${Logging:LogLevel:System?${Loggin:LogLevel:Default}}"
|
||||
{{"/PlaceholderConfig"}}
|
||||
}
|
||||
|
|
|
@ -84,6 +84,12 @@
|
|||
"Description": "Steeltoe: Add ConfigServer Configuration Source",
|
||||
"friendlyName": "Config Server"
|
||||
},
|
||||
{
|
||||
"Name": "PlaceholderConfig",
|
||||
"DefaultValue": false,
|
||||
"Description": "Steeltoe: Add Placeholder Configuration Source",
|
||||
"friendlyName": "Placeholder Configuration Source"
|
||||
},
|
||||
{
|
||||
"Name": "ProjectNameSpace",
|
||||
"DefaultValue": "SteeltoeExample",
|
||||
|
@ -134,7 +140,11 @@
|
|||
},
|
||||
{
|
||||
"Name": "ConfigServer",
|
||||
"InclusionExpression": "Models/ConfigServerData.cs;Controllers/ConfigDataController.cs"
|
||||
"InclusionExpression": "Models/ConfigServerData.cs;Controllers/ConfigDataController.cs"
|
||||
},
|
||||
{
|
||||
"Name": "PlaceholderConfig",
|
||||
"InclusionExpression": "SampleOptions.cs;Controllers/PlaceholderDataController.cs"
|
||||
}
|
||||
],
|
||||
"Versions": [
|
||||
|
|
|
@ -1,32 +1,13 @@
|
|||
{
|
||||
{{#IndividualB2CAuth}}
|
||||
// "AzureAdB2C": {
|
||||
// "Instance": "https:////login.microsoftonline.com/tfp/",
|
||||
// "ClientId": "11111111-1111-1111-11111111111111111",
|
||||
// "Domain": "qualified.domain.name",
|
||||
// "SignUpSignInPolicyId": "MySignUpSignInPolicyId"
|
||||
// },
|
||||
{{/IndividualB2CAuth}}
|
||||
{{#OrganizationalAuth}}
|
||||
// "AzureAd": {
|
||||
|
||||
{{#SingleOrgAuth}}
|
||||
// "Instance": "https:////login.microsoftonline.com/common",
|
||||
{{/SingleOrgAuth}}
|
||||
{{^SingleOrgAuth}}
|
||||
// "Instance": "https:////login.microsoftonline.com/",
|
||||
// "Domain": "qualified.domain.name",
|
||||
// "TenantId": "22222222-2222-2222-2222-222222222222",
|
||||
{{/SingleOrgAuth}}
|
||||
// "ClientId": "11111111-1111-1111-11111111111111111"
|
||||
// },
|
||||
{{/OrganizationalAuth}}
|
||||
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
|
||||
{{"#PlaceholderConfig"}}
|
||||
"ResolvedPlaceholderFromEnvVariables": "${PATH?NotFound}",
|
||||
"UnresolvedPlaceholder": "${SomKeyNotFound?NotFound}",
|
||||
"ResolvedPlaceholderFromJson": "${Logging:LogLevel:System?${Loggin:LogLevel:Default}}",
|
||||
{{"/PlaceholderConfig"}}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче