Skip to content

Commit

Permalink
Release features #1499 #1663 (#1660) (#1693)
Browse files Browse the repository at this point in the history
* push code coverage for main and develop branches

* #1660 Huge logs because of StyleCop.Analyzers warnings (#1663)

* Add StyleCop.Analyzers package

* Fix SA0001: XML comment analysis is disabled due to project configuration

* Fix SA1609: Property documentation should have value

* Fix CS1591: Missing XML comment for publicly visible type or member {xyz}

* Fix SA1101: Prefix local calls with this

* Fix SA1413: The last statement in a multi-line C# initializer or list is missing a trailing comma.

* Fix SA1135: A using directive is not qualified.

* Fix compiler errors

* Fix SA1651: Do not use placeholder elements

* Fix compiling error

* Fix SA1113: Comma should be on the same line as previous parameter

* Fix SA1116: The parameters should begin on the line after the declaration, whenever the parameter span across multiple lines

* Fix SA1137: Elements should have the same indentation

* Fix SA1200: Using directive should appear within a namespace declaration

* Fix SA1316: Tuple element names should use correct casing

* Fix SA1503: Braces should not be omitted

* Fix SA1505: An opening brace should not be followed by a blank line

* Fix SA1507: Code should not contain multiple blank lines in a row

* Fix SA1508: A closing brace should not be preceded by a blank line

* Fix SA1512, SA1515

* Fix SA1513: Closing brace should be followed by blank line

* Fix SA1400: Element 'OpenTracingTracer' should declare an access modifier

* Fix SA1515: Single-line comment should be preceded by blank line

* Fix SA1518: File is required to end with a single newline character

* Add StyleCop

* Fix SA1633: A C# code file is missing a standard file header.

* Disable SA1602: An item within a C# enumeration is missing an Xml documentation header.

* Fix SA1600: Elements should be documented

* Fix SA1604: Element documentation should have summary

* Fix SA1618: The documentation for type parameter 'T' is missing

* Fix SA1629: Documentation text should end with a period.

* Fix SA1649: File name should match first type name

* Fix SA1600: Elements should be documented

* Upgrade K8s sample to ASP.NET 7.
Rename project to Ocelot.Samples.OcelotKube.DownstreamService

* Upgrade K8s sample to ASP.NET 7.
Rename project to Ocelot.Samples.OcelotKube.ApiGateway

* Fix CS0169: The field 'xxx' is never used

* Fix CS0219: The variable 'baseUrl' is assigned but its value is never used

* Fix CS0414: The field 'xxx' is assigned but its value is never used

* Fix CS1570: XML comment has badly formed XML

* Fix CS0649: Field 'xxx' is never assigned to, and will always have its default value null

* Fix CS0618: 'member' is obsolete: 'text'

* Fix NU1504: Duplicate 'PackageReference' items found: Microsoft.Data.SQLite 7.0.4, Microsoft.Data.SQLite 7.0.5

* Upgrade sample to ASP.NET 7

* Fix NU5048: The 'PackageIconUrl'/'iconUrl' element is deprecated.
Consider using the 'PackageIcon'/'icon' element instead.
Learn more at https://aka.ms/deprecateIconUrl

* Rewrite a RequestDelegate object definition

* Fix CS0618: 'member' is obsolete: 'text'

* Fix CA1816: Change Dispose() to call GC.SuppressFinalize(object).
This will prevent derived types that introduce a finalizer from needing to re-implement 'IDisposable' to call it.

* Fix CA1822: Member 'GivenThereIsAConfiguration' does not access instance data and can be marked as static

* Fix CA1837: Use 'Environment.ProcessId' instead of 'Process.GetCurrentProcess().Id'

* Fix CA2211: Non-constant fields should not be visible.
Convert to property.

* Fix IDE0060: Remove unused parameter 'path' if it is not part of a shipped public API

* Fix CA1816: Change ConsulWebSocketTests.Dispose() to call GC.SuppressFinalize(object).

* Fix IDE1006: Naming rule violation: These words must begin with upper case characters

* Fix IDE1006: Naming rule violation: These words must begin with upper case characters: AcceptanceTests\WebSocketTests

* Fix last issues

* Upgrade basic sample to ASP.NET 7

* fixed up required spacing in README (#1499)

Co-authored-by: Justin Middler <[email protected]>

* Update README.md

---------

Co-authored-by: TomPallister <[email protected]>
Co-authored-by: Justin Middler <[email protected]>
Co-authored-by: Justin Middler <[email protected]>
Co-authored-by: Tom Pallister <[email protected]>
  • Loading branch information
5 people authored Sep 19, 2023
1 parent fdc761c commit a90664b
Show file tree
Hide file tree
Showing 446 changed files with 5,460 additions and 5,453 deletions.
6 changes: 3 additions & 3 deletions Ocelot.sln
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ocelot.Provider.Kubernetes"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{8FA0CBA0-0338-48EB-B37F-83CA5022237C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OcelotBasic", "samples\OcelotBasic\OcelotBasic.csproj", "{ED0B3A09-112B-4BA4-82D6-11569BC7A99B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ocelot.Samples.OcelotBasic.ApiGateway", "samples\OcelotBasic\Ocelot.Samples.OcelotBasic.ApiGateway.csproj", "{ED0B3A09-112B-4BA4-82D6-11569BC7A99B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdministrationApi", "samples\AdministrationApi\AdministrationApi.csproj", "{B180F8AE-2F8F-44F9-9E5D-FE65B84B742E}"
EndProject
Expand All @@ -64,9 +64,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DownstreamService", "sample
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "k8s", "k8s", "{4B706988-4817-43A8-ABE1-32A67998C2C8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiGateway", "samples\OcelotKube\ApiGateway\ApiGateway.csproj", "{8500055B-2C51-4CF1-A6EE-F05BB3E9BF16}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ocelot.Samples.OcelotKube.ApiGateway", "samples\OcelotKube\ApiGateway\Ocelot.Samples.OcelotKube.ApiGateway.csproj", "{8500055B-2C51-4CF1-A6EE-F05BB3E9BF16}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DownstreamService", "samples\OcelotKube\DownstreamService\DownstreamService.csproj", "{7B319B8C-8155-4779-BD93-5ABD05CA2AB6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ocelot.Samples.OcelotKube.DownstreamService", "samples\OcelotKube\DownstreamService\Ocelot.Samples.OcelotKube.DownstreamService.csproj", "{7B319B8C-8155-4779-BD93-5ABD05CA2AB6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "service-fabric", "service-fabric", "{B412628F-C325-47E1-A8D9-873DE04C8AF5}"
EndProject
Expand Down
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ that need a unified point of entry into their system. However it will work with

In particular I want easy integration with IdentityServer reference and bearer tokens.

We have been unable to find this in my current workplacewithout having to write our own Javascript middlewares to handle the IdentityServer reference tokens. We would rather use the IdentityServer code that already existsto do this.
We have been unable to find this in my current workplace without having to write our own Javascript middlewares to handle the IdentityServer reference tokens. We would rather use the IdentityServer code that already exists to do this.

Ocelot is a bunch of middlewares in a specific order.

Expand Down Expand Up @@ -70,13 +70,3 @@ Pull requests, issues and commentary welcome!
Please complete the relevant template for issues and PRs. Sometimes it's worth getting in touch with us to discuss changes before doing any work incase this is something we are already doing or it might not make sense. We can also give advice on the easiest way to do things :)

Finally we mark all existing issues as help wanted, small, medium and large effort. If you want to contribute for the first time I suggest looking at a help wanted & small effort issue :)

## Donate

If you think this project is worth supporting financially please make a contribution using the button below! We use the money to run the https://threemammals.com website.

[![Support via PayPal](https://cdn.rawgit.com/twolfson/paypal-github-button/1.0.0/dist/button.svg)](https://www.paypal.me/ThreeMammals/)

## Things that are currently annoying me

[![](https://codescene.io/projects/697/status.svg) Get more details at **codescene.io**.](https://codescene.io/projects/697/jobs/latest-successful/results)
18 changes: 15 additions & 3 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Task("RunUnitTests")

GenerateReport(coverageSummaryFile);

if (IsRunningOnCircleCI() && IsMain())
if (IsRunningOnCircleCI() && IsMainOrDevelop())
{
var repoToken = EnvironmentVariable(coverallsRepoToken);
if (string.IsNullOrEmpty(repoToken))
Expand Down Expand Up @@ -555,7 +555,19 @@ private bool IsRunningOnCircleCI()
return !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("CIRCLECI"));
}

private bool IsMain()
private bool IsMainOrDevelop()
{
return Environment.GetEnvironmentVariable("CIRCLE_BRANCH").ToLower() == "main";
var env = Environment.GetEnvironmentVariable("CIRCLE_BRANCH").ToLower();

if(env == "main")
{
return true;
}

if(env == "develop")
{
return true;
}

return false;
}
9 changes: 4 additions & 5 deletions codeanalysis.ruleset
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Rules for StyleCop.Analyzers" Description="Code analysis rules for StyleCop.Analyzers.csproj." ToolsVersion="15.0">
<RuleSet Name="Rules for StyleCop.Analyzers" Description="Code analysis rules for StyleCop.Analyzers.csproj." ToolsVersion="17.0">
<Rules AnalyzerId="AsyncUsageAnalyzers" RuleNamespace="AsyncUsageAnalyzers">
<Rule Id="AvoidAsyncSuffix" Action="None" />
<Rule Id="AvoidAsyncVoid" Action="Error" />
Expand Down Expand Up @@ -50,12 +50,11 @@
<Rule Id="SA1209" Action="None" />
<Rule Id="SA1210" Action="None" />
<Rule Id="SA1214" Action="None" />
<Rule Id="SA1216" Action="None" />
<Rule Id="SA1216" Action="None" />
<Rule Id="SA1300" Action="None" />
<Rule Id="SA1302" Action="Error" />
<Rule Id="SA1303" Action="None" />
<Rule Id="SA1304" Action="Error" />
<Rule Id="SA1305" Action="None" />
<Rule Id="SA1309" Action="None" />
<Rule Id="SA1310" Action="None" />
<Rule Id="SA1311" Action="Error" />
Expand All @@ -70,14 +69,14 @@
<Rule Id="SA1408" Action="None" />
<Rule Id="SA1410" Action="Error" />
<Rule Id="SA1411" Action="Error" />
<Rule Id="SA1412" Action="None" />
<Rule Id="SA1500" Action="None" />
<Rule Id="SA1502" Action="None" />
<Rule Id="SA1516" Action="None" />
<Rule Id="SA1600" Action="None" />
<Rule Id="SA1602" Action="None" />
<Rule Id="SA1603" Action="Error" />
<Rule Id="SA1609" Action="Error" />
<Rule Id="SA1611" Action="None" />
<Rule Id="SA1611" Action="None" />
<Rule Id="SA1623" Action="None" />
<Rule Id="SA1633" Action="None" />
<Rule Id="SA1636" Action="Error" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ocelot" Version="18.0.0" />
<Folder Include="Properties\" />
</ItemGroup>

<ItemGroup>
<Folder Include="Properties\" />
<ProjectReference Include="..\..\src\Ocelot\Ocelot.csproj" />
</ItemGroup>


</Project>
70 changes: 33 additions & 37 deletions samples/OcelotBasic/Program.cs
Original file line number Diff line number Diff line change
@@ -1,44 +1,40 @@
using System.IO;

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;

using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System.IO;

namespace Ocelot.Samples.OcelotBasic.ApiGateway;

namespace OcelotBasic
public class Program
{
public class Program
public static void Main(string[] args)
{
public static void Main(string[] args)
{
new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureAppConfiguration((hostingContext, config) =>
{
config
.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
.AddJsonFile("appsettings.json", true, true)
.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true)
.AddJsonFile("ocelot.json")
.AddEnvironmentVariables();
})
.ConfigureServices(s =>
{
s.AddOcelot();
})
.ConfigureLogging((hostingContext, logging) =>
{
//add your logging
})
.UseIISIntegration()
.Configure(app =>
{
app.UseOcelot().Wait();
})
.Build()
.Run();
}
new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureAppConfiguration((hostingContext, config) =>
{
config
.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
.AddJsonFile("appsettings.json", true, true)
.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true)
.AddJsonFile("ocelot.json")
.AddEnvironmentVariables();
})
.ConfigureLogging((hostingContext, logging) =>
{
if (hostingContext.HostingEnvironment.IsDevelopment())
{
logging.ClearProviders();
logging.AddConsole();
}
//add your logging
})
.UseIISIntegration()
.UseStartup<Startup>()
.Build()
.Run();
}
}
6 changes: 4 additions & 2 deletions samples/OcelotBasic/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "posts/1",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"OcelotBasic": {
"ApiGateway": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "posts/1",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}
}
30 changes: 30 additions & 0 deletions samples/OcelotBasic/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;

namespace Ocelot.Samples.OcelotBasic.ApiGateway;

public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddOcelot();
services.AddLogging();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseOcelot().Wait();
}
}
8 changes: 5 additions & 3 deletions samples/OcelotBasic/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
"Default": "Debug",
"Microsoft": "Information",
"Microsoft.AspNetCore": "Information",
"Microsoft.Hosting.Lifetime": "Information",
"System": "Information"
}
}
}
4 changes: 1 addition & 3 deletions samples/OcelotBasic/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
"Default": "Warning"
}
},
"AllowedHosts": "*"
Expand Down
2 changes: 1 addition & 1 deletion samples/OcelotBasic/ocelot.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
"GlobalConfiguration": {
"BaseUrl": "https://localhost:5000"
}
}
}
13 changes: 6 additions & 7 deletions samples/OcelotEureka/ApiGateway/Program.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using Ocelot.Provider.Eureka;
using Ocelot.Provider.Polly;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;

using Ocelot.DependencyInjection;
using Ocelot.Middleware;

namespace ApiGateway
{
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;

using Ocelot.DependencyInjection;
using Ocelot.Middleware;

public class Program
{
public static void Main(string[] args)
Expand Down
8 changes: 3 additions & 5 deletions samples/OcelotEureka/DownstreamService/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

using Steeltoe.Discovery.Client;

namespace DownstreamService
{
using Microsoft.Extensions.Hosting;

using Steeltoe.Discovery.Client;

public class Startup
{
public Startup(IConfiguration configuration)
Expand All @@ -34,7 +33,6 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
}

app.UseDiscoveryClient();
app.UseMvc();
}
}
}
17 changes: 9 additions & 8 deletions samples/OcelotKube/ApiGateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
FROM mcr.microsoft.com/dotnet/core/aspnet:2.1-stretch-slim AS base
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:2.1-stretch AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["ApiGateway/ApiGateway.csproj", "ApiGateway/"]
RUN dotnet restore "ApiGateway/ApiGateway.csproj"
COPY ["ApiGateway/Ocelot.Samples.OcelotKube.ApiGateway.csproj", "ApiGateway/"]
RUN dotnet restore "ApiGateway/Ocelot.Samples.OcelotKube.ApiGateway.csproj"
COPY . .
WORKDIR "/src/ApiGateway"
RUN dotnet build "ApiGateway.csproj" -c Release -o /app
RUN dotnet build "Ocelot.Samples.OcelotKube.ApiGateway.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "ApiGateway.csproj" -c Release -o /app
RUN dotnet publish "Ocelot.Samples.OcelotKube.ApiGateway.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "ApiGateway.dll"]
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Ocelot.Samples.OcelotKube.ApiGateway.dll"]
Loading

0 comments on commit a90664b

Please sign in to comment.