Skip to content

Commit

Permalink
2.0 Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dtillman committed Nov 28, 2017
1 parent 4369f36 commit ca8257a
Show file tree
Hide file tree
Showing 1,136 changed files with 82,060 additions and 6,163 deletions.
Binary file added Common/images/Java-Jdk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Common/images/Lab-06-appmanager-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Common/images/Lab-06-appmanager-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Common/images/Lab-06-appmanager-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Common/images/Lab-07-appmanager-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Common/images/Lab-07-appmanager-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Common/images/lab-01-appsmanager-env-variables.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Common/images/lab-01-appsmanager-env.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Common/images/lab-01-appsmanager.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Common/images/lab-01-dotnet-install.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Common/images/lab-01-dotnet-install2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Common/images/lab-01-git-hub.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Common/images/lab-05-ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Common/images/lab-05-ui2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Common/images/lab-05-ui3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Common/images/lab-09-hystrix-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Common/images/lab-09-hystrix-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Common/images/lab-add-route.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Common/images/lab-marketplace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Common/images/lab-metrics-sel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Common/images/lab-metrics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Common/images/lab-mkt-link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Common/images/lab-mysql.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Common/images/lab-mysql2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Common/images/lab-mysql3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Common/images/lab-mysql4.png
Binary file added Common/images/lab-mysql5.png
Binary file modified Common/images/lab-routes.png
Binary file modified Common/images/lab-unmap-route.png
2 changes: 1 addition & 1 deletion ConfigServer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ $ java -jar target/*.jar
```

It will start up on port 8888 and serve configuration data from
"file:///steeltoe/config-repo":
"file:./steeltoe/config-repo":
10 changes: 9 additions & 1 deletion ConfigServer/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ spring:
config:
server:
native:
searchLocations: file:./steeltoe/config-repo
searchLocations: file:./steeltoe/config-repo
#
# Replace spring: configuration above with what is below for github repo usage
#
# spring:
# cloud:
# config:
# server:
# git: https://github.com/SteeltoeOSS/workshop-config-repo.git
16 changes: 16 additions & 0 deletions ConfigServer/steeltoe/config-repo/application-Development.yml
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
12 changes: 12 additions & 0 deletions ConfigServer/steeltoe/config-repo/application.yml
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ eureka:
shouldFetchRegistry: false
instance:
port: 5000
hostName: localhost
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
2 changes: 1 addition & 1 deletion EurekaServer/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ spring:
name: eureka
cloud:
config:
uri: ${CONFIG_SERVER_URL:http://localhost:8888}
uri: ${CONFIG_SERVER_URL:http://localhost:9999}
61 changes: 61 additions & 0 deletions Final/Fortune-Teller-Service/Controllers/FortunesController.cs
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 Final/Fortune-Teller-Service/Fortune-Teller-Service.csproj
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>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Fortune_Teller_Service.Common.Services
namespace Fortune_Teller_Service.Models
{
public class Fortune
{
Expand Down
65 changes: 65 additions & 0 deletions Final/Fortune-Teller-Service/MySqlHealthContributor.cs
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
73 changes: 73 additions & 0 deletions Final/Fortune-Teller-Service/Program.cs
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();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:50479/",
"applicationUrl": "http://localhost:58497/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/fortunes/all",
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Fortune_Teller_Service": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "http://localhost:5000/api/fortunes/all",
"launchUrl": "api/fortunes/random",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://*:5000"
}
}
}
}
}
Loading

0 comments on commit ca8257a

Please sign in to comment.