forked from vmware-archive/Workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,136 changed files
with
82,060 additions
and
6,163 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
ConfigServer/steeltoe/config-repo/application-Development.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Logging: | ||
IncludeScopes: false | ||
Debug: | ||
LogLevel: | ||
Default: Information | ||
Fortune_Teller_Service: Debug | ||
Fortune_Teller_UI: Debug | ||
Pivotal: Debug | ||
Steeltoe: Debug | ||
Console: | ||
LogLevel: | ||
Default: Information | ||
Fortune_Teller_Service: Debug | ||
Fortune_Teller_UI: Debug | ||
Pivotal: Debug | ||
Steeltoe: Debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Logging: | ||
IncludeScopes: false | ||
Debug: | ||
LogLevel: | ||
Default: Information | ||
Console: | ||
LogLevel: | ||
Default: Information | ||
eureka: | ||
client: | ||
serviceUrl: http://localhost:8761/eureka/ | ||
validate_certificates: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,3 @@ eureka: | |
shouldFetchRegistry: false | ||
instance: | ||
port: 5000 | ||
hostName: localhost |
6 changes: 2 additions & 4 deletions
6
Session-03/Lab08/config-repo/fortuneui.yml → ...Server/steeltoe/config-repo/fortuneui.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
eureka: | ||
client: | ||
shouldRegisterWithEureka: false | ||
|
||
fortuneService: | ||
scheme: http | ||
address: fortuneService | ||
address: fortuneservice | ||
randomFortunePath: api/fortunes/random | ||
allFortunesPath: api/fortunes/all | ||
|
||
allFortunesPath: api/fortunes/all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
Final/Fortune-Teller-Service/Controllers/FortunesController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
| ||
using Fortune_Teller_Service.Models; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Logging; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace Fortune_Teller_Service.Controllers | ||
{ | ||
[Route("api/[controller]")] | ||
public class FortunesController : Controller | ||
{ | ||
ILogger<FortunesController> _logger; | ||
|
||
// Lab05 Start | ||
private IFortuneRepository _fortunes; | ||
public FortunesController(ILogger<FortunesController> logger, IFortuneRepository fortunes) | ||
{ | ||
_logger = logger; | ||
_fortunes = fortunes; | ||
} | ||
// Lab05 End | ||
|
||
|
||
// GET: api/fortunes/all | ||
[HttpGet("all")] | ||
// Lab10 Start | ||
[Authorize(Policy = "read.fortunes")] | ||
// Lab10 End | ||
public async Task<List<Fortune>> AllFortunesAsync() | ||
{ | ||
_logger?.LogDebug("AllFortunesAsync"); | ||
|
||
// Lab05 Start | ||
var entities = await _fortunes.GetAllAsync(); | ||
var result = new List<Fortune>(); | ||
foreach(var entity in entities) | ||
{ | ||
result.Add(new Fortune() { Id = entity.Id, Text = entity.Text }); | ||
} | ||
return result; | ||
// Lab05 End | ||
} | ||
|
||
// GET api/fortunes/random | ||
[HttpGet("random")] | ||
// Lab10 Start | ||
[Authorize(Policy = "read.fortunes")] | ||
// Lab10 End | ||
public async Task<Fortune> RandomFortuneAsync() | ||
{ | ||
_logger?.LogDebug("RandomFortuneAsync"); | ||
|
||
// Lab05 Start | ||
var entity = await _fortunes.RandomFortuneAsync(); | ||
return new Fortune() { Id = entity.Id, Text = entity.Text }; | ||
// Lab05 End | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
Final/Fortune-Teller-Service/Fortune-Teller-Service.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
<RootNamespace>Fortune_Teller_Service</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Models\" /> | ||
<Folder Include="wwwroot\" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /> | ||
<!-- Lab06 Start--> | ||
<PackageReference Include="Pivotal.Extensions.Configuration.ConfigServerCore" Version="2.0.0-dev-00118" /> | ||
<!-- Lab06 End--> | ||
|
||
<!-- Lab07 Start--> | ||
<PackageReference Include="Pivotal.Discovery.ClientCore" Version="2.0.0-dev-00114" /> | ||
<!-- Lab07 End--> | ||
|
||
<!-- Lab08 Start--> | ||
<PackageReference Include="Steeltoe.CloudFoundry.Connector.EFCore" Version="2.0.0-dev-00193" /> | ||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.0.0" /> | ||
<!-- Lab08 End--> | ||
|
||
<!-- Lab10 Start--> | ||
<PackageReference Include="Steeltoe.Security.Authentication.CloudFoundryCore" Version="2.0.0-dev-00081" /> | ||
<!-- Lab10 End--> | ||
|
||
</ItemGroup> | ||
|
||
<!-- Lab11 Start--> | ||
<ItemGroup> | ||
<PackageReference Include="Steeltoe.Management.CloudFoundryCore" Version="2.0.0-dev-00052" /> | ||
|
||
<PackageReference Include="GitInfo" Version="2.0.1" /> | ||
<None Include="git.properties"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
<Target Name="_GitProperties" AfterTargets="CoreCompile"> | ||
<WriteLinesToFile File="git.properties" Lines="git.remote.origin.url=$(GitRoot)" Overwrite="true" /> | ||
<WriteLinesToFile File="git.properties" Lines="git.build.version=$(GitBaseVersion)" Overwrite="false" /> | ||
<WriteLinesToFile File="git.properties" Lines="git.commit.id.abbrev=$(GitCommit)" Overwrite="false" /> | ||
<WriteLinesToFile File="git.properties" Lines="git.commit.id=$(GitSha)" Overwrite="false" /> | ||
<WriteLinesToFile File="git.properties" Lines="git.tags=$(GitTag)" Overwrite="false" /> | ||
<WriteLinesToFile File="git.properties" Lines="git.branch=$(GitBranch)" Overwrite="false" /> | ||
<WriteLinesToFile File="git.properties" Lines="git.build.time=$([System.DateTime]::Now.ToString('O'))" Overwrite="false" /> | ||
<WriteLinesToFile File="git.properties" Lines="git.build.user.name=$([System.Environment]::GetEnvironmentVariable('USERNAME'))" Overwrite="false" /> | ||
<WriteLinesToFile File="git.properties" Lines="git.build.host=$([System.Environment]::GetEnvironmentVariable('COMPUTERNAME'))" Overwrite="false" /> | ||
</Target> | ||
<!-- Lab11 End--> | ||
|
||
<ItemGroup> | ||
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
2 changes: 1 addition & 1 deletion
2
FortuneTeller/Common/Services/Fortune.cs → .../Fortune-Teller-Service/Models/Fortune.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Lab11 Start | ||
using System; | ||
|
||
using Fortune_Teller_Service.Models; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.Logging; | ||
|
||
using MySql.Data.MySqlClient; | ||
|
||
using Steeltoe.Management.Endpoint.Health; | ||
|
||
|
||
namespace Fortune_Teller_Service | ||
{ | ||
public class MySqlHealthContributor : IHealthContributor | ||
{ | ||
FortuneContext _context; | ||
ILogger<MySqlHealthContributor> _logger; | ||
public MySqlHealthContributor(FortuneContext dbContext, ILogger<MySqlHealthContributor> logger) | ||
{ | ||
_context = dbContext; | ||
_logger = logger; | ||
} | ||
|
||
public string Id { get; } = "mySql"; | ||
|
||
public Health Health() | ||
{ | ||
_logger.LogInformation("Checking MySql connection health!"); | ||
|
||
Health result = new Health(); | ||
result.Details.Add("database", "MySQL"); | ||
MySqlConnection _connection = null; | ||
try | ||
{ | ||
_connection = _context.Database.GetDbConnection() as MySqlConnection; | ||
if (_connection != null) | ||
{ | ||
_connection.Open(); | ||
MySqlCommand cmd = new MySqlCommand("SELECT 1;", _connection); | ||
var qresult = cmd.ExecuteScalar(); | ||
result.Details.Add("result", qresult); | ||
result.Details.Add("status", HealthStatus.UP.ToString()); | ||
result.Status = HealthStatus.UP; | ||
_logger.LogInformation("MySql connection up!"); | ||
} | ||
|
||
} | ||
catch (Exception e) | ||
{ | ||
_logger.LogInformation("MySql connection down!"); | ||
result.Details.Add("error", e.GetType().Name + ": " + e.Message); | ||
result.Details.Add("status", HealthStatus.DOWN.ToString()); | ||
result.Status = HealthStatus.DOWN; | ||
} | ||
finally | ||
{ | ||
if (_connection != null) _connection.Close(); | ||
} | ||
|
||
return result; | ||
} | ||
} | ||
} | ||
// Lab11 End |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System.IO; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Logging; | ||
|
||
// Lab06 Start | ||
using Pivotal.Extensions.Configuration.ConfigServer; | ||
// Lab06 End | ||
|
||
// Lab11 Start | ||
using Steeltoe.Extensions.Logging; | ||
// Lab11 End | ||
|
||
namespace Fortune_Teller_Service | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
BuildWebHost(args).Run(); | ||
} | ||
|
||
public static IWebHost BuildWebHost(string[] args) | ||
{ | ||
var builder = new WebHostBuilder() | ||
.UseKestrel() | ||
.UseContentRoot(Directory.GetCurrentDirectory()) | ||
.ConfigureAppConfiguration((hostingContext, config) => | ||
{ | ||
var env = hostingContext.HostingEnvironment; | ||
|
||
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) | ||
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true); | ||
|
||
// Lab06 Start | ||
config.AddConfigServer(env); | ||
// Lab06 End | ||
|
||
config.AddEnvironmentVariables(); | ||
|
||
if (args != null) | ||
{ | ||
config.AddCommandLine(args); | ||
} | ||
}) | ||
.ConfigureLogging((hostingContext, logging) => | ||
{ | ||
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); | ||
logging.AddDebug(); | ||
|
||
// Lab11 Start | ||
logging.AddDynamicConsole(hostingContext.Configuration); | ||
// Lab11 End | ||
|
||
}) | ||
.UseIISIntegration() | ||
.UseDefaultServiceProvider((context, options) => | ||
{ | ||
options.ValidateScopes = context.HostingEnvironment.IsDevelopment(); | ||
}) | ||
.UseStartup<Startup>(); | ||
|
||
if (args != null) | ||
{ | ||
builder.UseConfiguration(new ConfigurationBuilder().AddCommandLine(args).Build()); | ||
} | ||
|
||
return builder.Build(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.