Skip to content

Commit f15e3a9

Browse files
authored
Merge pull request #1 from ThreeMammals/develop
Update
2 parents f4c9e2a + 41519b1 commit f15e3a9

File tree

63 files changed

+718
-519
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+718
-519
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ sudo: required
88
dist: bionic
99

1010
# OS X 10.12
11-
osx_image: xcode9.2
11+
osx_image: xcode9.4
1212

1313
mono:
14-
- 5.10.0
14+
- 6.0.0
1515

16-
dotnet: 2.2.105
16+
dotnet: 3.0.100
1717

1818
before_install:
1919
- git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
[<img src="http://threemammals.com/images/ocelot_logo.png">](http://threemammals.com/ocelot)
1+
[<img src="https://threemammals.com/ocelot_logo.png">](https://threemammals.com/ocelot)
22

33
[![Build status](https://ci.appveyor.com/api/projects/status/r6sv51qx36sis1je?branch=develop&svg=true)](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb) Windows (AppVeyor)
44

55
[![Build Status](https://travis-ci.org/ThreeMammals/Ocelot.svg?branch=develop)](https://travis-ci.org/ThreeMammals/Ocelot) Linux & OSX (Travis)
66

7-
[![Build Status](https://dev.azure.com/ThreeMammals/Ocelot/_apis/build/status/Ocelot%20-%20Windows?branchName=develop)](https://dev.azure.com/ThreeMammals/Ocelot/_build/latest?definitionId=4&branchName=develop) Windows
8-
9-
[![Build Status](https://dev.azure.com/ThreeMammals/Ocelot/_apis/build/status/Ocelot%20-%20MacOS?branchName=develop)](https://dev.azure.com/ThreeMammals/Ocelot/_build/latest?definitionId=3&branchName=develop) MacOS
10-
11-
[![Build Status](https://dev.azure.com/ThreeMammals/Ocelot/_apis/build/status/Ocelot%20-%20Linux?branchName=develop)](https://dev.azure.com/ThreeMammals/Ocelot/_build/latest?definitionId=2&branchName=develop) Linux
12-
137
[![Windows Build history](https://buildstats.info/appveyor/chart/TomPallister/ocelot-fcfpb?branch=develop&includeBuildsFromPullRequest=false)](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb/history?branch=develop)
148

159
[![Coverage Status](https://coveralls.io/repos/github/ThreeMammals/Ocelot/badge.svg?branch=develop)](https://coveralls.io/github/ThreeMammals/Ocelot?branch=develop)
@@ -43,7 +37,7 @@ is returned to the client. That is basically it with a bunch of other features!
4337

4438
## Features
4539

46-
A quick list of Ocelot's capabilities for more information see the [documentation](http://ocelot.readthedocs.io/en/latest/).
40+
A quick list of Ocelot's capabilities for more information see the [documentation](https://ocelot.readthedocs.io/en/latest/).
4741

4842
* Routing
4943
* Request Aggregation
@@ -79,7 +73,7 @@ All versions can be found [here](https://www.nuget.org/packages/Ocelot/)
7973

8074
## Documentation
8175

82-
Please click [here](http://ocelot.readthedocs.io/en/latest/) for the Ocelot documentation. This includes lots of information and will be helpful if you want to understand the features Ocelot currently offers.
76+
Please click [here](https://ocelot.readthedocs.io/en/latest/) for the Ocelot documentation. This includes lots of information and will be helpful if you want to understand the features Ocelot currently offers.
8377

8478
## Coming up
8579

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
image: Visual Studio 2019

build.cake

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
#tool "nuget:?package=GitReleaseNotes"
33
#addin nuget:?package=Cake.Json
44
#addin nuget:?package=Newtonsoft.Json
5-
#tool "nuget:?package=OpenCover"
65
#tool "nuget:?package=ReportGenerator"
76
#tool "nuget:?package=coveralls.net&version=0.7.0"
8-
#addin Cake.Coveralls&version=0.7.0
7+
#addin Cake.Coveralls&version=0.10.1
98

109
// compile
1110
var compileConfig = Argument("configuration", "Release");
@@ -119,27 +118,20 @@ Task("RunUnitTests")
119118
.IsDependentOn("Compile")
120119
.Does(() =>
121120
{
121+
var testSettings = new DotNetCoreTestSettings
122+
{
123+
Configuration = compileConfig,
124+
ResultsDirectory = artifactsForUnitTestsDir,
125+
ArgumentCustomization = args => args
126+
.Append("--settings test/Ocelot.UnitTests/UnitTests.runsettings")
127+
};
128+
129+
EnsureDirectoryExists(artifactsForUnitTestsDir);
130+
DotNetCoreTest(unitTestAssemblies, testSettings);
131+
122132
if (IsRunningOnWindows())
123133
{
124-
var coverageSummaryFile = artifactsForUnitTestsDir + File("coverage.xml");
125-
126-
EnsureDirectoryExists(artifactsForUnitTestsDir);
127-
128-
OpenCover(tool =>
129-
{
130-
tool.DotNetCoreTest(unitTestAssemblies);
131-
},
132-
new FilePath(coverageSummaryFile),
133-
new OpenCoverSettings()
134-
{
135-
Register="user",
136-
ArgumentCustomization=args=>args.Append(@"-oldstyle -returntargetcode -excludebyattribute:*.ExcludeFromCoverage*")
137-
}
138-
.WithFilter("+[Ocelot*]*")
139-
.WithFilter("-[xunit*]*")
140-
.WithFilter("-[Ocelot*Tests]*")
141-
);
142-
134+
var coverageSummaryFile = GetSubDirectories(artifactsForUnitTestsDir).First().CombineWithFilePath(File("coverage.opencover.xml"));
143135
ReportGenerator(coverageSummaryFile, artifactsForUnitTestsDir);
144136

145137
if (AppVeyor.IsRunningOnAppVeyor)
@@ -171,17 +163,6 @@ Task("RunUnitTests")
171163
var whereToCheck = !AppVeyor.IsRunningOnAppVeyor ? coverallsRepo : artifactsForUnitTestsDir;
172164
throw new Exception(string.Format("Code coverage fell below the threshold of {0}%. You can find the code coverage report at {1}", minCodeCoverage, whereToCheck));
173165
};
174-
175-
}
176-
else
177-
{
178-
var settings = new DotNetCoreTestSettings
179-
{
180-
Configuration = compileConfig,
181-
};
182-
183-
EnsureDirectoryExists(artifactsForUnitTestsDir);
184-
DotNetCoreTest(unitTestAssemblies, settings);
185166
}
186167
});
187168

src/Ocelot.Administration/Ocelot.Administration.csproj

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netstandard2.0</TargetFramework>
4-
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
5-
<NETStandardImplicitPackageVersion>2.0.0</NETStandardImplicitPackageVersion>
3+
<TargetFramework>netcoreapp3.0</TargetFramework>
64
<NoPackageAnalysis>true</NoPackageAnalysis>
75
<Description>Provides Ocelot extensions to use the administration API and IdentityService dependencies that come with it</Description>
86
<AssemblyTitle>Ocelot.Administration</AssemblyTitle>
@@ -29,10 +27,13 @@
2927
<ProjectReference Include="..\Ocelot\Ocelot.csproj" />
3028
</ItemGroup>
3129
<ItemGroup>
32-
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
30+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66">
3331
<PrivateAssets>all</PrivateAssets>
3432
</PackageReference>
35-
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.7.0" />
36-
<PackageReference Include="IdentityServer4" Version="2.4.0" />
33+
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
34+
<PackageReference Include="IdentityServer4" Version="3.0.1" />
35+
</ItemGroup>
36+
<ItemGroup>
37+
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
3738
</ItemGroup>
3839
</Project>

src/Ocelot.Administration/OcelotBuilderExtensions.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
namespace Ocelot.Administration
2-
{
3-
using DependencyInjection;
4-
using IdentityServer4.AccessTokenValidation;
5-
using IdentityServer4.Models;
6-
using Microsoft.AspNetCore.Builder;
7-
using Microsoft.Extensions.Configuration;
8-
using Microsoft.Extensions.DependencyInjection;
9-
using Microsoft.Extensions.DependencyInjection.Extensions;
10-
using Ocelot.Middleware;
11-
using System;
12-
using System.Collections.Generic;
13-
using System.IdentityModel.Tokens.Jwt;
14-
using System.Security.Cryptography.X509Certificates;
1+
using Ocelot.DependencyInjection;
2+
using IdentityServer4.AccessTokenValidation;
3+
using IdentityServer4.Models;
4+
using Microsoft.AspNetCore.Builder;
5+
using Microsoft.Extensions.Configuration;
6+
using Microsoft.Extensions.DependencyInjection;
7+
using Microsoft.Extensions.DependencyInjection.Extensions;
8+
using Ocelot.Middleware;
9+
using System;
10+
using System.Collections.Generic;
11+
using System.IdentityModel.Tokens.Jwt;
12+
using System.Security.Cryptography.X509Certificates;
1513

14+
namespace Ocelot.Administration
15+
{
1616
public static class OcelotBuilderExtensions
1717
{
1818
public static IOcelotAdministrationBuilder AddAdministration(this IOcelotBuilder builder, string path, string secret)
@@ -86,7 +86,7 @@ private static void AddIdentityServer(IIdentityServerConfiguration identityServe
8686
else
8787
{
8888
//todo - refactor so calls method?
89-
var cert = new X509Certificate2(identityServerConfiguration.CredentialsSigningCertificateLocation, identityServerConfiguration.CredentialsSigningCertificatePassword);
89+
var cert = new X509Certificate2(identityServerConfiguration.CredentialsSigningCertificateLocation, identityServerConfiguration.CredentialsSigningCertificatePassword, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable);
9090
identityServerBuilder.AddSigningCredential(cert);
9191
}
9292
}

src/Ocelot.Cache.CacheManager/Ocelot.Cache.CacheManager.csproj

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netstandard2.0</TargetFramework>
4-
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
5-
<NETStandardImplicitPackageVersion>2.0.0</NETStandardImplicitPackageVersion>
3+
<TargetFramework>netcoreapp3.0</TargetFramework>
64
<NoPackageAnalysis>true</NoPackageAnalysis>
75
<Description>Provides Ocelot extensions to use CacheManager.Net</Description>
86
<AssemblyTitle>Ocelot.Cache.CacheManager</AssemblyTitle>
@@ -28,11 +26,14 @@
2826
<ProjectReference Include="..\Ocelot\Ocelot.csproj" />
2927
</ItemGroup>
3028
<ItemGroup>
31-
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
29+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66">
3230
<PrivateAssets>all</PrivateAssets>
3331
</PackageReference>
34-
<PackageReference Include="CacheManager.Core" Version="1.2.0" />
35-
<PackageReference Include="CacheManager.Microsoft.Extensions.Configuration" Version="1.2.0" />
36-
<PackageReference Include="CacheManager.Microsoft.Extensions.Logging" Version="1.2.0" />
32+
<PackageReference Include="CacheManager.Core" Version="2.0.0-beta-1629" />
33+
<PackageReference Include="CacheManager.Microsoft.Extensions.Configuration" Version="2.0.0-beta-1629" />
34+
<PackageReference Include="CacheManager.Microsoft.Extensions.Logging" Version="2.0.0-beta-1629" />
35+
</ItemGroup>
36+
<ItemGroup>
37+
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
3738
</ItemGroup>
3839
</Project>

src/Ocelot.Provider.Consul/ConsulFileConfigurationRepository.cs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Configuration.Repository;
55
using global::Consul;
66
using Logging;
7+
using Microsoft.Extensions.Options;
78
using Newtonsoft.Json;
89
using Responses;
910
using System;
@@ -18,29 +19,20 @@ public class ConsulFileConfigurationRepository : IFileConfigurationRepository
1819
private readonly IOcelotLogger _logger;
1920

2021
public ConsulFileConfigurationRepository(
22+
IOptions<FileConfiguration> fileConfiguration,
2123
Cache.IOcelotCache<FileConfiguration> cache,
22-
IInternalConfigurationRepository repo,
2324
IConsulClientFactory factory,
2425
IOcelotLoggerFactory loggerFactory)
2526
{
2627
_logger = loggerFactory.CreateLogger<ConsulFileConfigurationRepository>();
2728
_cache = cache;
2829

29-
var internalConfig = repo.Get();
30+
var serviceDiscoveryProvider = fileConfiguration.Value.GlobalConfiguration.ServiceDiscoveryProvider;
31+
_configurationKey = string.IsNullOrWhiteSpace(serviceDiscoveryProvider.ConfigurationKey) ? "InternalConfiguration" :
32+
serviceDiscoveryProvider.ConfigurationKey;
3033

31-
_configurationKey = "InternalConfiguration";
32-
33-
string token = null;
34-
35-
if (!internalConfig.IsError)
36-
{
37-
token = internalConfig.Data.ServiceProviderConfiguration.Token;
38-
_configurationKey = !string.IsNullOrEmpty(internalConfig.Data.ServiceProviderConfiguration.ConfigurationKey) ?
39-
internalConfig.Data.ServiceProviderConfiguration.ConfigurationKey : _configurationKey;
40-
}
41-
42-
var config = new ConsulRegistryConfiguration(internalConfig.Data.ServiceProviderConfiguration.Host,
43-
internalConfig.Data.ServiceProviderConfiguration.Port, _configurationKey, token);
34+
var config = new ConsulRegistryConfiguration(serviceDiscoveryProvider.Host,
35+
serviceDiscoveryProvider.Port, _configurationKey, serviceDiscoveryProvider.Token);
4436

4537
_consul = factory.Get(config);
4638
}

src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netstandard2.0</TargetFramework>
4-
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
5-
<NETStandardImplicitPackageVersion>2.0.0</NETStandardImplicitPackageVersion>
3+
<TargetFramework>netcoreapp3.0</TargetFramework>
64
<NoPackageAnalysis>true</NoPackageAnalysis>
75
<Description>Provides Ocelot extensions to use Consul</Description>
86
<AssemblyTitle>Ocelot.Provider.Consul</AssemblyTitle>
@@ -30,8 +28,11 @@
3028
</ItemGroup>
3129
<ItemGroup>
3230
<PackageReference Include="Consul" Version="0.7.2.6" />
33-
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
31+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66">
3432
<PrivateAssets>all</PrivateAssets>
3533
</PackageReference>
3634
</ItemGroup>
35+
<ItemGroup>
36+
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
37+
</ItemGroup>
3738
</Project>

src/Ocelot.Provider.Consul/PollingConsulServiceDiscoveryProvider.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
{
33
using Logging;
44
using ServiceDiscovery.Providers;
5+
using System;
56
using System.Collections.Generic;
67
using System.Threading;
78
using System.Threading.Tasks;
89
using Values;
910

10-
public class PollConsul : IServiceDiscoveryProvider
11+
public sealed class PollConsul : IServiceDiscoveryProvider, IDisposable
1112
{
1213
private readonly IOcelotLogger _logger;
1314
private readonly IServiceDiscoveryProvider _consulServiceDiscoveryProvider;
14-
private readonly Timer _timer;
15+
private Timer _timer;
1516
private bool _polling;
1617
private List<Service> _services;
1718

@@ -34,6 +35,12 @@ public PollConsul(int pollingInterval, IOcelotLoggerFactory factory, IServiceDis
3435
}, null, pollingInterval, pollingInterval);
3536
}
3637

38+
public void Dispose()
39+
{
40+
_timer?.Dispose();
41+
_timer = null;
42+
}
43+
3744
public Task<List<Service>> Get()
3845
{
3946
return Task.FromResult(_services);

0 commit comments

Comments
 (0)