diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9872c7932..6eeff9eb3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,9 @@ name: Release on: push: - branches: [ "release/24.0" ] # main + branches: + - main + #- 'release/24.0' env: WORKFLOW_VAR: Release # ${{ vars.WORKFLOW_VAR }} jobs: diff --git a/.readthedocs.yaml b/.readthedocs.yaml index e495fe279..18aa68cef 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -9,7 +9,7 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "3.11" + python: "3.12" # You can also specify other tool versions: # nodejs: "19" # rust: "1.64" diff --git a/LICENSE.md b/LICENSE.md index e4ad3be15..3a0b5c459 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,8 +1,19 @@ The MIT License (MIT) Copyright © 2016-2025 Tom Gardham-Pallister, Raman Maksimchuk and contributors. -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMP- +LIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index b80594463..f4163fe09 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ ![Ocelot Logo](https://raw.githubusercontent.com/ThreeMammals/Ocelot/refs/heads/assets/images/ocelot_logo.png) -[![develop Status](https://github.com/ThreeMammals/Ocelot/actions/workflows/develop.yml/badge.svg)](https://github.com/ThreeMammals/Ocelot/actions/workflows/develop.yml) -[![ReadTheDocs Status](https://readthedocs.org/projects/ocelot/badge/?version=develop&style=flat-default)](https://app.readthedocs.org/projects/ocelot/builds/?version__slug=develop) -[![Coveralls Status](https://coveralls.io/repos/github/ThreeMammals/Ocelot/badge.svg?branch=develop)](https://coveralls.io/github/ThreeMammals/Ocelot?branch=develop) -[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/ThreeMammals/Ocelot/blob/develop/LICENSE.md) -[![NuGet Version](https://img.shields.io/nuget/v/Ocelot.svg)](https://www.nuget.org/packages/Ocelot/) -[![NuGet Downloads](https://img.shields.io/nuget/dt/Ocelot.svg)](https://www.nuget.org/packages/Ocelot/) +[![Release Status](https://github.com/ThreeMammals/Ocelot/actions/workflows/release.yml/badge.svg)](https://github.com/ThreeMammals/Ocelot/actions/workflows/release.yml) +[![Development Status](https://github.com/ThreeMammals/Ocelot/actions/workflows/develop.yml/badge.svg)](https://github.com/ThreeMammals/Ocelot/actions/workflows/develop.yml) +[![ReadTheDocs Status](https://readthedocs.org/projects/ocelot/badge/?version=latest&style=flat-square)](https://app.readthedocs.org/projects/ocelot/builds/?version__slug=latest) +[![Coveralls Status](https://coveralls.io/repos/github/ThreeMammals/Ocelot/badge.svg?branch=main)](https://coveralls.io/github/ThreeMammals/Ocelot?branch=main) +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/ThreeMammals/Ocelot/blob/main/LICENSE.md) +[![NuGet](https://img.shields.io/nuget/v/Ocelot?logo=nuget&label=NuGet&color=blue)](https://www.nuget.org/packages/Ocelot/ "Download Ocelot from NuGet.org") +[![Downloads](https://img.shields.io/nuget/dt/Ocelot?logo=nuget&label=Downloads)](https://www.nuget.org/packages/Ocelot/ "Total Ocelot downloads from NuGet.org") ## About Ocelot is a .NET [API gateway](https://www.bing.com/search?q=API+gateway). @@ -74,11 +75,11 @@ You can see what we are working on in the [backlog](https://github.com/ThreeMamm ## Contributing We love to receive contributions from the community, so please keep them coming. -Pull requests, issues, and commentary welcome! octocat +Pull requests, issues, and commentary welcome! octocat Please complete the relevant [template](https://github.com/ThreeMammals/Ocelot/tree/main/.github) for [issues](https://github.com/ThreeMammals/Ocelot/blob/main/.github/ISSUE_TEMPLATE.md) and [pull requests](https://github.com/ThreeMammals/Ocelot/blob/main/.github/PULL_REQUEST_TEMPLATE.md). Sometimes it's worth getting in touch with us to [discuss](https://github.com/ThreeMammals/Ocelot/discussions) changes before doing any work in case 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 octocat +We can also give advice on the easiest way to do things octocat Finally, we mark all existing issues as [![label: help wanted][~helpwanted]](https://github.com/ThreeMammals/Ocelot/labels/help%20wanted) [![label: small effort][~smalleffort]](https://github.com/ThreeMammals/Ocelot/labels/small%20effort) @@ -86,7 +87,7 @@ Finally, we mark all existing issues as [![label: help wanted][~helpwanted]](htt [![label: large effort][~largeeffort]](https://github.com/ThreeMammals/Ocelot/labels/large%20effort). [^6] If you want to contribute for the first time, we suggest looking at a [![label: help wanted][~helpwanted]](https://github.com/ThreeMammals/Ocelot/labels/help%20wanted) [![label: small effort][~smalleffort]](https://github.com/ThreeMammals/Ocelot/labels/small%20effort) -[![label: good first issue][~goodfirstissue]](https://github.com/ThreeMammals/Ocelot/labels/good%20first%20issue) octocat +[![label: good first issue][~goodfirstissue]](https://github.com/ThreeMammals/Ocelot/labels/good%20first%20issue) octocat [~helpwanted]: https://img.shields.io/badge/-help%20wanted-128A0C.svg [~smalleffort]: https://img.shields.io/badge/-small%20effort-fef2c0.svg @@ -96,8 +97,8 @@ If you want to contribute for the first time, we suggest looking at a [![label: ### Notes [^1]: Ocelot does not directly support [GraphQL](https://graphql.org/). Developers can easily integrate the [GraphQL for .NET](https://github.com/graphql-dotnet/graphql-dotnet) library. -[^2]: Ocelot supports [Consul](https://www.consul.io/), [Netflix Eureka](https://www.nuget.org/packages/Steeltoe.Discovery.Eureka), [Service Fabric](https://azure.microsoft.com/en-us/products/service-fabric/) service discovery providers, as well as special modes like [Dynamic Routing](/ThreeMammals/Ocelot/blob/main/docs/features/servicediscovery.rst#dynamic-routing) and [Custom Providers](/ThreeMammals/Ocelot/blob/main/docs/features/servicediscovery.rst#custom-providers). -[^3]: Retry policies only via [Polly](/App-vNext/Polly) library. -[^4]: Starting with version [21.0](https://github.com/ThreeMammals/Ocelot/releases/tag/21.0.0), the solution's code base supports [Multitargeting](https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-multitargeting-overview) as SDK-style projects. It should be easier for teams to migrate to the currently supported [.NET 8 and 9](https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core#lifecycle) frameworks. Also, new features will be available for all .NET SDKs that we support via multitargeting. Find out more here: [Target frameworks in SDK-style projects](https://learn.microsoft.com/en-us/dotnet/standard/frameworks) +[^2]: Ocelot supports the following service discovery providers: (**1**) [Consul](https://www.consul.io) through the [Ocelot.Provider.Consul](https://www.nuget.org/packages/Ocelot.Provider.Consul) extension package, (**2**) [Kubernetes](https://kubernetes.io) via the [Ocelot.Provider.Kubernetes](https://www.nuget.org/packages/Ocelot.Provider.Kubernetes) extension package, and (**3**) [Netflix Eureka](https://spring.io/projects/spring-cloud-netflix), which utilizes the [Steeltoe.Discovery.Eureka](https://www.nuget.org/packages/Steeltoe.Discovery.Eureka) package referenced within the [Ocelot.Provider.Eureka](https://www.nuget.org/packages/Ocelot.Provider.Eureka) extension package. Additionally, Ocelot supports (**4**) Azure [Service Fabric](https://azure.microsoft.com/en-us/products/service-fabric/) for service discovery, along with special modes such as [Dynamic Routing](https://ocelot.readthedocs.io/en/latest/features/servicediscovery.html#dynamic-routing) and [Custom Providers](https://ocelot.readthedocs.io/en/latest/features/servicediscovery.html#custom-providers). +[^3]: Retry policies only via [Polly](https://github.com//App-vNext/Polly) library referenced within the [Ocelot.Provider.Polly](https://www.nuget.org/packages/Ocelot.Provider.Polly) extension package. +[^4]: Starting with version [21](https://github.com/ThreeMammals/Ocelot/releases/tag/21.0.0) and higher, the solution's code base supports [Multitargeting](https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-multitargeting-overview) as SDK-style projects. It should be easier for teams to migrate to the currently supported [.NET 8 and 9](https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core#lifecycle) frameworks. Also, new features will be available for all .NET SDKs that we support via multitargeting. Find out more here: [Target frameworks in SDK-style projects](https://learn.microsoft.com/en-us/dotnet/standard/frameworks) [^5]: [Ocelot Guru](https://gurubase.io/g/ocelot) is an unofficial tool to get answers regarding Ocelot: please consider it an advanced search tool. Thus, we have an official [Questions & Answers](https://github.com/ThreeMammals/Ocelot/discussions/categories/q-a) category in the [Discussions](https://github.com/ThreeMammals/Ocelot/discussions) space. [^6]: See all [labels](https://github.com/ThreeMammals/Ocelot/issues/labels) for the repository, which are useful for searching and filtering. diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 5f0ea652b..669380160 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1 +1,57 @@ -## Technical Release +## Upgrade to .NET 9 (TFM `net9.0`, version 24.0) aka [.NET 9](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) release +> Milestone: [.NET 9](https://github.com/ThreeMammals/Ocelot/milestone/11) +> Codenamed: [.NET 9](https://devblogs.microsoft.com/dotnet/announcing-dotnet-9/) +> Read the Docs: [Ocelot 24.0](https://ocelot.readthedocs.io/en/{0}/) with [PDF](https://ocelot.readthedocs.io/_/downloads/en/{0}/pdf/) +> Target Framework Monikers: `net8.0`, `net9.0` + +### :information_source: About +On November 12th, 2024, the [.NET team](https://devblogs.microsoft.com/dotnet/author/dotnet) announced the release of the [.NET 9](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) framework: + +* .NET Blog: [Announcing .NET 9](https://devblogs.microsoft.com/dotnet/announcing-dotnet-9/) + +This major release upgrades [Ocelot](https://www.nuget.org/packages/Ocelot) package [TFMs](https://learn.microsoft.com/en-us/dotnet/standard/frameworks#latest-versions) to `net9.0` in addition to the current `net8.0`. Thus, the current Ocelot [supported frameworks](https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core#lifecycle) are .NET 8 LTS and .NET 9 STS. According to the [.NET Support Policy](https://dotnet.microsoft.com/en-us/platform/support/policy), the Ocelot team has discontinued support of .NET 6 and .NET 7 by providing the version [23.4.3](https://github.com/ThreeMammals/Ocelot/releases/tag/23.4.3) which targets those .NET versions. + +### :new: What's New? + +- [DevOps](https://github.com/ThreeMammals/Ocelot/labels/DevOps): The CI/CD infrastructure was migrated from CircleCI to GitHub Actions by @raman-m. + + #### Official Notice to the Community Regarding CircleCI + + Ocelot's previous CI/CD provider, [CircleCI](https://circleci.com/), facilitated professional and seamless development, build processes, and delivery of Ocelot versions for seven years, starting in [March 2018](https://github.com/ThreeMammals/Ocelot/pull/283). But last year, in January 2025, after patching Ocelot with version [23.4.3](https://github.com/ThreeMammals/Ocelot/releases/tag/23.4.3), our team encountered legal issues related to [CircleCI](https://circleci.com/) Co's policies, leading to this CI/CD provider stopping the build process for the [Ocelot project](https://app.circleci.com/pipelines/github/ThreeMammals/Ocelot). This legal issue and technical incident were unforeseen on our part because Ocelot is _open-source software_ (OSS), and forcibly stopping the project's build process and blocking accounts appears to be an unfortunate breach of OSS principles. We strongly believe that any developer or user, from any country, should be able to use software providers that support the OSS movement by offering free or other cost-free plans and serving the accounts of these users, OSS teams, and OSS projects 24/7, 365 days a year. We consider this legal issue and the resulting technical incidents involving CircleCI to be a serious breach of OSS principles and an act of discrimination against Ocelot users, developers, and customers who rely on Ocelot OSS, ultimately causing delays to the current release. **As a team, we do not recommend using CircleCI for OSS projects**, as there is no guarantee that these projects will not face discrimination from this U.S. company. + + For all developers, team leads, architects, and managers of any OSS projects—at least on GitHub—we recommend utilizing the built-in GitHub Actions CI/CD infrastructure. Since its founding, GitHub has supported OSS projects. Today, GitHub provides 2,000 minutes of free CI/CD build time per month for OSS repositories (public repos). Also, we strongly believe that GitHub will never violate its OSS policies without a notice period, nor fail to inform owners and maintainers that certain policies must be met by Ocelot's owners. In addition, we want to acknowledge that we are monitoring U.S. government regulations. Unfortunately, we must state that some GitHub products are unavailable in certain countries, even if the project is OSS and GitHub claims these products are free for OSS. Since the Ocelot team does not utilize these non-critical products (we prefer to energize our brains rather than rely on AI-driven products), and since the Ocelot project is currently well-served by GitHub Co, the Ocelot team affirms that Ocelot will remain on GitHub as long as its OSS-friendly policies continue. As a team, we hope that GitHub will never enforce extra rules on our project or other OSS projects. + Regardless, we remain on GitHub! + + #### Technical Information + + Starting from version [24.0](https://github.com/ThreeMammals/Ocelot/releases/tag/{0}), all pull requests, development commits, and releases will be built using [GitHub Actions](https://docs.github.com/en/actions) workflows. We currently have [three workflows](https://github.com/ThreeMammals/Ocelot/tree/main/.github/workflows): one for pull requests ([PR](https://github.com/ThreeMammals/Ocelot/blob/main/.github/workflows/pr.yml)), one for the `develop` branch ([Develop](https://github.com/ThreeMammals/Ocelot/blob/main/.github/workflows/develop.yml)), and one for the `main` branch ([Release](https://github.com/ThreeMammals/Ocelot/blob/main/.github/workflows/release.yml)). + + The [PR](https://github.com/ThreeMammals/Ocelot/blob/main/.github/workflows/pr.yml) workflow will track code coverage using [Coveralls](https://coveralls.io/). After opening a pull request or submitting a new commit to a pull request, [Coveralls](https://coveralls.io) will publish a short message with the current code coverage once the top commit is built. Considering that [Coveralls](https://coveralls.io) retains the entire history but does not fail the build if coverage falls below the threshold, all workflows have a built-in 80% threshold, applied internally within the `build-cake` job, particularly during the "Cake Build" step-action. If the code coverage of a newly opened pull request drops below the 80% threshold, the `build-cake` job will fail, logging an appropriate message in the "Cake Build" step. For your information, the current code coverage of the Ocelot project is around 85-86%. The coverage threshold is subject to change in upcoming releases. All Coveralls builds can be viewed by navigating to the [ThreeMammals/Ocelot](https://coveralls.io/github/ThreeMammals/Ocelot) project on Coveralls.io. + +### :up: What's Updated? + +- **[Core](https://github.com/ThreeMammals/Ocelot/labels/Core)**: + The main [Ocelot](https://www.nuget.org/packages/Ocelot) package and all [extension](https://www.nuget.org/profiles/ThreeMammals) packages [reference](https://github.com/search?q=repo%3AThreeMammals%2FOcelot%20%3CTargetFrameworks%3E&type=code) `net8.0` and `net9.0` target framework monikers (TFMs). Refer to [TargetFrameworks](https://github.com/search?q=repo%3AThreeMammals%2FOcelot%20%3CTargetFrameworks%3E&type=code) to verify this. The `net6.0` and `net7.0` TFMs have been removed. If your project still relies on these outdated TFMs, please continue using version [23.4.3](https://github.com/ThreeMammals/Ocelot/releases/tag/23.4.3). + +- **[Authentication](https://ocelot.readthedocs.io/en/{0}/features/authentication.html)**: + Testing of [Identity Server Bearer Tokens](https://ocelot.readthedocs.io/en/{0}/features/authentication.html#identity-server-bearer-tokens) functionality was stopped due to [vulnerabilities](https://github.com/ThreeMammals/Ocelot/security/dependabot) reported by Dependabot, specifically the "[IdentityServer Open Redirect vulnerability](https://github.com/ThreeMammals/Ocelot/security/dependabot?q=is%3Aclosed+IdentityServer)" security issue. More technical details were provided in the [23.4.3](https://github.com/ThreeMammals/Ocelot/releases/tag/23.4.3) release notes, where we notified the community. Ultimately, issue #2218 was addressed via pull request #2274. + >**Note**: In upcoming releases, we plan to utilize the [ASP.NET Core Identity](https://learn.microsoft.com/en-us/aspnet/core/security/authentication/identity) framework in our [acceptance testing](https://github.com/ThreeMammals/Ocelot/tree/main/test/Ocelot.AcceptanceTests) project to align with .NET industry standards. As a result, we intend to replace the [IdentityServer4](https://github.com/DuendeArchive/IdentityServer4) library with [ASP.NET Core Identity](https://learn.microsoft.com/en-us/aspnet/core/security/authentication/identity), which also supports Bearer tokens, also known as `JwtBearerHandler` from the [Microsoft.AspNetCore.Authentication.JwtBearer](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authentication.jwtbearer) namespace. + +- **[Administration](https://ocelot.readthedocs.io/en/{0}/features/administration.html)**: + The [Ocelot.Administration](https://www.nuget.org/packages/Ocelot.Administration) extension package has been renamed to [Ocelot.Administration.IdentityServer4](https://github.com/ThreeMammals/Ocelot.Administration.IdentityServer4) (it is scheduled for deprecation) to address all [IdentityServer4](https://github.com/DuendeArchive/IdentityServer4)-related [vulnerabilities](https://github.com/ThreeMammals/Ocelot/security/dependabot) (issue #2218). The [package's source code](https://github.com/ThreeMammals/Ocelot/tree/release/23.4/src/Ocelot.Administration) has been moved out of the Ocelot repository (pull request #2274) and transferred to the newly created [Ocelot.Administration.IdentityServer4](https://github.com/ThreeMammals/Ocelot.Administration.IdentityServer4) repository. + >**Note**: Currently, the [Administration](https://ocelot.readthedocs.io/en/{0}/features/administration.html) feature is solely based on the [IdentityServer4 package](https://github.com/ThreeMammals/Ocelot/blob/release/23.4/src/Ocelot.Administration/Ocelot.Administration.csproj#L38), whose [repository](https://github.com/IdentityServer/IdentityServer4) was archived by its owner on July 31, 2024. The Ocelot team will deprecate the new [Ocelot.Administration.IdentityServer4](https://github.com/ThreeMammals/Ocelot.Administration.IdentityServer4) extension package after the current Ocelot release; however, the repository will not be archived, allowing for potential patches in the future. + +- **[Kubernetes](https://ocelot.readthedocs.io/en/{0}/features/kubernetes.html)**: + 1. Answered question #2256 on "How to provide a host to the Kubernetes service discovery provider?" + Unfortunately, in the [Kubernetes](https://ocelot.readthedocs.io/en/{0}/features/kubernetes.html) chapter, it was unclear to users how to define a K8s endpoint host in the [Configuration](https://ocelot.readthedocs.io/en/{0}/features/kubernetes.html#configuration) due to the implicit reuse of `KubeClient`, which is created from the pod account during [Install](https://ocelot.readthedocs.io/en/{0}/features/kubernetes.html#install)-ation. As a team, we decided to add the new [AddKubernetes(Action<KubeClientOptions>) method](https://ocelot.readthedocs.io/en/{0}/features/kubernetes.html#addkubernetes-action-kubeclientoptions-method), which handles different user scenarios. It is now possible to provide manually configured `KubeClientOptions` in C# during [Install](https://ocelot.readthedocs.io/en/{0}/features/kubernetes.html#install)-ation, but users can also reuse `ServiceDiscoveryProvider` options from the global [configuration](https://ocelot.readthedocs.io/en/{0}/features/kubernetes.html#configuration), including the `Host` option to construct the [kubernetes](https://ocelot.readthedocs.io/en/{0}/features/kubernetes.html) endpoint address. The new overloaded `AddKubernetes(Action)` method was implemented in pull request #2257. + 2. In the [Ocelot.Provider.Kubernetes](https://www.nuget.org/packages/Ocelot.Provider.Kubernetes/) extension package, the `KubeClient` dependency library version was upgraded to `3.0.x`, which requires .NET 8.0 and .NET 9.0 TFMs for the current Ocelot version [24.0](https://github.com/ThreeMammals/Ocelot/releases/tag/24.0.0). `KubeClient` v3 was internally reviewed and released specifically to meet Ocelot's needs for this release. Thanks to Adam Friedman (@tintoy) for his collaboration! This package upgrade was implemented in pull request #2266. + +- **[Sample](https://github.com/ThreeMammals/Ocelot/labels/sample)**: + The learning [Samples](https://github.com/ThreeMammals/Ocelot/tree/main/samples) projects were reviewed, rewritten, and refactored due to issue #1912. The community brought to our attention that the documentation and [samples](https://github.com/ThreeMammals/Ocelot/tree/main/samples) were outdated, as .NET 8 allows the `Program.cs` file to be minimized using the "[Top-level statements](https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/program-structure/top-level-statements)" feature. This was ultimately addressed in pull requests #2244 and #2258. + +### :notebook: Documentation Summary +Due to the major version increase to v24, all documentation chapters were reviewed to improve readability, eliminate ambiguity, provide more useful tables and data schemas, update code snippets with the syntax of [Top-level statements](https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/program-structure/top-level-statements), and add handy samples, among other enhancements. The entire documentation is designed to be truly professional for senior developers while remaining easy to read for junior developers and newcomers who are starting to use the Ocelot gateway. + +We believe that Ocelot students will ask fewer questions in 2025 :wink: +For students, we always recommend finding answers in [Q&A](https://github.com/ThreeMammals/Ocelot/discussions/categories/q-a) category first. Honestly, it is advised to read existing discussions before opening a new question in repo [discussions](https://github.com/ThreeMammals/Ocelot/discussions). +For true Ocelot patriots, we have added a [README link](https://github.com/ThreeMammals/Ocelot?tab=readme-ov-file#documentation) to the smart [Ocelot AI Guru](https://gurubase.io/g/ocelot) assistant, which is always ready to answer any of your questions. Feel free to explore and interact with it! :blush: diff --git a/build.cake b/build.cake index fcbbb2ed8..c2008f91a 100644 --- a/build.cake +++ b/build.cake @@ -14,7 +14,7 @@ using System.IO; using System.Linq; using System.Text.RegularExpressions; -const bool IsTechnicalRelease = false; +bool IsTechnicalRelease = false; const string Release = "Release"; // task name, target, and Release config name const string PullRequest = "PullRequest"; // task name, target, and PullRequest config name const string AllFrameworks = "net8.0;net9.0"; @@ -277,7 +277,7 @@ Task("CreateReleaseNotes") var place = Place(log.Count); return HonorForDeletions(place, contributor.Contributor, group.Commits, contributor.Files, contributor.Insertions, contributor.Deletions); }); - Information("---==< TOP Contributors >==---"); + Information("------==< TOP Contributors >==------"); Information(string.Join(NL, topContributors)); // local helpers @@ -392,20 +392,20 @@ Task("CreateReleaseNotes") } return log; } // END of IterateCommits - // releaseNotes.Add("### Honoring :medal_sports: aka Top Contributors :clap:"); - // releaseNotes.AddRange(topContributors.Take(3)); // Top 3 only, disabled 'breaker' logic - // releaseNotes.Add(""); - // releaseNotes.Add("### Starring :star: aka Release Influencers :bowtie:"); - // releaseNotes.AddRange(starring); - // releaseNotes.Add(""); - // releaseNotes.Add($"### Features in Release {releaseVersion}"); - // releaseNotes.Add(""); - // releaseNotes.Add("
Logbook"); - // releaseNotes.Add(""); - // var commitsHistory = GitHelper($"log --no-merges --date=format:\"%A, %B %d at %H:%M\" --pretty=format:\"- %h by **%aN** on %ad →%n %s\" {lastRelease}..HEAD"); - // releaseNotes.AddRange(commitsHistory); - // releaseNotes.Add("
"); - // releaseNotes.Add(""); + releaseNotes.Add("### Honoring :medal_sports: aka Top Contributors :clap:"); + releaseNotes.AddRange(topContributors.Take(3)); // Top 3 only, disabled 'breaker' logic + releaseNotes.Add(""); + releaseNotes.Add("### Starring :star: aka Release Influencers :bowtie:"); + releaseNotes.AddRange(starring); + releaseNotes.Add(""); + releaseNotes.Add($"### Features in Release {releaseVersion}"); + releaseNotes.Add(""); + releaseNotes.Add("
Logbook"); + releaseNotes.Add(""); + var commitsHistory = GitHelper($"log --no-merges --date=format:\"%A, %B %d at %H:%M\" --pretty=format:\"- %h by **%aN** on %ad →%n %s\" {lastRelease}..HEAD"); + releaseNotes.AddRange(commitsHistory); + releaseNotes.Add("
"); + releaseNotes.Add(""); WriteReleaseNotes(); }); @@ -651,11 +651,11 @@ Task("PublishGitHubRelease") .IsDependentOn("CreateArtifacts") .Does(() => { - // if (!IsRunningInCICD()) - // { - // Warning("We are not running on the CI/CD so we won't publish a GitHub release"); - // return; - // } + if (!IsRunningInCICD()) + { + Warning("We are not running on the CI/CD so we won't publish a GitHub release"); + return; + } dynamic release = CreateGitHubRelease(); var path = packagesDir.ToString() + @"/**/*Ocelot.*"; // filter out artifacts.txt and ReleaseNotes.md @@ -718,14 +718,17 @@ Task("PublishToNuget") return; } - // if (IsRunningInCICD()) - // { - // stable releases + if (IsRunningInCICD()) + { var nugetFeedStableKey = EnvironmentVariable("OCELOT_NUGET_API_KEY_2025"); var nugetFeedStableUploadUrl = "https://www.nuget.org/api/v2/package"; var nugetFeedStableSymbolsUploadUrl = "https://www.nuget.org/api/v2/package"; PublishPackages(packagesDir, artifactsFile, nugetFeedStableKey, nugetFeedStableUploadUrl, nugetFeedStableSymbolsUploadUrl); - // } + } + else + { + Warning("We are not running on the CI/CD so we won't publish NuGet packages."); + } }); Task("Void").Does(() => {}); diff --git a/docs/building/building.rst b/docs/building/building.rst new file mode 100644 index 000000000..c4280c71c --- /dev/null +++ b/docs/building/building.rst @@ -0,0 +1,260 @@ +.. _Ocelot: https://github.com/ThreeMammals/Ocelot +.. _Cake: https://cakebuild.net +.. _Bash: https://www.gnu.org/software/bash +.. _build.cake: https://github.com/ThreeMammals/Ocelot/blob/main/build.cake +.. _GitHub Actions: https://docs.github.com/en/actions +.. _NuGet: https://www.nuget.org/profiles/ThreeMammals + +Building +======== + +This document summarises the build and release process for the `Ocelot`_ project. +The build scripts are written using `Cake`_ (C# Make), with relevant build tasks defined in the '`build.cake`_' file located in the root of the `Ocelot`_ project. +The scripts are designed to be run by developers locally in a `Bash`_ terminal (on any OS), in Command Prompt (CMD) or PowerShell consoles (on Windows OS), +or by a CI/CD server (currently `GitHub Actions`_), with minimal logic defined in the build server itself. + +The final goal of the build process is to create ``Ocelot.*`` `NuGet`_ packages (.nupkg files) for redistribution via the `NuGet`_ repository or manually. +The build process consists of several steps: (1) compilation, (2) testing, (3) creating and publishing `NuGet`_ packages, and (4) making an official GitHub release. +The build process requires pre-installed .NET SDKs on the build machine (host) for all target framework monikers: TFMs are ``net8.0`` and ``net9.0`` currently. +In general, the build process is the same across all environments and tools, with a few differences described below. + +.. _b-in-ide: + +In IDE +------ +.. _Release configuration: https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-set-debug-and-release-configurations?view=vs-2022 + +In an IDE, a DevOps engineer can build the project in Visual Studio IDE or another IDE in `Release configuration`_ mode, but the latest .NET 8/9 SDKs must be pre-installed on the local machine. +However, this approach is not practical because the generated '.nupkg' files must be uploaded to `NuGet`_ manually, and the GitHub release must also be created manually. +A better approach is to utilize the '`build.cake`_' script :ref:`b-in-terminal`, which covers all building scenarios. + +.. _b-in-terminal: + +In terminal +----------- +.. _./: https://github.com/ThreeMammals/Ocelot/tree/main/ + + Folder: `./`_ + +These are local machine or remote server building scenarios using build scripts, aka '`build.cake`_'. +In these scenarios, the following two commands should be run in a terminal from the project's root folder: + +.. code-block:: shell + + dotnet tool restore && dotnet cake # In Bash terminal + dotnet tool restore; dotnet cake # In PowerShell terminal + +.. _break: http://break.do + + **Note**: The default target task ("Default") is "Build", and output files will be stored in the ``./artifacts`` directory. + +To run a desired target task, you need to specify its *name*: + +.. code-block:: shell + + dotnet tool restore && dotnet cake --target=name # In Bash terminal + dotnet tool restore; dotnet cake --target=name # In PowerShell terminal + +For example, + +- .. code-block:: shell + + dotnet cake --target=Build + + It runs a local build, performing compilation and testing only. + +- .. code-block:: shell + + dotnet cake --target=Version + + It checks the next version to be tagged in the Git repository during the next release, without performing compilation or testing tasks. + +- .. code-block:: shell + + dotnet cake --target=CreateReleaseNotes + + It generates Release Notes artifacts in the ``/artifacts/Packages`` folder using the ``ReleaseNotes.md`` template file. + +- .. code-block:: shell + + dotnet cake --target=Release + + It creates a release, consisting of the following steps: compilation, testing, generating release notes, creating .nupkg files, publishing `NuGet`_ packages, and finally, making a GitHub release. + +.. _dotnet-tools.json: https://github.com/ThreeMammals/Ocelot/blob/main/.config/dotnet-tools.json + + **Note 1**: The building tools for the ``dotnet tool restore`` command are configured in the `dotnet-tools.json`_ file. + + **Note 2**: Some targets (build tasks) require appropriate environment variables to be defined directly in the terminal session (aka secret tokens). + +.. _b-with-docker: + +With Docker +----------- +.. _docker: https://github.com/ThreeMammals/Ocelot/tree/main/docker +.. _Dockerfile.build: https://github.com/ThreeMammals/Ocelot/blob/main/docker/Dockerfile.build +.. _24.0: https://github.com/ThreeMammals/Ocelot/releases/tag/24.0.0 + + Folder: ./`docker`_ + +The best way to replicate the CI/CD process and build `Ocelot`_ locally is by using the `Dockerfile.build`_ file, which can be found in the '`docker`_' folder in the `Ocelot`_ root directory. +For example, use the following command: + +.. code-block:: shell + + docker build --platform linux/amd64 -f ./docker/Dockerfile.build . + +You may need to adjust the platform flag depending on your system. + + **Note**: This approach is somewhat excessive, but it will work if you are a masterful Docker user. 🙂 + The Ocelot team has not followed this approach since version `24.0`_, favoring :ref:`b-with-ci-cd`-based builds and occasionally building :ref:`b-in-terminal` instead. + +.. _b-with-ci-cd: + +With CI/CD +---------- +.. _workflows: https://github.com/ThreeMammals/Ocelot/tree/main/.github/workflows +.. _PR: https://github.com/ThreeMammals/Ocelot/blob/main/.github/workflows/pr.yml +.. _Develop: https://github.com/ThreeMammals/Ocelot/blob/main/.github/workflows/develop.yml +.. _Release: https://github.com/ThreeMammals/Ocelot/blob/main/.github/workflows/release.yml +.. _Coveralls: https://coveralls.io +.. |ReleaseButton| image:: https://github.com/ThreeMammals/Ocelot/actions/workflows/release.yml/badge.svg + :target: https://github.com/ThreeMammals/Ocelot/actions/workflows/release.yml + :alt: Release Status +.. |DevelopButton| image:: https://github.com/ThreeMammals/Ocelot/actions/workflows/develop.yml/badge.svg + :target: https://github.com/ThreeMammals/Ocelot/actions/workflows/develop.yml + :alt: Development Status +.. |DevelopCoveralls| image:: https://coveralls.io/repos/github/ThreeMammals/Ocelot/badge.svg?branch=develop + :target: https://coveralls.io/github/ThreeMammals/Ocelot?branch=develop + :alt: Coveralls Status +.. |ReleaseCoveralls| image:: https://coveralls.io/repos/github/ThreeMammals/Ocelot/badge.svg?branch=main + :target: https://coveralls.io/github/ThreeMammals/Ocelot?branch=main + :alt: Coveralls Status +.. _break2: http://break.do + + | Folder: ./.github/`workflows`_ + | Provider: `GitHub Actions`_ + | Workflows: `PR`_, `Develop`_, `Release`_ + | Dashboard: `Workflow runs `_ (Actions tab) + +The `Ocelot`_ project utilizes `GitHub Actions`_ as a CI/CD provider, offering seamless integrations with the GitHub ecosystem and APIs. +Starting from version `24.0`_, all pull requests, development commits, and releases are built using `GitHub Actions`_ workflows. +There are three `workflows`_: one for pull requests (`PR`_), one for the ``develop`` branch (`Develop`_), and one for the ``main`` branch (`Release`_). + + **Note**: Each workflow has a dedicated status badge in the `Ocelot README`_: + the `Release`_ |ReleaseButton| button and the `Develop`_ |DevelopButton| button, with the `PR`_ status being published directly in a pull request under the "Checks" tab. + +The `PR`_ workflow will track code coverage using `Coveralls`_. +After opening a pull request or submitting a new commit to a pull request, `Coveralls`_ will publish a short message with the current code coverage once the top commit is built. +Considering that `Coveralls`_ retains the entire history but does not fail the build if coverage falls below the threshold, all workflows have a built-in 80% threshold, +applied internally within the ``build-cake`` job, particularly during the "`Cake Build`_" step-action. +If the code coverage of a newly opened pull request drops below the 80% threshold, the `'build-cake' job`_ will fail, logging an appropriate message in the "`Cake Build`_" step. + + **Note 1**: There are special code coverage badges in `Ocelot README`_: the `Develop`_ |DevelopCoveralls| button and the `Release`_ |ReleaseCoveralls| button. + + **Note 2**: The current code coverage of the `Ocelot`_ project is around 85-86%. The coverage threshold is subject to change in upcoming releases. + All `Coveralls`_ builds can be viewed by navigating to the `ThreeMammals/Ocelot `_ project on Coveralls.io. + +Documentation +------------- +.. _docs: https://github.com/ThreeMammals/Ocelot/tree/main/docs +.. _.readthedocs.yaml: https://github.com/ThreeMammals/Ocelot/blob/main/.readthedocs.yaml +.. _Read the Docs: https://about.readthedocs.com +.. _Ocelot app: https://app.readthedocs.org/projects/ocelot/ +.. _README: https://github.com/ThreeMammals/Ocelot/blob/main/docs/readme.md +.. _Ocelot README: https://github.com/ThreeMammals/Ocelot/blob/main/README.md +.. |ReleaseDocs| image:: https://readthedocs.org/projects/ocelot/badge/?version=latest&style=flat-square + :target: https://app.readthedocs.org/projects/ocelot/builds/?version__slug=latest + :alt: ReadTheDocs Status +.. |DevelopDocs| image:: https://readthedocs.org/projects/ocelot/badge/?version=develop&style=flat-square + :target: https://app.readthedocs.org/projects/ocelot/builds/?version__slug=develop + :alt: ReadTheDocs Status +.. _break3: http://break.do + + | Folder: ./`docs`_ + | Dashboard: `Ocelot app`_ project + +Documentation building is configured using the '`.readthedocs.yaml`_' integration file, which allows builds to run separately via the `Read the Docs`_ publisher. +All build artifacts and document sources are located in the '`docs`_' folder. +More details on the documentation build process can be found in the `README`_. + + **Note 1**: Documentation builds have a dedicated status badges in `Ocelot README`_: the `Develop`_ |DevelopDocs| button and the `Release`_ |ReleaseDocs| button. + + **Note**: Documentation can be easily built locally in a terminal from the '`docs`_' folder by running the ``make.sh`` or ``make.bat`` scripts. + The resulting documentation build files will be located in the ``./docs/_build`` folder, with the HTML documentation specifically written to the ``./docs/_build/html`` folder. + +.. _b-testing: + +Testing +------- + +The tests should run and function correctly as part of the *building* process using the ``dotnet test`` command. +You can also run them in Visual Studio IDE within the Test Explorer window. +Depending on your build scenario, `Ocelot`_ *testing* can be performed as follows. + +:ref:`b-in-ide`: Simply run tests via the Test Explorer window of Visual Studio IDE. + +:ref:`b-in-terminal`: There are two main approaches: + +1. Run the ``dotnet test`` command to perform all tests (unit, integration, and acceptance): + + .. code-block:: shell + + dotnet test -f net8.0 ./Ocelot.sln + + Or run tests separately per project: + + .. code-block:: shell + + dotnet test -f net8.0 ./test/Ocelot.UnitTests/Ocelot.UnitTests.csproj # Unit tests only + dotnet test -f net8.0 ./test/Ocelot.IntegrationTests/Ocelot.IntegrationTests.csproj # Integration tests only + dotnet test -f net8.0 ./test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.csproj # Acceptance tests only + +2. Run ``dotnet cake`` command: ``dotnet cake --target=Tests`` to perform all tests (unit, integration and acceptance). + Or run tests separately per *testing* project: + + .. code-block:: shell + + dotnet cake --target=UnitTests # unit tests only + dotnet cake --target=IntegrationTests # integration tests only + dotnet cake --target=AcceptanceTests # acceptance tests only + +:ref:`b-with-docker`: This approach is not recommended. +Instead, perform automated testing :ref:`b-with-ci-cd` or opt for :ref:`b-in-terminal`-based testing, which is a more advanced method. + +:ref:`b-with-ci-cd`: In `GitHub Actions`_ `workflows`_, the *testing* process consists of separate testing steps, organized per job: + +* In the `'build' job`_: There are '`Unit Tests`_', '`Integration Tests`_', and '`Acceptance Tests`_' steps. +* In the `'build-cake' job`_: There is a '`Cake Build`_' step responsible for performing tests internally. + +.. _'build' job: https://github.com/search?q=repo%3AThreeMammals%2FOcelot+build%3A+path%3A%2F%5E%5C.github%5C%2Fworkflows%5C%2F%2F&type=code +.. _Unit Tests: https://github.com/search?q=repo%3AThreeMammals%2FOcelot+%22Unit+Tests%22+path%3A%2F%5E%5C.github%5C%2Fworkflows%5C%2F%2F&type=code +.. _Integration Tests: https://github.com/search?q=repo%3AThreeMammals%2FOcelot+%22Integration+Tests%22+path%3A%2F%5E%5C.github%5C%2Fworkflows%5C%2F%2F&type=code +.. _Acceptance Tests: https://github.com/search?q=repo%3AThreeMammals%2FOcelot+%22Acceptance+Tests%22+path%3A%2F%5E%5C.github%5C%2Fworkflows%5C%2F%2F&type=code +.. _'build-cake' job: https://github.com/search?q=repo%3AThreeMammals%2FOcelot+%22-cake%3A%22+path%3A%2F%5E%5C.github%5C%2Fworkflows%5C%2F%2F&type=code +.. _Cake Build: https://github.com/search?q=repo%3AThreeMammals%2FOcelot+%22cake-build%2F%22+path%3A%2F%5E%5C.github%5C%2Fworkflows%5C%2F%2F&type=code + +SSL certificate +--------------- + +To create a certificate for :ref:`b-testing`, you can use `OpenSSL `_: + +* Install the `openssl `__ package (if you are using Windows, download the binaries `here `_). +* Generate a private key: + + .. code-block:: bash + + openssl genrsa 2048 > private.pem + +* Generate a self-signed certificate: + + .. code-block:: bash + + openssl req -x509 -days 1000 -new -key private.pem -out public.pem + +* If needed, create a PFX file: + + .. code-block:: bash + + openssl pkcs12 -export -in public.pem -inkey private.pem -out mycert.pfx + diff --git a/docs/building/devprocess.rst b/docs/building/devprocess.rst index 59070eef0..b07a00cfd 100644 --- a/docs/building/devprocess.rst +++ b/docs/building/devprocess.rst @@ -1,19 +1,35 @@ +.. _Gitflow Workflow: https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow +.. _GitHub Flow: https://docs.github.com/en/get-started/using-github/github-flow +.. _develop: https://github.com/ThreeMammals/Ocelot/tree/develop +.. _main: https://github.com/ThreeMammals/Ocelot/tree/main +.. _issue(s): https://github.com/ThreeMammals/Ocelot/issues +.. _discussion: https://github.com/ThreeMammals/Ocelot/discussions +.. _fork: https://docs.github.com/en/get-started/quickstart/fork-a-repo +.. _unit: https://github.com/ThreeMammals/Ocelot/tree/develop/test/Ocelot.UnitTests +.. _acceptance: https://github.com/ThreeMammals/Ocelot/tree/develop/test/Ocelot.AcceptanceTests +.. _documentation: https://github.com/ThreeMammals/Ocelot/tree/develop/docs +.. _feature: https://github.com/ThreeMammals/Ocelot/tree/develop/docs/features +.. _Actions: https://github.com/ThreeMammals/Ocelot/actions +.. _Coveralls check: https://coveralls.io/github/ThreeMammals/Ocelot + Development Process =================== -* The *development process* is optimized when using Gitflow branching, as detailed here: `Gitflow Workflow `_. - It's important to note that the Ocelot team does not utilize `GitHub Flow `_, which, despite being quicker, does not align with the efficiency required for Ocelot's delivery. -* Contributors are free to manage their pull requests and feature branches as they see fit to contribute to the `develop `_ branch. -* Maintainers have the autonomy to handle pull requests and merges. Any merges to the `main `_ branch will trigger the release of packages to GitHub and NuGet. +* The *development process* is optimized when using Gitflow branching, as detailed here: `Gitflow Workflow`_. + It's important to note that the Ocelot team does not utilize `GitHub Flow`_, which, despite being quicker, does not align with the efficiency required for Ocelot's delivery. +* Contributors are free to manage their pull requests and feature branches as they see fit to contribute to the '`develop`_' branch. +* Maintainers have the autonomy to handle pull requests and merges. Any merges to the '`main`_' branch will trigger the release of packages to GitHub and NuGet. * In conclusion, while users should adhere to the guidelines in :doc:`../building/devprocess`, maintainers should follow the procedures outlined in :doc:`../building/releaseprocess`. -Ocelot project follows this *development process* to integrate work into a merged commit in the `develop`_ branch: +Stages +------ + +Ocelot project follows this *development process* to integrate work into a merged commit in the '`develop`_' branch: -1. Users either create a new issue or select an `existing issue `_ on GitHub. - Issues can also be generated from `discussion `_ topics when necessary and agreed upon. +1. Users either create a new issue or select an existing `issue(s)`_ on GitHub. + Issues can also be generated from `discussion`_ topics when necessary and agreed upon. -2. Users should create `a fork `_ and branch off of it - (unless they are a core team member, in which case they can branch directly from the main/head/upstream repository), e.g., ``feature/xxx``, ``bug/xxx``, etc. +2. Users should create a `fork`_ and branch off of it (unless they are a core team member, in which case they can branch directly from the main/head/upstream repository), e.g., ``feature/xxx``, ``bug/xxx``, etc. The "xxx" can be the issue number or a brief description. 3. Once contributors are satisfied with their work, they can submit a pull request against the `develop`_ branch on GitHub with their changes. @@ -21,8 +37,9 @@ Ocelot project follows this *development process* to integrate work into a merge 4. The Ocelot team will review the pull request and, if satisfactory, merge it; otherwise, they will provide feedback for the contributor to address. To expedite pull request approval, contributors should consider: - - Ensuring all changes are covered by `unit `_ and `acceptance `_ tests. - - Updating any `documentation `_ affected by the changes. + - Ensuring all changes are covered by `unit`_ and `acceptance`_ tests. + - Ensuring that the code coverage percentage from `unit`_ tests does not decrease; thus, the `Coveralls check`_ reports a green status. + - Updating any `documentation`_ affected by the changes, with a required review of the appropriate `feature`_ document. - Verifying that the feature is necessary and does not duplicate existing Ocelot features. 5. A pull request must meet the following criteria before merging: @@ -30,32 +47,62 @@ Ocelot project follows this *development process* to integrate work into a merge - All new code must be covered by `unit`_ tests. - There must be at least one `acceptance`_ test for the happy path of the new code. - Tests must pass locally, in Visual Studio Test Explorer or in terminal after performing ``dotnet test`` command. - - The build must have a green status on CircleCI as passed Checks of the pull request (aka Checks tab). - - The build's performance must not be significantly degraded on `CircleCI Ocelot project `_ main webpage. - - The main Ocelot package must not introduce any non-Microsoft dependencies. + - The build must have a green status on repository `Actions`_ as passed *checks* of the pull request (aka `Checks`_ tab). + - The build's performance must not be significantly degraded on repository `Actions`_ page for `PR`_ workflow. + - The main `Ocelot package`_ must not introduce any non-Microsoft `dependencies`_. + +.. _PR: https://github.com/ThreeMammals/Ocelot/actions/workflows/pr.yml +.. _Checks: https://github.com/ThreeMammals/Ocelot/pull/2283/checks +.. _Ocelot package: https://www.nuget.org/packages/Ocelot +.. _dependencies: https://www.nuget.org/packages/Ocelot#dependencies-body-tab +.. _NuGet packages: https://www.nuget.org/profiles/ThreeMammals -6. Once the pull request is merged into the `develop`_ branch, the Ocelot NuGet packages will not be updated until a release is crafted. - The concluding step involves returning to GitHub to close any resolved issues. - **Note**: Issues linked to the PR within the **Development** settings (on the right sidebar of the PR settings) will automatically close upon merging. - It is crucial for developers to utilize the "**Link an issue from this repository**" feature in the **Development** settings. +6. Once the pull request is merged with *"Squash and Merge"* option into the `develop`_ branch, the ``Ocelot.*`` `NuGet packages`_ will not be updated until a release is crafted. + The concluding step involves returning to GitHub to close any resolved `issue(s)`_. Notes ----- -All pull request builds are conducted with CircleCI. For details, refer to the `Pipelines - ThreeMammals/Ocelot `_ on CircleCI. -It's recommended to monitor the build status. If a build fails, initiate a new build or consult with online maintainers or code reviewers to ensure the current PR build is successful. +**Note 1**: The `issue(s)`_ linked to the pull request within the *Development* settings (on the right sidebar of the pull request settings) will automatically close upon merging. +It is crucial for developers to utilize the *"Link an issue from this repository"* feature in the *Development* settings. +An alternative way to link `issue(s)`_ is by specifying them in the pull request description, where the developer lists the linked `issue(s)`_ that need to be closed. +For example: + +.. code-block:: markdown + + ## Fixes #1222 + - #1222 + + ## Closes #1333 + - #1333 -Should you encounter any confusion or obstacles, do not hesitate to reach out to the members of the 'Ocelot Core Team' or the repository maintainers. + ## Proposed Changes + - change 1 + - change 2 + +This Markdown should automatically link the desired bug/issue in the open status. +For bugs, the developer needs to write "Fixes #xxxx", and for features, "Closes #xxxx". + +.. _GitHub Actions: https://docs.github.com/en/actions +.. _workflows: https://github.com/ThreeMammals/Ocelot/tree/main/.github/workflows + +**Note 2**: All pull request builds are conducted using `GitHub Actions`_, but developers have the freedom to build Ocelot as needed. +Details can be found in the :doc:`../building/building` chapter. +Additionally, for a deeper understanding of the current Ocelot CI/CD environment and a clearer view of the CI/CD build process, refer to the "Building :ref:`b-with-ci-cd`" section. + +**Note 3**: Should you encounter any confusion or obstacles, do not hesitate to reach out to the members of the 'Ocelot Team' or the repository maintainers. .. _dev-best-practices: Best Practices -------------- - +* Refer to the Ocelot `Actions`_ dashboard on GitHub to verify the latest build statuses for the three current `workflows`_. + It is recommended to monitor the build status of each workflow on the `Actions`_ dashboard or directly in the `Checks`_ tab of a pull request. + If a build fails, initiate a new build by pushing a new commit, or consult with online maintainers or code reviewers to ensure the current pull request build is successful. * Request a code review after reaching the "Development Complete" stage, and address all feedback issues. Code is deemed complete when robust code, relevant `unit`_ and `acceptance`_ tests, and `documentation`_ updates are in place. * Set up your development environment on Windows OS using Visual Studio IDE. - While development in Linux OS with alternative IDEs is possible, it is not recommended. For more details, refer to the :ref:`dev-fun` subsection. + While development in Linux OS with alternative IDEs is possible, it is not recommended. For more details, refer to the :ref:`dev-fun` section. * Remain online after submitting a pull request/issue to ensure maintainers can reach you promptly. Note that if you are offline for extended periods, such as days, weeks, or months, maintainers may deprioritize your work. A strong contribution ethic implies constant online presence and proactivity. @@ -67,13 +114,15 @@ Dev Fun This section is part of the :ref:`dev-best-practices` and is written to be more amusing D) -Line-Ending Gotchas aka EOL Fun -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +EOL Gotchas +^^^^^^^^^^^ + + *Also known as, "Line-Endings problem"* - Since the project's inception in 2016, this issue has been persistent. - Indeed, some lines end with the ``LF`` character, typical of the Linux OS. - Many of our contributors work on Linux and use IDEs like Visual Studio Code, which defaults to the ``LF`` as the newline character. - As a result, we have numerous files with inconsistent or mixed EOL characters. + Since the project's inception in 2016, this issue has been persistent. + Indeed, some lines end with the ``LF`` character, typical of the Linux OS. + Many of our contributors work on Linux and use IDEs like Visual Studio Code, JetBrains .NET Rider, which defaults to the ``LF`` as the newline character. + As a result, we have numerous files with inconsistent or mixed EOL characters. This problem stems from the well-known dilemma of End-of-Line (EOL) characters in cross-OS development. For the Windows OS, the EOL character is ``CRLF``, while for Linux, it is ``LF``. @@ -81,7 +130,7 @@ Modern IDEs and Git repositories have their own strategies for detecting inconsi However, the GitHub "Files Changed" tool unfortunately registers a line change in two scenarios: ``CRLF`` to ``LF`` and ``LF`` to ``CRLF``, even when there's no actual code change! Reviewing such pull requests with fictitious ("fake") changes is always challenging because the reviewer's focus should be on actual code changes. - Please note, if a pull request is filled with "fake" changes in **Files Changed**, the code reviewer has the right to not provide a code review, mark the PR as a draft, or even close it. + Please note, if a pull request is filled with "fake" changes in *"Files Changed"*, the code reviewer has the right to not provide a code review, mark the PR as a draft, or even close it. Our standard practice is to maintain end-of-line characters as they are. Moreover, we utilize Visual Studio's unique ``.editorconfig`` IDE analyzer settings for EOL to avoid issues with line endings. @@ -105,3 +154,4 @@ Our current recommendations for addressing the end-of-line (EOL) issue are as fo Therefore, "fake" changes result from auto-refactoring commands in IDEs like Visual Studio, Visual Code, Rider, etc. * **Our final recommendation** is to boot into Windows, use Visual Studio Community (which is free), refrain from using auto-refactoring commands, and ensure that EOLs remain unchanged. + If your OS differs, you **must** ensure that the appropriate settings are provided in the ``.gitattributes`` file to always commit files with ``CRLF`` EOL characters. diff --git a/docs/building/overview.rst b/docs/building/overview.rst deleted file mode 100644 index 70374b236..000000000 --- a/docs/building/overview.rst +++ /dev/null @@ -1,35 +0,0 @@ -Overview -======== - -This document summarises the build and release process for the project. -The build scripts are written using `Cake `_, and they are defined in ``./build.cake``. -The scripts have been designed to be run by either developers locally or by a build server (currently `CircleCi `_), with minimal logic defined in the build server itself. - -Building --------- - -* You can also just run ``dotnet tool restore && dotnet cake`` locally! Output will got to the ``./artifacts`` directory. - -* The best way to replicate the CI process is to build Ocelot locally is using the `Dockerfile.build `_ file - which can be found in the `docker `_ folder in `Ocelot `_ root. - Use the following command ``docker build --platform linux/amd64 -f ./docker/Dockerfile.build .`` for example. You will need to change the platform flag depending on your platform. - -* There is a `Makefile `_ to make it easier to call the various targets in `build.cake `_. - The scripts are called with **.sh** but can be easily changed to **.ps1** if you are using Windows. - -* Alternatively you can build the project in VS2022 with the latest `.NET 8.0 `_ SDK. - -Testing -------- - -The tests should all just run and work as part of the build process. You can of course also run them in Visual Studio. - -Create SSL certificate -^^^^^^^^^^^^^^^^^^^^^^ - -To create a certificate for *testing* we can do this via `OpenSSL `_: - -* Install `openssl package `_ (if you are using Windows, download binaries `here `_). -* Generate private key: ``openssl genrsa 2048 > private.pem`` -* Generate the self-signed certificate: ``openssl req -x509 -days 1000 -new -key private.pem -out public.pem`` -* If needed, create PFX: ``openssl pkcs12 -export -in public.pem -inkey private.pem -out mycert.pfx`` diff --git a/docs/building/releaseprocess.rst b/docs/building/releaseprocess.rst index aeb5d9ee1..9193d3353 100644 --- a/docs/building/releaseprocess.rst +++ b/docs/building/releaseprocess.rst @@ -1,52 +1,92 @@ +.. _Gitflow Workflow: https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow +.. _GitHub Flow: https://docs.github.com/en/get-started/using-github/github-flow +.. _develop: https://github.com/ThreeMammals/Ocelot/tree/develop +.. _main: https://github.com/ThreeMammals/Ocelot/tree/main + Release Process =============== -* The *release process* is optimized when using Gitflow branching, as detailed here: `Gitflow Workflow `_. - It's important to note that the Ocelot team does not utilize `GitHub Flow `_, which, despite being quicker, does not align with the efficiency required for Ocelot's delivery. -* Contributors are free to manage their pull requests and feature branches as they see fit to contribute to the `develop `_ branch. -* Maintainers have the autonomy to handle pull requests and merges. Any merges to the `main `_ branch will trigger the release of packages to GitHub and NuGet. +* The *release process* is optimized when using Gitflow branching, as detailed here: `Gitflow Workflow`_. + It's important to note that the Ocelot team does not utilize `GitHub Flow`_, which, despite being quicker, does not align with the efficiency required for Ocelot's delivery. +* Contributors are free to manage their pull requests and feature branches as they see fit to contribute to the '`develop`_' branch. +* Maintainers have the autonomy to handle pull requests and merges. Any merges to the '`main`_' branch will trigger the release of packages to GitHub and NuGet. * In conclusion, while users should adhere to the guidelines in :doc:`../building/devprocess`, maintainers should follow the procedures outlined in :doc:`../building/releaseprocess`. +Stages +------ +.. _Pair Programming: https://www.bing.com/search?q=Pair+Programming +.. _SemVer: https://semver.org +.. _GitVersion: https://gitversion.net/docs/ +.. _Ocelot NuGet packages: https://www.nuget.org/profiles/ThreeMammals +.. _Release: https://github.com/ThreeMammals/Ocelot/actions/workflows/release.yml +.. _Environments: https://github.com/ThreeMammals/Ocelot/settings/environments +.. _build.cake: https://github.com/ThreeMammals/Ocelot/blob/main/build.cake +.. _ThreeMammals: https://github.com/ThreeMammals +.. _milestone: https://github.com/ThreeMammals/Ocelot/milestones +.. _releases: https://github.com/ThreeMammals/Ocelot/releases + Ocelot project follows this *release process* to incorporate work into NuGet packages: -1. Maintainers review pull requests and, if satisfactory, merge them; otherwise, they provide feedback for the contributor to address. - Contributors are supported through continuous `Pair Programming `_ sessions, which include multiple code reviews, resolving code review issues, and problem-solving. +1. As a code reviewers, maintainers review pull requests and, if satisfactory, merge them; otherwise, they provide feedback for the contributor to address. + Contributors are supported through continuous `Pair Programming`_ sessions, which include multiple code reviews, resolving code review issues, and problem-solving. -2. Maintainers must adhere to Semantic Versioning (`SemVer `_) supported by `GitVersion `_. - For breaking changes, maintainers should use the correct commit message to ensure **GitVersion** applies the appropriate **SemVer** tags. +2. As a release engineers, maintainers must adhere to Semantic Versioning (`SemVer`_) supported by `GitVersion`_. + For breaking changes, maintainers should use the correct commit message (containing *"+semver: breaking|major|minor|patch"*) to ensure `GitVersion`_ applies the appropriate `SemVer`_ tags. Manual tagging of the Ocelot repository should be avoided to prevent disruptions. -3. Once a pull request is merged into the `develop`_ branch, the `Ocelot NuGet packages `_ remain unchanged until a release is initiated. - When sufficient work warrants a new release, the `develop`_ branch is merged into `main`_ as a ``release/X.Y.Z`` branch, triggering the release process that builds the code, assigns versions, and pushes artifacts to GitHub and NuGet packages to NuGet. +3. Once a pull request is merged into the '`develop`_' branch, the `Ocelot NuGet packages`_ remain unchanged until a release is initiated. + When sufficient work warrants a new release, the '`develop`_' branch is merged into '`main`_' as a ``release/X.Y`` branch, triggering the `Release`_ workflow that builds the code, assigns versions, and pushes artifacts to GitHub and packages to NuGet. -4. The release engineer, who holds the integration tokens for both CircleCi and GitHub, automates each release build using the primary build script, ``build.cake``. - The release engineer is also responsible for DevOps within the organization, across all (sub)repositories, supporting the primary build script. +4. The release engineer, who holds the integration tokens in GitHub `Environments`_, automates each release build using the primary build script, '`build.cake`_'. + Automated or manual :doc:`../building/building` can be performed :ref:`b-in-terminal` or :ref:`b-with-ci-cd`. + The release engineer is also responsible for DevOps within the `ThreeMammals`_ organization, across all (sub)repositories, supporting the primary build script, and scripting for other repositories. -5. The release engineer drafts ``ReleaseNotes.md``, informing the community about key aspects of the release, including new or updated features, bug fixes, documentation updates, breaking changes, contributor acknowledgments, version upgrade guidelines, etc. +5. The release engineer drafts the ``ReleaseNotes.md`` template file, informing the community about key aspects of the release, including new or updated features, bug fixes, documentation updates, breaking changes, contributor acknowledgments, version upgrade guidelines, and more. -6. The final step involves returning to GitHub to close the current `milestone `_, ensuring that: +6. The final stage of the *release process* involves returning to GitHub to close the current `milestone`_, ensuring that: * All issues within the `milestone`_ are closed; any remaining work from open issues should be transferred to the next `milestone`_. * All pull requests associated with the `milestone`_ are either closed or reassigned to the upcoming release `milestone`_. - * Release Notes are published on GitHub `releases `_, with an additional review of the text. - * The published release is designated as the latest, provided the corresponding `Ocelot NuGet packages`_ have been successfully uploaded to the `ThreeMammals `_ account. + * Release Notes are published on GitHub `releases`_, with an additional review of the text. + * The published release is designated as the latest, provided the corresponding `Ocelot NuGet packages`_ have been successfully uploaded to the `ThreeMammals `__ account. -7. Optional support for the major version ``X.Y.0`` should be available in instances such as Microsoft official patches and critical Ocelot defects of the major version. +7. Optional support for the major version ``X.Y.0`` should be available in cases such as Microsoft official patches and critical Ocelot defects of that major version. Maintainers should release patched versions ``X.Y.1-z`` as hot-fix patch versions. Notes ----- +.. _GitHub Actions: https://docs.github.com/en/actions +.. _Actions: https://github.com/ThreeMammals/Ocelot/actions +.. _Tom Pallister: https://github.com/TomPallister +.. _Raman Maksimchuk: https://github.com/raman-m +.. _Ocelot Team: https://github.com/orgs/ThreeMammals/teams -All NuGet package builds and releases are conducted through CircleCI. -For details, refer to the `Pipelines - ThreeMammals/Ocelot `_ on CircleCI. +**Note 1**: All NuGet package builds and releases are conducted through the `GitHub Actions`_ CI/CD provider. +For details, refer to the dedicated `Actions`_ dashboard, which should be used to monitor the current status of three workflows. -Currently, only `Tom Pallister `_, `Raman Maksimchuk `_, the owners, along with the `Ocelot Team `_ maintainers, have the authority to merge releases into the `main`_ branch of the Ocelot repository. -This policy is to ensure that a final :ref:`quality-gates` are in place. -The maintainers' primary focus during the final merge is to identify any security issues, as outlined in Step **7** of the process. +**Note 2**: Currently, only `Tom Pallister`_, `Raman Maksimchuk`_, the owners—along with the `Ocelot Team`_ maintainers—have the authority to merge releases into the '`main`_' branch of the Ocelot repository. +This policy ensures that final :ref:`quality-gates` are in place. +The maintainers' primary focus during the final merge is to identify any security issues, as outlined in Stage 7 of the process. .. _quality-gates: Quality Gates ------------- +.. _code analysis rule set: https://github.com/search?q=repo%3AThreeMammals%2FOcelot%20%3CCodeAnalysisRuleSet%3E&type=code +.. _codeanalysis.ruleset: https://github.com/ThreeMammals/Ocelot/blob/main/codeanalysis.ruleset +.. _Overview of .NET source code analysis: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/overview?tabs=net-9 +.. _StyleCop.Analyzers: https://www.nuget.org/packages/StyleCop.Analyzers +.. _reference: https://github.com/search?q=repo%3AThreeMammals%2FOcelot%20StyleCop.Analyzers&type=code +.. _here: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/configuration-options + +**Gate 1**: Static code analysis. +The Ocelot repository includes the following integrated style analyzers: + +* In-built IDE (.NET SDK): + The `code analysis rule set`_ is defined in the '`codeanalysis.ruleset`_' file, with configuration instructions available `here`_. + For comprehensive documentation, refer to the following article: + + - Microsoft Learn: `Overview of .NET source code analysis`_ - To be developed... +* `StyleCop.Analyzers`_: The package is somewhat outdated with slow support, but Ocelot projects still `reference`_ it because it has remained functional since 2015/16 as an older style analyzer. + The Ocelot team plans to replace this library with a more advanced tool in upcoming releases. diff --git a/docs/conf.py b/docs/conf.py index 9938ab7e8..e73d5a096 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -15,6 +15,7 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration extensions = [ + 'sphinx_copybutton' ] templates_path = ['_templates'] diff --git a/docs/features/administration.rst b/docs/features/administration.rst index 4c406eebb..fb2537805 100644 --- a/docs/features/administration.rst +++ b/docs/features/administration.rst @@ -1,25 +1,38 @@ -.. _IdentityServer4: https://github.com/IdentityServer/IdentityServer4 -.. _Program: https://github.com/ThreeMammals/Ocelot/blob/main/samples/Administration/Program.cs +.. _IdentityServer: https://github.com/DuendeArchive/IdentityServer4 +.. _IdentityServer4: https://www.nuget.org/packages/IdentityServer4 +.. _Program: https://github.com/ThreeMammals/Ocelot.Administration.IdentityServer4/blob/main/sample/Program.cs +.. _Ocelot.Administration: https://www.nuget.org/packages/Ocelot.Administration +.. _Ocelot.Administration.IdentityServer4: https://github.com/ThreeMammals/Ocelot.Administration.IdentityServer4 +.. _24.0: https://github.com/ThreeMammals/Ocelot/releases/tag/24.0.0 Administration ============== + | NuGet package: `IdentityServer4`_ by `IdentityServer org `_ (archived on March 6, 2025) + | Ocelot extension package: `Ocelot.Administration`_ with version 23.4.3 + Ocelot supports changing configuration during runtime via an authenticated HTTP API. -This can be authenticated in two ways either using Ocelot's internal `IdentityServer4`_ (for authenticating requests to the administration API only) or hooking the administration API authentication into your own `IdentityServer4`_. +This can be authenticated in two ways either using Ocelot's internal `IdentityServer`_ (for authenticating requests to the :ref:`administration-api` only) or hooking the :ref:`administration-api` authentication into your own `IdentityServer`_. -The first thing you need to do if you want to use the administration API is bring in the relevant `Ocelot.Administration `_ package: +The first thing you need to do if you want to use the :ref:`administration-api` is bring in the relevant `Ocelot.Administration `_ package: .. code-block:: powershell Install-Package Ocelot.Administration -This will bring down everything needed by the administration API. +This will bring down everything needed by the :ref:`administration-api`. + + **Warning!** Currently, the *Administration* feature relies solely on the `IdentityServer4`_ package, whose `repository `_ was archived by its owner on July 31, 2024 (for the first time) and again on March 6, 2025. + The Ocelot team will deprecate the upcoming `Ocelot.Administration.IdentityServer4`_ extension package after the release of Ocelot version `24.0`_. + However, `the repository `_ will remain available, allowing for potential future patches. -Providing your own IdentityServer ---------------------------------- +.. _ad-your-own-identityserver: -All you need to do to hook into your own `IdentityServer4`_ is add the following configuration options with authentication to your `Program`_. -After that, we must pass these options to the ``AddAdministration()`` extension of the ``OcelotBuilder`` being returned by ``AddOcelot()`` [#f1]_, as shown below: +Your Own IdentityServer [#f1]_ +------------------------------ + +All you need to do to hook into your own `IdentityServer`_ is add the following configuration options with authentication to your `Program`_. +After that, we must pass these options to the ``AddAdministration()`` extension of the ``OcelotBuilder`` being returned by ``AddOcelot()`` [#f2]_, as shown below: .. code-block:: csharp @@ -37,17 +50,18 @@ After that, we must pass these options to the ``AddAdministration()`` extension .AddOcelot(builder.Configuration) .AddAdministration("/administration", options); -You now need to get a token from your `IdentityServer4`_ and use in subsequent requests to Ocelot's administration API. +You now need to get a token from your `IdentityServer`_ and use in subsequent requests to Ocelot's :ref:`administration-api`. + + **Note**: This feature is useful because the `IdentityServer`_ authentication middleware needs the URL of the server. + If you are using the :ref:`ad-internal-identityserver`, it might not always be possible to have the Ocelot URL. -This feature was implemented for issue `228 `_. -It is useful because the `IdentityServer4`_ authentication middleware needs the URL of the server. -If you are using the internal `IdentityServer4`_, it might not always be possible to have the Ocelot URL. +.. _ad-internal-identityserver: Internal IdentityServer ----------------------- The API is authenticated using Bearer tokens that you request from Ocelot itself. -This is provided by the amazing `IdentityServer4`_ project that the .NET community has been using for several years. +This is provided by the amazing `IdentityServer`_ project that the .NET community has been using for several years. Check it out. In order to enable the administration section, you need to do a few things. First of all, add this to your initial `Program`_. @@ -55,9 +69,9 @@ In order to enable the administration section, you need to do a few things. Firs The path can be anything you want and it is obviously recommended don't use a URL you would like to route through with Ocelot as this will not work. The administration uses the ``MapWhen`` functionality of ASP.NET Core and all requests to ``{root}/administration`` will be sent there not to the Ocelot middleware. -The secret is the client secret that Ocelot's internal `IdentityServer4`_ will use to authenticate requests to the administration API. +The secret is the client secret that Ocelot's internal `IdentityServer`_ will use to authenticate requests to the :ref:`administration-api`. This can be whatever you want it to be! -In order to pass this secret string as parameter, we must call the ``AddAdministration()`` extension of the ``OcelotBuilder`` being returned by ``AddOcelot()`` [#f1]_, as shown below: +In order to pass this secret string as parameter, we must call the ``AddAdministration()`` extension of the ``OcelotBuilder`` being returned by ``AddOcelot()`` [#f2]_, as shown below: .. code-block:: csharp @@ -65,7 +79,7 @@ In order to pass this secret string as parameter, we must call the ``AddAdminist .AddOcelot(builder.Configuration) .AddAdministration("/administration", "secret"); -In order for the administration API to work, Ocelot and `IdentityServer4`_ must be able to call themselves for validation. +In order for the :ref:`administration-api` to work, Ocelot and `IdentityServer`_ must be able to call themselves for validation. This means that you need to add the base URL of Ocelot to the global configuration if it is not the default ``http://localhost:5000``. Please note, if you are using something like Docker to host Ocelot, it might not be able to call back to ``localhost``, etc., and you need to know what you are doing with Docker networking in this scenario. @@ -92,7 +106,7 @@ Obviously these will need to be changed if you are running Ocelot on a different The scripts show you how to request a Bearer token from Ocelot and then use it to GET the existing configuration and POST a configuration. -If you are running multiple Ocelot instances in a cluster then you need to use a certificate to sign the Bearer tokens used to access the administration API. +If you are running multiple Ocelot instances in a cluster then you need to use a certificate to sign the Bearer tokens used to access the :ref:`administration-api`. In order to do this, you need to add two more environmental variables for each Ocelot in the cluster: @@ -110,7 +124,7 @@ Administration API * **POST** ``{adminPath}/connect/token`` This gets a token for use with the admin area using the client credentials we talk about setting above. - Under the hood this calls into an `IdentityServer4`_ hosted within Ocelot. + Under the hood this calls into an `IdentityServer`_ hosted within Ocelot. The body of the request is form-data as follows: @@ -143,4 +157,5 @@ Administration API """" -.. [#f1] The :ref:`di-services-addocelot-method` adds default ASP.NET services to the DI container. You can call another extended :ref:`di-addocelotusingbuilder-method` while configuring services to develop your own :ref:`di-custom-builder`. See more instructions in the ":ref:`di-addocelotusingbuilder-method`" section of the :doc:`../features/dependencyinjection` feature. +.. [#f1] The ":ref:`ad-your-own-identityserver`" feature was implemented for issue `228 `_. +.. [#f2] The :ref:`di-services-addocelot-method` adds default ASP.NET services to the DI container. You can call another extended :ref:`di-addocelotusingbuilder-method` while configuring services to develop your own :ref:`di-custom-builder`. See more instructions in the ":ref:`di-addocelotusingbuilder-method`" section of the :doc:`../features/dependencyinjection` feature. diff --git a/docs/features/logging.rst b/docs/features/logging.rst index 0946bb265..f4aef707a 100644 --- a/docs/features/logging.rst +++ b/docs/features/logging.rst @@ -299,10 +299,10 @@ We are pleased to invite you to run logging benchmarks on your machine by follow 7. Wait for 3+ minutes to complete the benchmark and get the final results. 8. Read and analyze your benchmark session results. -.. Indicators -.. ^^^^^^^^^^ - -.. ``To be developed...`` +.. + Indicators + ^^^^^^^^^^ + To be developed... """" diff --git a/docs/index.rst b/docs/index.rst index 3538463c1..d53630962 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,11 +1,15 @@ .. _24.0: https://github.com/ThreeMammals/Ocelot/releases/tag/24.0.0 +.. role:: htm(raw) + :format: html +.. role:: pdf(raw) + :format: latex pdflatex ############## Ocelot `24.0`_ ############## Thanks for taking a look at the Ocelot documentation! -Please use the left hand **Navigation** sidebar to get around, or see the **Table of Contents** below (above). +Please use the left hand **Navigation** sidebar to get around, or see the :htm:`Table of Contents below.` :pdf:`\textbf{Table of Contents} above.` The team recommends that newcomers to Ocelot's world start with the **Introduction** chapters. For seasoned fans of Ocelot with a Production environment, it is advised to always consult the :ref:`release-notes` in the **Welcome** section before upgrading the app to the latest `24.0`_ version. @@ -16,7 +20,7 @@ The primary features include :doc:`../features/configuration` and :doc:`../featu Additional tips for building Ocelot can be found in the **Building Ocelot** section. We adhere to a :doc:`../building/devprocess` which is a part of :doc:`../building/releaseprocess`. -.. admonition:: Table of Contents +:htm:`

Table of Contents

` .. toctree:: :maxdepth: 2 @@ -67,7 +71,8 @@ We adhere to a :doc:`../building/devprocess` which is a part of :doc:`../buildin :maxdepth: 3 :caption: Building Ocelot - building/overview + building/building building/devprocess building/releaseprocess +:htm:`
` diff --git a/docs/introduction/bigpicture.rst b/docs/introduction/bigpicture.rst index 632bf688d..0dd71ff79 100644 --- a/docs/introduction/bigpicture.rst +++ b/docs/introduction/bigpicture.rst @@ -4,10 +4,11 @@ Big Picture Ocelot is aimed at people using .NET running a microservices (service-oriented) architecture (aka SOA) that need a unified point of entry into their system. However it will work with anything that speaks HTTP(S) and run on any platform that `ASP.NET Core `_ supports. -.. TODO Decide what to do with this paragraph?.. -.. In particular we want easy integration with `IdentityServer `_ reference and `Bearer `_ tokens. -.. We have been unable to find this in our 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. +.. + TODO Decide what to do with this paragraph?.. + In particular we want easy integration with `IdentityServer `_ reference and `Bearer `_ tokens. + We have been unable to find this in our 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 consists of a series of ASP.NET Core `middlewares `_ arranged in a specific order. @@ -21,22 +22,23 @@ That is basically it with a bunch of other features! The following are configurations that you use when deploying Ocelot. Basic Implementation -^^^^^^^^^^^^^^^^^^^^ +-------------------- .. image:: ../images/OcelotBasic.jpg -.. TODO Do not advertise the product because of non-OSS status -.. With IdentityServer -.. ^^^^^^^^^^^^^^^^^^^ -.. .. image:: ../images/OcelotIndentityServer.jpg +.. + TODO Do not advertise the product because of non-OSS status + With IdentityServer + ^^^^^^^^^^^^^^^^^^^ + .. image:: ../images/OcelotIndentityServer.jpg Multiple Instances -^^^^^^^^^^^^^^^^^^ +------------------ .. image:: ../images/OcelotMultipleInstances.jpg With Consul -^^^^^^^^^^^ +----------- .. image:: ../images/OcelotMultipleInstancesConsul.jpg With Service Fabric -^^^^^^^^^^^^^^^^^^^ +------------------- .. image:: ../images/OcelotServiceFabric.jpg diff --git a/docs/introduction/gotchas.rst b/docs/introduction/gotchas.rst index 515b0e2f2..68d0553ae 100644 --- a/docs/introduction/gotchas.rst +++ b/docs/introduction/gotchas.rst @@ -11,7 +11,7 @@ Please review deployment and web hosting common user scenarios below depending o IIS --- - | Repository Label: |image-IIS| + | Repository Label: |image-IIS| `IIS `_ | Microsoft Learn: `Host ASP.NET Core on Windows with IIS `_ We **do not** recommend to deploy Ocelot app to IIS environments, but if you do, keep in mind the gotchas below. @@ -41,7 +41,7 @@ Probably you will find a ready solution by Ocelot community members. Kestrel ------- - | Repository Label: |image-Kestrel| + | Repository Label: |image-Kestrel| `Kestrel `_ | Microsoft Learn: `Kestrel web server in ASP.NET Core `_ We **do** recommend to deploy Ocelot app to self-hosting environments, aka Kestrel vs Docker. diff --git a/docs/releasenotes.rst b/docs/releasenotes.rst index 00961fa3f..c903b09b7 100644 --- a/docs/releasenotes.rst +++ b/docs/releasenotes.rst @@ -4,7 +4,6 @@ .. _24.0.0: https://github.com/ThreeMammals/Ocelot/releases/tag/24.0.0 .. _.NET 9: https://dotnet.microsoft.com/en-us/download/dotnet/9.0 .. _Ocelot: https://www.nuget.org/packages/Ocelot - .. role:: htm(raw) :format: html @@ -16,40 +15,15 @@ Welcome Welcome to the Ocelot `24.0`_ documentation! -It is recommended to read all :ref:`release-notes` if you have deployed the Ocelot app in a production environment and are planning to upgrade to major or patched versions. - -.. The major version `23.4.0`_ includes several patches, the history of which is provided below. - -.. .. admonition:: Patches - -.. - `23.4.1`_, on Nov 22, 2024: Routing patch. -.. - `23.4.2`_, on Nov 27, 2024: End of .NET 6/7 Support patch. +It is recommended to read all :ref:`release-notes` if you have deployed the Ocelot app in a production environment and are planning to upgrade to major, minor or patched versions. .. _release-notes: Release Notes ------------- -| Release Tag: `24.0.0`_ -| Release Codename: `.NET 9`_ - - .. :htm:`
With release jokes:` - - .. - **for men**: Wearing a cap with the `MAGA slogan `_ is encouraged when visiting McDonald's. - .. - **for women**: Donald is fond of caps, particularly the `MAGA cap `_, and it's amusing to see children's reactions when `We Ask Kids How Mr.D is Doing `_? - .. - **for black men**: Here are some highlights of Donald's antics aka Mr. D: - - .. | 1 `Mr. D stops to retrieve Marine's hat `_ - .. | 2 `M-A-G-A caps take flight `_ - .. | 3 `Mr. D Dances To 'YMCA' `_ - .. | 4 `Elon is more than just a MAGAr `_ - .. | 5 `Mr. D looks for a job at McDonald's in 2024 `_ - .. | lastly, `Mr. D serves customers at McDonald's Drive-Thru `_ - - .. :htm:`
` - -About -^^^^^ + | Release Tag: `24.0.0`_ + | Release Codename: `.NET 9`_ On November 12th, 2024, the `.NET team `_ announced the release of the `.NET 9`_ framework: @@ -59,46 +33,146 @@ This major release upgrades `Ocelot`_ package `TFMs `_ are .NET 8 LTS and .NET 9 STS. According to the `.NET Support Policy `_, the Ocelot team has discontinued support of .NET 6 and .NET 7 by providing the version `23.4.3`_ which targets those .NET versions. -.. What's New? -.. ^^^^^^^^^^^ +What's New? +----------- + +.. _@raman-m: https://github.com/raman-m +.. _DevOps: https://github.com/ThreeMammals/Ocelot/labels/DevOps + +- `DevOps`_: The CI/CD infrastructure was migrated from CircleCI to GitHub Actions by `@raman-m`_. + + **Official Notice to the Community Regarding CircleCI** + + Ocelot's previous CI/CD provider, CircleCI, facilitated professional and seamless development, build processes, and delivery of Ocelot versions for seven years, starting in `March 2018 `_. + But last year, in January 2025, after patching Ocelot with version `23.4.3`_, our team encountered legal issues related to CircleCI Co's policies, leading to this CI/CD provider stopping the build process for the `Ocelot project `_. + This legal issue and technical incident were unforeseen on our part because Ocelot is *open-source software* (OSS), and forcibly stopping the project's build process and blocking accounts appears to be an unfortunate breach of OSS principles. + We strongly believe that any developer or user, from any country, should be able to use software providers that support the OSS movement by offering free or other cost-free plans and serving the accounts of these users, OSS teams, and OSS projects 24/7, 365 days a year. + We consider this legal issue and the resulting technical incidents involving CircleCI to be a serious breach of OSS principles and an act of discrimination against Ocelot users, developers, and customers who rely on Ocelot OSS, ultimately causing delays to the current release. + As a team, we do not recommend using CircleCI for OSS projects, as there is no guarantee that these projects will not face discrimination from this U.S. company. + + For all developers, team leads, architects, and managers of any OSS projects—at least on GitHub—we recommend utilizing the built-in GitHub Actions CI/CD infrastructure. + Since its founding, GitHub has supported OSS projects. Today, GitHub provides 2,000 minutes of free CI/CD build time per month for OSS repositories (public repos). + Also, we strongly believe that GitHub will never violate its OSS policies without a notice period, nor fail to inform owners and maintainers that certain policies must be met by Ocelot's owners. + In addition, we want to acknowledge that we are monitoring U.S. government regulations. + Unfortunately, we must state that some GitHub products are unavailable in certain countries, even if the project is OSS and GitHub claims these products are free for OSS. + Since the Ocelot team does not utilize these non-critical products (we prefer to energize our brains rather than rely on AI-driven products), and since the Ocelot project is currently well-served by GitHub Co, the Ocelot team affirms that Ocelot will remain on GitHub as long as its OSS-friendly policies continue. + As a team, we hope that GitHub will never enforce extra rules on our project or other OSS projects. + Regardless, we remain on GitHub! + + **Technical Information** + + .. _PR: https://github.com/ThreeMammals/Ocelot/blob/main/.github/workflows/pr.yml + .. _Develop: https://github.com/ThreeMammals/Ocelot/blob/main/.github/workflows/develop.yml + .. _Release: https://github.com/ThreeMammals/Ocelot/blob/main/.github/workflows/release.yml + .. _three workflows: https://github.com/ThreeMammals/Ocelot/tree/main/.github/workflows + .. _GitHub Actions: https://docs.github.com/en/actions + .. _Coveralls: https://coveralls.io/ + .. _ThreeMammals/Ocelot: https://coveralls.io/github/ThreeMammals/Ocelot + + Starting from version `24.0`_, all pull requests, development commits, and releases will be built using `GitHub Actions`_ workflows. + We currently have `three workflows`_: one for pull requests (`PR`_), one for the ``develop`` branch (`Develop`_), and one for the ``main`` branch (`Release`_). + + The `PR`_ workflow will track code coverage using `Coveralls`_. + After opening a pull request or submitting a new commit to a pull request, `Coveralls`_ will publish a short message with the current code coverage once the top commit is built. + Considering that `Coveralls`_ retains the entire history but does not fail the build if coverage falls below the threshold, all workflows have a built-in 80% threshold, + applied internally within the ``build-cake`` job, particularly during the "Cake Build" step-action. + If the code coverage of a newly opened pull request drops below the 80% threshold, the ``build-cake`` job will fail, logging an appropriate message in the "Cake Build" step. + For your information, the current code coverage of the Ocelot project is around 85-86%. The coverage threshold is subject to change in upcoming releases. + All Coveralls builds can be viewed by navigating to the `ThreeMammals/Ocelot`_ project on Coveralls.io. + +What's Updated? +--------------- -.. - :doc:`../features/routing`: Introducing the new ":ref:`routing-embedded-placeholders`" feature by `@ggnaegi`_. +.. _1912: https://github.com/ThreeMammals/Ocelot/issues/1912 +.. _2218: https://github.com/ThreeMammals/Ocelot/issues/2218 +.. _2274: https://github.com/ThreeMammals/Ocelot/pull/2274 +.. _TargetFrameworks: https://github.com/search?q=repo%3AThreeMammals%2FOcelot%20%3CTargetFrameworks%3E&type=code +.. _reference: https://github.com/search?q=repo%3AThreeMammals%2FOcelot%20%3CTargetFrameworks%3E&type=code +.. _extension: https://www.nuget.org/profiles/ThreeMammals +.. _vulnerabilities: https://github.com/ThreeMammals/Ocelot/security/dependabot +.. _ASP.NET Core Identity: https://learn.microsoft.com/en-us/aspnet/core/security/authentication/identity +.. _acceptance testing: https://github.com/ThreeMammals/Ocelot/tree/develop/test/Ocelot.AcceptanceTests +.. _Microsoft.AspNetCore.Authentication.JwtBearer: https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authentication.jwtbearer +.. _IdentityServer4: https://github.com/DuendeArchive/IdentityServer4 -.. | As of November 2024, Ocelot was unable to process multiple :ref:`routing-placeholders` embedded between two forward slashes (``/``). It was also challenging to differentiate the placeholder from other elements within the slashes. For example, ``/{url}-2/`` for ``/y-2/`` would yield ``{url} = y-2``. We are excited to introduce an enhanced method for evaluating placeholders that allows for the resolution of :ref:`routing-placeholders` within complex URLs. -.. | For additional information, refer to PR `2200`_. +.. - |Core|_: -What's Updated? -^^^^^^^^^^^^^^^ +- `Core `_: + + The main `Ocelot`_ package and all `extension`_ packages `reference`_ ``net8.0`` and ``net9.0`` target framework monikers (TFMs). + Refer to `TargetFrameworks`_ to verify this. + The ``net6.0`` and ``net7.0`` TFMs have been removed. + If your project still relies on these outdated TFMs, please continue using version `23.4.3`_. + + .. |Core| replace:: **Core** + .. _Core: https://github.com/ThreeMammals/Ocelot/labels/Core + +- :doc:`../features/authentication`: - ``TODO``: To be written... + Testing of :ref:`authentication-identity-server` functionality was stopped due to `vulnerabilities`_ reported by Dependabot, + specifically the "`IdentityServer Open Redirect vulnerability `_" security issue. + More technical details were provided in the `23.4.2`_ release notes, where we notified the community. + Ultimately, issue `2218`_ was addressed via pull request `2274`_. -.. .. _1912: https://github.com/ThreeMammals/Ocelot/issues/1912 -.. .. _2218: https://github.com/ThreeMammals/Ocelot/issues/2218 + **Note**: In upcoming releases, we plan to utilize the `ASP.NET Core Identity`_ framework in our `acceptance testing`_ project to align with .NET industry standards. + As a result, we intend to replace the `IdentityServer4`_ library with `ASP.NET Core Identity`_, which also supports Bearer tokens, also known as ``JwtBearerHandler`` from the `Microsoft.AspNetCore.Authentication.JwtBearer`_ namespace. -.. - `Core `_: The main `Ocelot`_ package and all `extension `_ packages `reference `_ ``net8.0`` and ``net9.0`` target framework monikers. -.. The ``net6.0`` and ``net7.0`` TFMs were removed. +- :doc:`../features/administration`: -.. Curious? Search for all references: ` `_. + The `Ocelot.Administration`_ extension package has been renamed to `Ocelot.Administration.IdentityServer4`_ (it is scheduled for deprecation) to address all `IdentityServer4`_-related `vulnerabilities`_ (issue `2218`_). + The `package's source code `_ has been moved out of the Ocelot repository (pull request `2274`_) and transferred to the newly created `Ocelot.Administration.IdentityServer4`_ repository. -.. - :doc:`../features/authentication`: Stopped testing :ref:`authentication-identity-server` functionality. + **Note**: Currently, the :doc:`../features/administration` feature is solely based on the `IdentityServer4 package `_, whose `repository `_ was archived by its owner on July 31, 2024. + The Ocelot team will deprecate the new `Ocelot.Administration.IdentityServer4`_ extension package after the current Ocelot release; however, the repository will not be archived, allowing for potential patches in the future. -.. The reason is explained in the `23.4.2`_ release notes warnings. + .. _Ocelot.Administration: https://www.nuget.org/packages/Ocelot.Administration + .. _Ocelot.Administration.IdentityServer4: https://github.com/ThreeMammals/Ocelot.Administration.IdentityServer4 -.. - :doc:`../features/administration`: The ``Ocelot.Administration`` extension package was renamed to ``Ocelot.Administration.IdentityServer4`` with immediate deprecation. +- :doc:`../features/kubernetes`: -.. To address all `IdentityServer4 `_-related `vulnerabilities `_ (issue `2218`_), the package source code has been `moved out of the Ocelot repository `_. -.. The feature was solely based on the `IdentityServer4 package `_, whose `repository `_ was archived by the owner on July 31, 2024. -.. The Ocelot team deprecated the new ``Ocelot.Administration.IdentityServer4`` extension package, but it will not be archived; any patches will be possible in the future. + 1. Answered question `2256`_ on "How to provide a host to the Kubernetes service discovery provider?" + Unfortunately, in the :doc:`../features/kubernetes` chapter, it was unclear to users how to define a K8s endpoint host in the :ref:`k8s-configuration` due to the implicit reuse of ``KubeClient``, which is created from the pod account during :ref:`k8s-install`-ation. + As a team, we decided to add the new :ref:`k8s-addkubernetes-action-method`, which handles different user scenarios. + It is now possible to provide manually configured ``KubeClientOptions`` in C# during :ref:`k8s-install`-ation, but users can also reuse ``ServiceDiscoveryProvider`` options from the global :ref:`k8s-configuration`, including the ``Host`` option to construct the :doc:`../features/kubernetes` endpoint address. + The new overloaded ``AddKubernetes(Action)`` method was implemented in pull request `2257`_. -.. - :doc:`../introduction/gettingstarted`: Learning :ref:`gettingstarted-samples` projects were reviewed, rewritten, and refactored due to issue `1912`_. + 2. In the `Ocelot.Provider.Kubernetes`_ extension package, the ``KubeClient`` dependency library version was upgraded to ``3.0.x``, which requires .NET 8.0 and .NET 9.0 TFMs for the current Ocelot version `24.0`_. + ``KubeClient`` v3 was internally reviewed and released specifically to meet Ocelot's needs for this release. Thanks to Adam Friedman (`@tintoy`_) for his collaboration! + This package upgrade was implemented in pull request `2266`_. + + .. _2256: https://github.com/ThreeMammals/Ocelot/discussions/2256 + .. _2257: https://github.com/ThreeMammals/Ocelot/pull/2257 + .. _2266: https://github.com/ThreeMammals/Ocelot/pull/2266 + .. _Ocelot.Provider.Kubernetes: https://www.nuget.org/packages/Ocelot.Provider.Kubernetes/ + .. _@tintoy: https://github.com/tintoy + +- `Sample `_: + + The learning `Samples`_ projects were reviewed, rewritten, and refactored due to issue `1912`_. + The community brought to our attention that the documentation and `Samples`_ were outdated, as .NET 8 allows the ``Program.cs`` file to be minimized using the `Top-level statements`_ feature. + This was ultimately addressed in pull requests `2244`_ and `2258`_. + + .. _2244: https://github.com/ThreeMammals/Ocelot/pull/2244 + .. _2258: https://github.com/ThreeMammals/Ocelot/pull/2258 + .. _Samples: https://github.com/ThreeMammals/Ocelot/tree/main/samples + .. _Top-level statements: https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/program-structure/top-level-statements Documentation Summary -^^^^^^^^^^^^^^^^^^^^^ +--------------------- + +Due to the major version increase to v24, all documentation chapters were reviewed to improve readability, eliminate ambiguity, provide more useful tables and data schemas, update code snippets with the syntax of `Top-level statements`_, and add handy samples, among other enhancements. +The entire documentation is designed to be truly professional for senior developers while remaining easy to read for junior developers and newcomers who are starting to use the Ocelot gateway. - ``TODO``: To be written... +We believe that Ocelot students will ask fewer questions in 2025 🙂 +For students, we always recommend finding answers in `Q&A`_ category first. +Honestly, it is advised to read existing discussions before opening a new question in repo `Discussions`_. +For true Ocelot patriots, we have added a `README link`_ to the smart `Ocelot AI Guru`_ assistant, which is always ready to answer any of your questions. +Feel free to explore and interact with it! 😊 -.. - :doc:`../introduction/gettingstarted`: Completely rewritten due to the fixed issue `1912`_. -.. Now documentation C# code blocks provide code snippets using `top-level statements `_ syntax. +.. _Q&A: https://github.com/ThreeMammals/Ocelot/discussions/categories/q-a +.. _Discussions: https://github.com/ThreeMammals/Ocelot/discussions +.. _README link: https://github.com/ThreeMammals/Ocelot?tab=readme-ov-file#documentation +.. _Ocelot AI Guru: https://gurubase.io/g/ocelot Contributing ------------ diff --git a/docs/requirements.txt b/docs/requirements.txt index 663b7f6a0..6ca44b48d 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,3 +1,4 @@ # Defining the exact version will make sure things don't break sphinx==8.2.3 alabaster==1.0.0 +sphinx_copybutton==0.5.2 diff --git a/samples/Eureka/DownstreamService/Ocelot.Samples.Eureka.DownstreamService.csproj b/samples/Eureka/DownstreamService/Ocelot.Samples.Eureka.DownstreamService.csproj index c801fb815..43858d793 100644 --- a/samples/Eureka/DownstreamService/Ocelot.Samples.Eureka.DownstreamService.csproj +++ b/samples/Eureka/DownstreamService/Ocelot.Samples.Eureka.DownstreamService.csproj @@ -29,7 +29,7 @@ - + diff --git a/samples/GraphQL/Ocelot.Samples.GraphQL.csproj b/samples/GraphQL/Ocelot.Samples.GraphQL.csproj index f5c971642..3d10cfdd2 100644 --- a/samples/GraphQL/Ocelot.Samples.GraphQL.csproj +++ b/samples/GraphQL/Ocelot.Samples.GraphQL.csproj @@ -23,8 +23,8 @@ - - + + diff --git a/samples/Kubernetes/DownstreamService/Ocelot.Samples.Kubernetes.DownstreamService.csproj b/samples/Kubernetes/DownstreamService/Ocelot.Samples.Kubernetes.DownstreamService.csproj index 5da06a82b..8c755b989 100644 --- a/samples/Kubernetes/DownstreamService/Ocelot.Samples.Kubernetes.DownstreamService.csproj +++ b/samples/Kubernetes/DownstreamService/Ocelot.Samples.Kubernetes.DownstreamService.csproj @@ -23,7 +23,7 @@ - + diff --git a/samples/OpenTracing/Ocelot.Samples.OpenTracing.csproj b/samples/OpenTracing/Ocelot.Samples.OpenTracing.csproj index b879e8b24..97ae64ae2 100644 --- a/samples/OpenTracing/Ocelot.Samples.OpenTracing.csproj +++ b/samples/OpenTracing/Ocelot.Samples.OpenTracing.csproj @@ -30,6 +30,6 @@ - + diff --git a/samples/ServiceDiscovery/DownstreamService/Ocelot.Samples.ServiceDiscovery.DownstreamService.csproj b/samples/ServiceDiscovery/DownstreamService/Ocelot.Samples.ServiceDiscovery.DownstreamService.csproj index 65556c342..2be2d2f9f 100644 --- a/samples/ServiceDiscovery/DownstreamService/Ocelot.Samples.ServiceDiscovery.DownstreamService.csproj +++ b/samples/ServiceDiscovery/DownstreamService/Ocelot.Samples.ServiceDiscovery.DownstreamService.csproj @@ -29,7 +29,7 @@ - + diff --git a/src/Ocelot.Cache.CacheManager/Ocelot.Cache.CacheManager.csproj b/src/Ocelot.Cache.CacheManager/Ocelot.Cache.CacheManager.csproj index 09387ed12..0d9c5f58a 100644 --- a/src/Ocelot.Cache.CacheManager/Ocelot.Cache.CacheManager.csproj +++ b/src/Ocelot.Cache.CacheManager/Ocelot.Cache.CacheManager.csproj @@ -49,13 +49,12 @@ all - - - - - - - + + + + + + diff --git a/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj b/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj index 59e43fc4e..a9fb0461a 100644 --- a/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj +++ b/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj @@ -45,7 +45,7 @@ - + all diff --git a/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj b/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj index 1067e52f0..e5311bb15 100644 --- a/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj +++ b/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj @@ -39,8 +39,8 @@ - - + + all diff --git a/src/Ocelot.Provider.Polly/Ocelot.Provider.Polly.csproj b/src/Ocelot.Provider.Polly/Ocelot.Provider.Polly.csproj index 2ed23be37..e5bc81d1a 100644 --- a/src/Ocelot.Provider.Polly/Ocelot.Provider.Polly.csproj +++ b/src/Ocelot.Provider.Polly/Ocelot.Provider.Polly.csproj @@ -48,7 +48,7 @@ all - + diff --git a/src/Ocelot/Ocelot.csproj b/src/Ocelot/Ocelot.csproj index 1a097648b..5bdaa6995 100644 --- a/src/Ocelot/Ocelot.csproj +++ b/src/Ocelot/Ocelot.csproj @@ -44,7 +44,7 @@ - + NU1701 @@ -55,13 +55,13 @@ - - + + - - + + diff --git a/test/Ocelot.AcceptanceTests/Caching/InMemoryJsonHandle.cs b/test/Ocelot.AcceptanceTests/Caching/InMemoryJsonHandle.cs index 52520232a..52837acf7 100644 --- a/test/Ocelot.AcceptanceTests/Caching/InMemoryJsonHandle.cs +++ b/test/Ocelot.AcceptanceTests/Caching/InMemoryJsonHandle.cs @@ -1,8 +1,9 @@ using CacheManager.Core; using CacheManager.Core.Internal; -using CacheManager.Core.Logging; +using CacheManager.Core.Configuration; using CacheManager.Core.Utility; using System.Collections.Concurrent; +using Microsoft.Extensions.Logging; namespace Ocelot.AcceptanceTests.Caching; @@ -19,7 +20,7 @@ public InMemoryJsonHandle( { _cache = new ConcurrentDictionary>(); _serializer = serializer; - Logger = loggerFactory.CreateLogger(this); + Logger = loggerFactory.CreateLogger>(); } public override int Count => _cache.Count; @@ -30,8 +31,7 @@ public InMemoryJsonHandle( public override void ClearRegion(string region) { - Guard.NotNullOrWhiteSpace(region, nameof(region)); - + ArgumentNullException.ThrowIfNullOrWhiteSpace(region, nameof(region)); var key = string.Concat(region, ":"); foreach (var item in _cache.Where(p => p.Key.StartsWith(key, StringComparison.OrdinalIgnoreCase))) { @@ -41,26 +41,22 @@ public override void ClearRegion(string region) public override bool Exists(string key) { - Guard.NotNullOrWhiteSpace(key, nameof(key)); - + ArgumentNullException.ThrowIfNullOrWhiteSpace(key, nameof(key)); return _cache.ContainsKey(key); } public override bool Exists(string key, string region) { - Guard.NotNullOrWhiteSpace(region, nameof(region)); + ArgumentNullException.ThrowIfNullOrWhiteSpace(region, nameof(region)); var fullKey = GetKey(key, region); return _cache.ContainsKey(fullKey); } protected override bool AddInternalPrepared(CacheItem item) { - Guard.NotNull(item, nameof(item)); - + ArgumentNullException.ThrowIfNull(item, nameof(item)); var key = GetKey(item.Key, item.Region); - var serializedItem = _serializer.SerializeCacheItem(item); - return _cache.TryAdd(key, new Tuple(item.Value.GetType(), serializedItem)); } @@ -89,10 +85,9 @@ protected override CacheItem GetCacheItemInternal(string key, strin protected override void PutInternalPrepared(CacheItem item) { - Guard.NotNull(item, nameof(item)); + ArgumentNullException.ThrowIfNull(item, nameof(item)); var serializedItem = _serializer.SerializeCacheItem(item); - _cache[GetKey(item.Key, item.Region)] = new Tuple(item.Value.GetType(), serializedItem); } @@ -106,8 +101,7 @@ protected override bool RemoveInternal(string key, string region) private static string GetKey(string key, string region) { - Guard.NotNullOrWhiteSpace(key, nameof(key)); - + ArgumentNullException.ThrowIfNullOrWhiteSpace(key, nameof(key)); if (string.IsNullOrWhiteSpace(region)) { return key; diff --git a/test/Ocelot.AcceptanceTests/Configuration/ConfigurationInConsulTests.cs b/test/Ocelot.AcceptanceTests/Configuration/ConfigurationInConsulTests.cs index e5e1bd37f..0dcd42a58 100644 --- a/test/Ocelot.AcceptanceTests/Configuration/ConfigurationInConsulTests.cs +++ b/test/Ocelot.AcceptanceTests/Configuration/ConfigurationInConsulTests.cs @@ -103,7 +103,8 @@ private void GivenOcelotIsRunningUsingConsulToStoreConfigAndJsonSerializedCache( { s.AddOcelot() .AddCacheManager(x => x - .WithMicrosoftLogging(_ => { /*log.AddConsole(LogLevel.Debug);*/ }) + + //.WithMicrosoftLogging(_ => { /*log.AddConsole(LogLevel.Debug);*/ }) .WithJsonSerializer() .WithHandle(typeof(InMemoryJsonHandle<>))) .AddConsul() diff --git a/test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.csproj b/test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.csproj index 6f582b446..f673156d3 100644 --- a/test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.csproj +++ b/test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.csproj @@ -44,46 +44,45 @@ - + - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + - - - + + - - + + all - - - - - - - - + + + + + + + + - + - + diff --git a/test/Ocelot.AcceptanceTests/Steps.cs b/test/Ocelot.AcceptanceTests/Steps.cs index b941a468d..4b0a7bc95 100644 --- a/test/Ocelot.AcceptanceTests/Steps.cs +++ b/test/Ocelot.AcceptanceTests/Steps.cs @@ -324,12 +324,9 @@ public void GivenOcelotIsRunningUsingJsonSerializedCache() s.AddOcelot() .AddCacheManager((x) => { - x.WithMicrosoftLogging(_ => - { - //log.AddConsole(LogLevel.Debug); - }) - .WithJsonSerializer() - .WithHandle(typeof(InMemoryJsonHandle<>)); + //x.WithMicrosoftLogging(_ => /*log.AddConsole(LogLevel.Debug);*/) + x.WithJsonSerializer(); + x.WithHandle(typeof(InMemoryJsonHandle<>)); }); }) .Configure(async app => await app.UseOcelot()); diff --git a/test/Ocelot.Benchmarks/Ocelot.Benchmarks.csproj b/test/Ocelot.Benchmarks/Ocelot.Benchmarks.csproj index 99f352565..d53a79de6 100644 --- a/test/Ocelot.Benchmarks/Ocelot.Benchmarks.csproj +++ b/test/Ocelot.Benchmarks/Ocelot.Benchmarks.csproj @@ -24,7 +24,7 @@ - + all diff --git a/test/Ocelot.IntegrationTests/CacheManagerTests.cs b/test/Ocelot.IntegrationTests/CacheManagerTests.cs index b9f806010..749d48d0e 100644 --- a/test/Ocelot.IntegrationTests/CacheManagerTests.cs +++ b/test/Ocelot.IntegrationTests/CacheManagerTests.cs @@ -125,11 +125,11 @@ private void GivenOcelotIsRunning() { Action settings = (s) => { - s.WithMicrosoftLogging(log => - { - //log.AddConsole(LogLevel.Debug); - }) - .WithDictionaryHandle(); + //s.WithMicrosoftLogging(log => + //{ + // //log.AddConsole(LogLevel.Debug); + //}) + s.WithDictionaryHandle(); }; x.AddMvc(option => option.EnableEndpointRouting = false); x.AddOcelot() diff --git a/test/Ocelot.IntegrationTests/Ocelot.IntegrationTests.csproj b/test/Ocelot.IntegrationTests/Ocelot.IntegrationTests.csproj index b67ade8fb..1095a5a78 100644 --- a/test/Ocelot.IntegrationTests/Ocelot.IntegrationTests.csproj +++ b/test/Ocelot.IntegrationTests/Ocelot.IntegrationTests.csproj @@ -35,29 +35,29 @@ - + - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all all - - - - - - - - - - + + + + + + + + + + diff --git a/test/Ocelot.ManualTest/Ocelot.ManualTest.csproj b/test/Ocelot.ManualTest/Ocelot.ManualTest.csproj index bd6465080..a6b592e8c 100644 --- a/test/Ocelot.ManualTest/Ocelot.ManualTest.csproj +++ b/test/Ocelot.ManualTest/Ocelot.ManualTest.csproj @@ -49,13 +49,13 @@ all - - - - - - - - + + + + + + + + diff --git a/test/Ocelot.UnitTests/Ocelot.UnitTests.csproj b/test/Ocelot.UnitTests/Ocelot.UnitTests.csproj index 4718785d7..d9c7a480a 100644 --- a/test/Ocelot.UnitTests/Ocelot.UnitTests.csproj +++ b/test/Ocelot.UnitTests/Ocelot.UnitTests.csproj @@ -48,15 +48,15 @@ - + - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -64,30 +64,29 @@ all - + - - - - - - - - - - - - - - + + + + + + + + + + + + + - + - +