diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index f929bfb712..7ae50cedb5 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -31,17 +31,19 @@ jobs: steps: - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 with: dotnet-version: | - 6.0.* 8.0.* + 10.0.* - name: Git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 + with: + persist-credentials: false - name: Restore packages - run: dotnet restore ${{ env.SOLUTION_FILE }} --verbosity minimal + run: dotnet restore ${{ env.SOLUTION_FILE }} /p:Configuration=Release /p:NuGetAudit=false --verbosity minimal - name: Calculate package version (for release) if: ${{ github.event_name == 'release' }} @@ -108,7 +110,7 @@ jobs: run: dotnet pack ${{ env.SOLUTION_FILE }} --no-build --configuration Release --output ${{ github.workspace }}/packages /p:VersionSuffix=${{ env.PACKAGE_VERSION_SUFFIX }} - name: Upload unsigned packages - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: if-no-files-found: error name: unsigned-packages @@ -126,13 +128,13 @@ jobs: steps: - name: Download unsigned packages - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: unsigned-packages path: packages - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 with: dotnet-version: 8.0.* @@ -140,7 +142,7 @@ jobs: run: dotnet tool install --global sign --prerelease - name: Azure login - uses: azure/login@v2 + uses: azure/login@v3 with: client-id: ${{ secrets.AZURE_CLIENT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }} @@ -159,7 +161,7 @@ jobs: --description-url 'https://steeltoe.io/' - name: Upload signed packages - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: if-no-files-found: error name: signed-packages @@ -179,22 +181,22 @@ jobs: steps: - name: Azure login - uses: azure/login@v2 + uses: azure/login@v3 with: client-id: ${{ secrets.AZURE_CLIENT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }} subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - name: Download signed packages - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: signed-packages path: packages - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 with: - dotnet-version: 8.0.x + dotnet-version: 8.0.* source-url: ${{ vars.AZURE_ARTIFACTS_FEED_URL }} env: NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -223,12 +225,12 @@ jobs: steps: - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 with: - dotnet-version: 8.0.x + dotnet-version: 8.0.* - name: Download signed packages - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: signed-packages path: packages @@ -248,7 +250,9 @@ jobs: steps: - name: Git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 + with: + persist-credentials: true - name: Calculate next package version shell: pwsh diff --git a/.github/workflows/scan-vulnerable-dependencies.yml b/.github/workflows/scan-vulnerable-dependencies.yml index 1e023af0fb..e2beadeebd 100644 --- a/.github/workflows/scan-vulnerable-dependencies.yml +++ b/.github/workflows/scan-vulnerable-dependencies.yml @@ -27,14 +27,31 @@ jobs: steps: - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 with: dotnet-version: | - 6.0.* 8.0.* + 10.0.* - name: Git checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 + with: + persist-credentials: false - name: Report vulnerable dependencies - run: dotnet restore ${{ env.SOLUTION_FILE }} --verbosity minimal /p:NuGetAudit=true /p:NuGetAuditMode=all /p:NuGetAuditLevel=low /p:TreatWarningsAsErrors=True + shell: pwsh + run: | + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $true + + $output = dotnet list ${{ env.SOLUTION_FILE }} package --vulnerable --include-transitive --format json --output-version 1 2>&1 + $text = ($output | Out-String).TrimEnd() + $json = $text | ConvertFrom-Json + + foreach ($project in $json.projects) { + if ($project.frameworks) { + Write-Host 'Vulnerable package references were found.' + dotnet list ${{ env.SOLUTION_FILE }} package --vulnerable --include-transitive + exit 1 + } + } diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000000..0adeb95638 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,5 @@ + + + true + + diff --git a/azure-pipelines.yml b/azure-pipelines.yml index de735fa805..a0b1eb5d93 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -33,14 +33,14 @@ jobs: pool: vmImage: $(imageName) steps: - - task: UseDotNet@2 - displayName: Install .NET 6 - inputs: - version: 6.0.x - task: UseDotNet@2 displayName: Install .NET 8 inputs: version: 8.0.x + - task: UseDotNet@2 + displayName: Install .NET 10 + inputs: + version: 10.0.x - pwsh: | # https://github.com/dotnet/core/issues/4749#issuecomment-2329706172 wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.24_amd64.deb @@ -87,13 +87,6 @@ jobs: projects: '**/*.csproj' arguments: '--blame-hang-timeout 3m -f net8.0 --no-build -c $(buildConfiguration) -maxcpucount:1 $(skipFilter) --collect "XPlat Code Coverage" --settings coverlet.runsettings --logger trx --results-directory $(Build.SourcesDirectory)' publishTestResults: false - - task: DotNetCoreCLI@2 - displayName: dotnet test 6.0 - inputs: - command: test - projects: '**/*.csproj' - arguments: '--blame-hang-timeout 3m -f net6.0 --no-build -c $(buildConfiguration) -maxcpucount:1 $(skipFilter) --collect "XPlat Code Coverage" --settings coverlet.runsettings --logger trx --results-directory $(Build.SourcesDirectory)' - publishTestResults: false - task: CopyFiles@2 condition: failed() inputs: diff --git a/build/templates/component-build.yaml b/build/templates/component-build.yaml index 488ea5d415..3aab77f97e 100644 --- a/build/templates/component-build.yaml +++ b/build/templates/component-build.yaml @@ -16,14 +16,14 @@ jobs: pool: vmImage: ${{parameters.OS}}-latest steps: - - task: UseDotNet@2 - displayName: Install .NET 6 - inputs: - version: 6.0.x - task: UseDotNet@2 displayName: Install .NET 8 inputs: version: 8.0.x + - task: UseDotNet@2 + displayName: Install .NET 10 + inputs: + version: 10.0.x - task: DotNetCoreCLI@2 displayName: dotnet restore inputs: @@ -52,13 +52,6 @@ jobs: projects: $(SolutionFile) arguments: -f net8.0 ${{parameters.skipFilter}} $(CommonTestArgs) publishTestResults: false - - task: DotNetCoreCLI@2 - displayName: dotnet test 6.0 - inputs: - command: test - projects: $(SolutionFile) - arguments: -f net6.0 ${{parameters.skipFilter}} $(CommonTestArgs) - publishTestResults: false - task: CopyFiles@2 condition: failed() inputs: diff --git a/sharedproject.props b/sharedproject.props index c649dd6827..e88aada1bd 100644 --- a/sharedproject.props +++ b/sharedproject.props @@ -57,9 +57,4 @@ - - - - - diff --git a/sharedtest.props b/sharedtest.props index b2b473f1e5..4204528eec 100644 --- a/sharedtest.props +++ b/sharedtest.props @@ -37,9 +37,4 @@ runtime; build; native; contentfiles; analyzers - - - - - diff --git a/src/Bootstrap/src/Autoconfig/Steeltoe.Bootstrap.Autoconfig.csproj b/src/Bootstrap/src/Autoconfig/Steeltoe.Bootstrap.Autoconfig.csproj index 2941451c31..15bd583c0b 100644 --- a/src/Bootstrap/src/Autoconfig/Steeltoe.Bootstrap.Autoconfig.csproj +++ b/src/Bootstrap/src/Autoconfig/Steeltoe.Bootstrap.Autoconfig.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.Bootstrap.Autoconfig Package for automatically configuring Steeltoe packages that have separately been added to a project. Autoconfiguration;automatic configuration;application bootstrapping diff --git a/src/Bootstrap/test/Autoconfig.Test/HostBuilderExtensionsTest.cs b/src/Bootstrap/test/Autoconfig.Test/HostBuilderExtensionsTest.cs index d81af58743..b24daf8395 100644 --- a/src/Bootstrap/test/Autoconfig.Test/HostBuilderExtensionsTest.cs +++ b/src/Bootstrap/test/Autoconfig.Test/HostBuilderExtensionsTest.cs @@ -302,7 +302,7 @@ public void TracingBase_IsAutowired() Assert.NotNull(host.Services.GetService()); // confirm instrumentation(s) were added as expected - var instrumentations = tracerProvider.GetType().GetField("instrumentations", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(tracerProvider) as List; + var instrumentations = OpenTelemetrySdkReflection.GetTracerProviderInstrumentations(tracerProvider); Assert.NotNull(instrumentations); Assert.Single(instrumentations); Assert.Contains(instrumentations, obj => obj.GetType().Name.Contains("Http")); @@ -325,7 +325,7 @@ public void TracingCore_IsAutowired() Assert.NotNull(host.Services.GetService()); // confirm instrumentation(s) were added as expected - var instrumentations = tracerProvider.GetType().GetField("instrumentations", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(tracerProvider) as List; + var instrumentations = OpenTelemetrySdkReflection.GetTracerProviderInstrumentations(tracerProvider); Assert.NotNull(instrumentations); Assert.Equal(2, instrumentations.Count); Assert.Contains(instrumentations, obj => obj.GetType().Name.Contains("Http")); diff --git a/src/Bootstrap/test/Autoconfig.Test/OpenTelemetrySdkReflection.cs b/src/Bootstrap/test/Autoconfig.Test/OpenTelemetrySdkReflection.cs new file mode 100644 index 0000000000..3c2d47d86c --- /dev/null +++ b/src/Bootstrap/test/Autoconfig.Test/OpenTelemetrySdkReflection.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using OpenTelemetry.Trace; +using System.Collections.Generic; +using System.Reflection; + +namespace Steeltoe.Bootstrap.Autoconfig.Test; + +/// +/// Reflection helpers for OpenTelemetry SDK internals used by tests. +/// +public static class OpenTelemetrySdkReflection +{ + public static List GetTracerProviderInstrumentations(TracerProvider tracerProvider) + { + var property = tracerProvider?.GetType().GetProperty( + "Instrumentations", + BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); + + return property?.GetValue(tracerProvider) as List; + } +} diff --git a/src/Bootstrap/test/Autoconfig.Test/Steeltoe.Bootstrap.Autoconfig.Test.csproj b/src/Bootstrap/test/Autoconfig.Test/Steeltoe.Bootstrap.Autoconfig.Test.csproj index 3733993c4e..dd34cdc3e5 100644 --- a/src/Bootstrap/test/Autoconfig.Test/Steeltoe.Bootstrap.Autoconfig.Test.csproj +++ b/src/Bootstrap/test/Autoconfig.Test/Steeltoe.Bootstrap.Autoconfig.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Bootstrap/test/Autoconfig.Test/WebApplicationBuilderExtensionsTest.cs b/src/Bootstrap/test/Autoconfig.Test/WebApplicationBuilderExtensionsTest.cs index ecf0a7405a..be904523d9 100644 --- a/src/Bootstrap/test/Autoconfig.Test/WebApplicationBuilderExtensionsTest.cs +++ b/src/Bootstrap/test/Autoconfig.Test/WebApplicationBuilderExtensionsTest.cs @@ -40,11 +40,7 @@ namespace Steeltoe.Bootstrap.Autoconfig.Test { public class WebApplicationBuilderExtensionsTest { -#if NET8_0_OR_GREATER private const int ConfigurationProviderCountDelta = 2; -#else - private const int ConfigurationProviderCountDelta = 0; -#endif [Fact] public void ConfigServerConfiguration_IsAutowired() @@ -230,7 +226,7 @@ public void TracingBase_IsAutowired() Assert.NotNull(host.Services.GetService()); // confirm instrumentation(s) were added as expected - var instrumentations = tracerProvider.GetType().GetField("instrumentations", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(tracerProvider) as List; + var instrumentations = OpenTelemetrySdkReflection.GetTracerProviderInstrumentations(tracerProvider); Assert.NotNull(instrumentations); Assert.Single(instrumentations); Assert.Contains(instrumentations, obj => obj.GetType().Name.Contains("Http")); @@ -249,7 +245,7 @@ public void TracingCore_IsAutowired() Assert.NotNull(host.Services.GetService()); // confirm instrumentation(s) were added as expected - var instrumentations = tracerProvider.GetType().GetField("instrumentations", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(tracerProvider) as List; + var instrumentations = OpenTelemetrySdkReflection.GetTracerProviderInstrumentations(tracerProvider); Assert.NotNull(instrumentations); Assert.Equal(2, instrumentations.Count); Assert.Contains(instrumentations, obj => obj.GetType().Name.Contains("Http")); diff --git a/src/Bootstrap/test/Autoconfig.Test/WebHostBuilderExtensionsTest.cs b/src/Bootstrap/test/Autoconfig.Test/WebHostBuilderExtensionsTest.cs index 939ea5e864..e9098ac16c 100644 --- a/src/Bootstrap/test/Autoconfig.Test/WebHostBuilderExtensionsTest.cs +++ b/src/Bootstrap/test/Autoconfig.Test/WebHostBuilderExtensionsTest.cs @@ -308,7 +308,7 @@ public void TracingBase_IsAutowired() Assert.NotNull(host.Services.GetService()); // confirm instrumentation(s) were added as expected - var instrumentations = tracerProvider.GetType().GetField("instrumentations", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(tracerProvider) as List; + var instrumentations = OpenTelemetrySdkReflection.GetTracerProviderInstrumentations(tracerProvider); Assert.NotNull(instrumentations); Assert.Single(instrumentations); Assert.Contains(instrumentations, obj => obj.GetType().Name.Contains("Http")); @@ -331,7 +331,7 @@ public void TracingCore_IsAutowired() Assert.NotNull(host.Services.GetService()); // confirm instrumentation(s) were added as expected - var instrumentations = tracerProvider.GetType().GetField("instrumentations", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(tracerProvider) as List; + var instrumentations = OpenTelemetrySdkReflection.GetTracerProviderInstrumentations(tracerProvider); Assert.NotNull(instrumentations); Assert.Equal(2, instrumentations.Count); Assert.Contains(instrumentations, obj => obj.GetType().Name.Contains("Http")); diff --git a/src/CircuitBreaker/src/Abstractions/Steeltoe.CircuitBreaker.Abstractions.csproj b/src/CircuitBreaker/src/Abstractions/Steeltoe.CircuitBreaker.Abstractions.csproj index aa7b37fe69..58e4a56b76 100644 --- a/src/CircuitBreaker/src/Abstractions/Steeltoe.CircuitBreaker.Abstractions.csproj +++ b/src/CircuitBreaker/src/Abstractions/Steeltoe.CircuitBreaker.Abstractions.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe.CircuitBreaker Circuit breaker abstractions diff --git a/src/CircuitBreaker/src/Hystrix.MetricsEventsCore/Steeltoe.CircuitBreaker.Hystrix.MetricsEventsCore.csproj b/src/CircuitBreaker/src/Hystrix.MetricsEventsCore/Steeltoe.CircuitBreaker.Hystrix.MetricsEventsCore.csproj index 7baa421884..5db21be4fd 100644 --- a/src/CircuitBreaker/src/Hystrix.MetricsEventsCore/Steeltoe.CircuitBreaker.Hystrix.MetricsEventsCore.csproj +++ b/src/CircuitBreaker/src/Hystrix.MetricsEventsCore/Steeltoe.CircuitBreaker.Hystrix.MetricsEventsCore.csproj @@ -1,7 +1,7 @@ Steeltoe Netflix Hystrix Metrics Event Stream ASP.NET Core - net8.0;net6.0 + net8.0 aspnetcore;Circuit Breaker;Spring;Spring Cloud;Spring Cloud Hystrix;Hystrix diff --git a/src/CircuitBreaker/src/Hystrix.MetricsStreamCore/Steeltoe.CircuitBreaker.Hystrix.MetricsStreamCore.csproj b/src/CircuitBreaker/src/Hystrix.MetricsStreamCore/Steeltoe.CircuitBreaker.Hystrix.MetricsStreamCore.csproj index df89f3aa3d..1d6c648644 100644 --- a/src/CircuitBreaker/src/Hystrix.MetricsStreamCore/Steeltoe.CircuitBreaker.Hystrix.MetricsStreamCore.csproj +++ b/src/CircuitBreaker/src/Hystrix.MetricsStreamCore/Steeltoe.CircuitBreaker.Hystrix.MetricsStreamCore.csproj @@ -1,6 +1,6 @@  - net8.0;net6.0 + net8.0 Netflix Hystrix metrics event stream for ASP.NET Core over RabbitMQ aspnetcore;Circuit Breaker;Spring;Spring Cloud;Spring Cloud Hystrix;Hystrix;turbine;cloudfoundry diff --git a/src/CircuitBreaker/src/HystrixBase/Exceptions/HystrixRuntimeException.cs b/src/CircuitBreaker/src/HystrixBase/Exceptions/HystrixRuntimeException.cs index 71ad6c0316..882b61ae64 100644 --- a/src/CircuitBreaker/src/HystrixBase/Exceptions/HystrixRuntimeException.cs +++ b/src/CircuitBreaker/src/HystrixBase/Exceptions/HystrixRuntimeException.cs @@ -52,7 +52,9 @@ protected HystrixRuntimeException(SerializationInfo info, StreamingContext conte public Type ImplementingClass { get; } +#pragma warning disable CS0672 // Member overrides obsolete member public override void GetObjectData(SerializationInfo info, StreamingContext context) +#pragma warning restore CS0672 // Member overrides obsolete member { base.GetObjectData(info, context); } diff --git a/src/CircuitBreaker/src/HystrixBase/Steeltoe.CircuitBreaker.HystrixBase.csproj b/src/CircuitBreaker/src/HystrixBase/Steeltoe.CircuitBreaker.HystrixBase.csproj index e3ecda3b0b..0153672a64 100644 --- a/src/CircuitBreaker/src/HystrixBase/Steeltoe.CircuitBreaker.HystrixBase.csproj +++ b/src/CircuitBreaker/src/HystrixBase/Steeltoe.CircuitBreaker.HystrixBase.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe.CircuitBreaker.Hystrix Steeltoe's implementation of Netflix's Hystrix, for .NET Spring Cloud;Netflix;Hystrix Client;Circuit Breaker @@ -12,6 +12,8 @@ + + diff --git a/src/CircuitBreaker/src/HystrixCore/Steeltoe.CircuitBreaker.HystrixCore.csproj b/src/CircuitBreaker/src/HystrixCore/Steeltoe.CircuitBreaker.HystrixCore.csproj index e6e56d4b61..3e59063584 100644 --- a/src/CircuitBreaker/src/HystrixCore/Steeltoe.CircuitBreaker.HystrixCore.csproj +++ b/src/CircuitBreaker/src/HystrixCore/Steeltoe.CircuitBreaker.HystrixCore.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.CircuitBreaker.Hystrix Package for adding Steeltoe Hystrix to ASP.NET Core applications aspnetcore;Spring Cloud;Netflix;Hystrix Client;Circuit Breaker diff --git a/src/CircuitBreaker/test/Hystrix.MetricsEventsCore.Test/Steeltoe.CircuitBreaker.Hystrix.MetricsEventsCore.Test.csproj b/src/CircuitBreaker/test/Hystrix.MetricsEventsCore.Test/Steeltoe.CircuitBreaker.Hystrix.MetricsEventsCore.Test.csproj index 843c2e12d7..23ceff9f47 100644 --- a/src/CircuitBreaker/test/Hystrix.MetricsEventsCore.Test/Steeltoe.CircuitBreaker.Hystrix.MetricsEventsCore.Test.csproj +++ b/src/CircuitBreaker/test/Hystrix.MetricsEventsCore.Test/Steeltoe.CircuitBreaker.Hystrix.MetricsEventsCore.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/CircuitBreaker/test/Hystrix.MetricsStreamCore.Test/Steeltoe.CircuitBreaker.Hystrix.MetricsStreamCore.Test.csproj b/src/CircuitBreaker/test/Hystrix.MetricsStreamCore.Test/Steeltoe.CircuitBreaker.Hystrix.MetricsStreamCore.Test.csproj index 92fcbacf6f..573a16c0ed 100644 --- a/src/CircuitBreaker/test/Hystrix.MetricsStreamCore.Test/Steeltoe.CircuitBreaker.Hystrix.MetricsStreamCore.Test.csproj +++ b/src/CircuitBreaker/test/Hystrix.MetricsStreamCore.Test/Steeltoe.CircuitBreaker.Hystrix.MetricsStreamCore.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/CircuitBreaker/test/HystrixBase.Test/Steeltoe.CircuitBreaker.HystrixBase.Test.csproj b/src/CircuitBreaker/test/HystrixBase.Test/Steeltoe.CircuitBreaker.HystrixBase.Test.csproj index bfb1ec5158..f08a1c6cb2 100644 --- a/src/CircuitBreaker/test/HystrixBase.Test/Steeltoe.CircuitBreaker.HystrixBase.Test.csproj +++ b/src/CircuitBreaker/test/HystrixBase.Test/Steeltoe.CircuitBreaker.HystrixBase.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/CircuitBreaker/test/HystrixCore.Test/Steeltoe.CircuitBreaker.HystrixCore.Test.csproj b/src/CircuitBreaker/test/HystrixCore.Test/Steeltoe.CircuitBreaker.HystrixCore.Test.csproj index a9dd8c64a8..e35dfba3c6 100644 --- a/src/CircuitBreaker/test/HystrixCore.Test/Steeltoe.CircuitBreaker.HystrixCore.Test.csproj +++ b/src/CircuitBreaker/test/HystrixCore.Test/Steeltoe.CircuitBreaker.HystrixCore.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Common/src/Abstractions/Steeltoe.Common.Abstractions.csproj b/src/Common/src/Abstractions/Steeltoe.Common.Abstractions.csproj index 0157909c65..88ceb33dd5 100644 --- a/src/Common/src/Abstractions/Steeltoe.Common.Abstractions.csproj +++ b/src/Common/src/Abstractions/Steeltoe.Common.Abstractions.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Common Abstractions commonly used across Steeltoe components diff --git a/src/Common/src/Common.Expression/Steeltoe.Common.Expression.csproj b/src/Common/src/Common.Expression/Steeltoe.Common.Expression.csproj index ec4020d3f0..a8c023620c 100644 --- a/src/Common/src/Common.Expression/Steeltoe.Common.Expression.csproj +++ b/src/Common/src/Common.Expression/Steeltoe.Common.Expression.csproj @@ -1,7 +1,7 @@ Steeltoe common expression language library - netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Common.Expression Steeltoe.Common.Expression NET Core;Expression;SPEL diff --git a/src/Common/src/Common.Hosting/Steeltoe.Common.Hosting.csproj b/src/Common/src/Common.Hosting/Steeltoe.Common.Hosting.csproj index 5806844b25..dd31731b2c 100644 --- a/src/Common/src/Common.Hosting/Steeltoe.Common.Hosting.csproj +++ b/src/Common/src/Common.Hosting/Steeltoe.Common.Hosting.csproj @@ -1,7 +1,7 @@ Steeltoe library for common hosting-related utilities - net8.0;net6.0 + net8.0 Steeltoe.Common.Hosting Steeltoe.Common.Hosting NET Core;Cloud Hosting; diff --git a/src/Common/src/Common.Http/Steeltoe.Common.Http.csproj b/src/Common/src/Common.Http/Steeltoe.Common.Http.csproj index bd8b314356..2cac9c68d7 100644 --- a/src/Common/src/Common.Http/Steeltoe.Common.Http.csproj +++ b/src/Common/src/Common.Http/Steeltoe.Common.Http.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe common library for HTTP @@ -9,7 +9,7 @@ - + diff --git a/src/Common/src/Common.Kubernetes/StandardPodUtilities.cs b/src/Common/src/Common.Kubernetes/StandardPodUtilities.cs index 9c19c13b77..06adc804fc 100644 --- a/src/Common/src/Common.Kubernetes/StandardPodUtilities.cs +++ b/src/Common/src/Common.Kubernetes/StandardPodUtilities.cs @@ -42,8 +42,8 @@ public async Task GetCurrentPodAsync() try { var hostname = Environment.GetEnvironmentVariable("HOSTNAME"); - var rsp = await _kubernetes.ListNamespacedPodWithHttpMessagesAsync(_applicationOptions.NameSpace); - pod = rsp.Body.Items?.FirstOrDefault(p => p.Metadata.Name.Equals(hostname)); + var list = await _kubernetes.CoreV1.ListNamespacedPodAsync(_applicationOptions.NameSpace).ConfigureAwait(false); + pod = list.Items?.FirstOrDefault(p => p.Metadata.Name.Equals(hostname)); } catch (Exception e) { diff --git a/src/Common/src/Common.Kubernetes/Steeltoe.Common.Kubernetes.csproj b/src/Common/src/Common.Kubernetes/Steeltoe.Common.Kubernetes.csproj index 833fd92e96..f8c7ffc26e 100644 --- a/src/Common/src/Common.Kubernetes/Steeltoe.Common.Kubernetes.csproj +++ b/src/Common/src/Common.Kubernetes/Steeltoe.Common.Kubernetes.csproj @@ -1,6 +1,6 @@  - netstandard2.1;netstandard2.0 + net8.0 Steeltoe common library for Kubernetes Kubernetes diff --git a/src/Common/src/Common.Net/Steeltoe.Common.Net.csproj b/src/Common/src/Common.Net/Steeltoe.Common.Net.csproj index 9713c29b19..a64fafa0c6 100644 --- a/src/Common/src/Common.Net/Steeltoe.Common.Net.csproj +++ b/src/Common/src/Common.Net/Steeltoe.Common.Net.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe common library for network interaction diff --git a/src/Common/src/Common.RetryPolly/Steeltoe.Common.RetryPolly.csproj b/src/Common/src/Common.RetryPolly/Steeltoe.Common.RetryPolly.csproj index 8e095ea6d5..97e3f80bf6 100644 --- a/src/Common/src/Common.RetryPolly/Steeltoe.Common.RetryPolly.csproj +++ b/src/Common/src/Common.RetryPolly/Steeltoe.Common.RetryPolly.csproj @@ -1,7 +1,7 @@ Steeltoe library for handling retries - netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Common.RetryPolly Steeltoe.Common.Retry NET Core;Retry; diff --git a/src/Common/src/Common.Security/Steeltoe.Common.Security.csproj b/src/Common/src/Common.Security/Steeltoe.Common.Security.csproj index d1d0ccf518..ed16e78e5a 100644 --- a/src/Common/src/Common.Security/Steeltoe.Common.Security.csproj +++ b/src/Common/src/Common.Security/Steeltoe.Common.Security.csproj @@ -1,6 +1,6 @@ - netstandard2.1 + net8.0;netstandard2.1 Steeltoe common library for security diff --git a/src/Common/src/Common.Utils/Steeltoe.Common.Utils.csproj b/src/Common/src/Common.Utils/Steeltoe.Common.Utils.csproj index d9a5736f09..58ff8a4ffe 100644 --- a/src/Common/src/Common.Utils/Steeltoe.Common.Utils.csproj +++ b/src/Common/src/Common.Utils/Steeltoe.Common.Utils.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe common utility libraries diff --git a/src/Common/src/Common/Steeltoe.Common.csproj b/src/Common/src/Common/Steeltoe.Common.csproj index 24f71abd83..b05d8a8dcf 100644 --- a/src/Common/src/Common/Steeltoe.Common.csproj +++ b/src/Common/src/Common/Steeltoe.Common.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe common library @@ -13,8 +13,8 @@ - - + + diff --git a/src/Common/src/Common/Util/EncodingUtils.cs b/src/Common/src/Common/Util/EncodingUtils.cs index d2781d277e..69653a497b 100644 --- a/src/Common/src/Common/Util/EncodingUtils.cs +++ b/src/Common/src/Common/Util/EncodingUtils.cs @@ -11,7 +11,9 @@ public static class EncodingUtils { public static readonly Encoding Utf16 = new UnicodeEncoding(false, false); public static readonly Encoding Utf16be = new UnicodeEncoding(true, false); +#pragma warning disable SYSLIB0001 // Type or member is obsolete public static readonly Encoding Utf7 = new UTF7Encoding(true); +#pragma warning restore SYSLIB0001 // Type or member is obsolete public static readonly Encoding Utf8 = new UTF8Encoding(false); public static readonly Encoding Utf32 = new UTF32Encoding(false, false); public static readonly Encoding Utf32be = new UTF32Encoding(true, false); diff --git a/src/Common/test/Common.Expression.Test/Steeltoe.Common.Expression.Test.csproj b/src/Common/test/Common.Expression.Test/Steeltoe.Common.Expression.Test.csproj index ca7450f31d..6e1ce9323a 100644 --- a/src/Common/test/Common.Expression.Test/Steeltoe.Common.Expression.Test.csproj +++ b/src/Common/test/Common.Expression.Test/Steeltoe.Common.Expression.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.Common.Expression diff --git a/src/Common/test/Common.Hosting.Test/Steeltoe.Common.Hosting.Test.csproj b/src/Common/test/Common.Hosting.Test/Steeltoe.Common.Hosting.Test.csproj index c67f95c3e0..e1c5f47ce2 100644 --- a/src/Common/test/Common.Hosting.Test/Steeltoe.Common.Hosting.Test.csproj +++ b/src/Common/test/Common.Hosting.Test/Steeltoe.Common.Hosting.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Common/test/Common.Http.Test/Steeltoe.Common.Http.Test.csproj b/src/Common/test/Common.Http.Test/Steeltoe.Common.Http.Test.csproj index 2c85309409..badb5c2f9a 100644 --- a/src/Common/test/Common.Http.Test/Steeltoe.Common.Http.Test.csproj +++ b/src/Common/test/Common.Http.Test/Steeltoe.Common.Http.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Common/test/Common.Kubernetes.Test/StandardPodUtilitiesTest.cs b/src/Common/test/Common.Kubernetes.Test/StandardPodUtilitiesTest.cs index a72a00f089..4e1a156bb0 100644 --- a/src/Common/test/Common.Kubernetes.Test/StandardPodUtilitiesTest.cs +++ b/src/Common/test/Common.Kubernetes.Test/StandardPodUtilitiesTest.cs @@ -3,8 +3,10 @@ // See the LICENSE file in the project root for more information. using k8s; +using k8s.Models; using Microsoft.Extensions.Configuration; using RichardSzalay.MockHttp; +using Steeltoe.Common.TestResources; using Steeltoe.Extensions.Configuration.Kubernetes; using System; using System.Net; @@ -29,7 +31,7 @@ public async Task ReturnsNullOnFailureToGetCurrentPod() var mockHttpMessageHandler = new MockHttpMessageHandler(); mockHttpMessageHandler.Expect(HttpMethod.Get, "*").Respond(HttpStatusCode.NotFound); var appOptions = new KubernetesApplicationOptions(new ConfigurationBuilder().Build()); - using var client = new k8s.Kubernetes(new KubernetesClientConfiguration { Host = "http://localhost" }, httpClient: mockHttpMessageHandler.ToHttpClient()); + using var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); var utils = new StandardPodUtilities(appOptions, null, client); var getPodResult = await utils.GetCurrentPodAsync(); @@ -47,13 +49,13 @@ public async Task ReturnsPodOnSuccessGettingPod() mockHttpMessageHandler.Expect(HttpMethod.Get, "*").Respond(HttpStatusCode.OK, new StringContent(podListRsp)); var appOptions = new KubernetesApplicationOptions(new ConfigurationBuilder().Build()); - using var client = new k8s.Kubernetes(new KubernetesClientConfiguration { Host = "http://localhost" }, httpClient: mockHttpMessageHandler.ToHttpClient()); + using var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); var utils = new StandardPodUtilities(appOptions, null, client); var getPodResult = await utils.GetCurrentPodAsync(); Assert.NotNull(getPodResult); - Assert.Equal("default", getPodResult.Metadata.NamespaceProperty); + Assert.Equal("default", getPodResult.Metadata.Namespace()); Assert.Equal(hostname, getPodResult.Metadata.Name); Assert.Equal("10.244.1.128", getPodResult.Status.PodIP); Assert.Equal("default", getPodResult.Spec.ServiceAccountName); diff --git a/src/Common/test/Common.Kubernetes.Test/Steeltoe.Common.Kubernetes.Test.csproj b/src/Common/test/Common.Kubernetes.Test/Steeltoe.Common.Kubernetes.Test.csproj index 25f4fe8242..320aa4e4cb 100644 --- a/src/Common/test/Common.Kubernetes.Test/Steeltoe.Common.Kubernetes.Test.csproj +++ b/src/Common/test/Common.Kubernetes.Test/Steeltoe.Common.Kubernetes.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Common/test/Common.Net.Test/Steeltoe.Common.Net.Test.csproj b/src/Common/test/Common.Net.Test/Steeltoe.Common.Net.Test.csproj index 999bf72860..00bbe392b4 100644 --- a/src/Common/test/Common.Net.Test/Steeltoe.Common.Net.Test.csproj +++ b/src/Common/test/Common.Net.Test/Steeltoe.Common.Net.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Common/test/Common.RetryPolly.Test/Steeltoe.Common.RetryPolly.Test.csproj b/src/Common/test/Common.RetryPolly.Test/Steeltoe.Common.RetryPolly.Test.csproj index 520e97b4de..4b0779372f 100644 --- a/src/Common/test/Common.RetryPolly.Test/Steeltoe.Common.RetryPolly.Test.csproj +++ b/src/Common/test/Common.RetryPolly.Test/Steeltoe.Common.RetryPolly.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Common/test/Common.Security.Test/Steeltoe.Common.Security.Test.csproj b/src/Common/test/Common.Security.Test/Steeltoe.Common.Security.Test.csproj index 80ef4cc351..06731d53c9 100644 --- a/src/Common/test/Common.Security.Test/Steeltoe.Common.Security.Test.csproj +++ b/src/Common/test/Common.Security.Test/Steeltoe.Common.Security.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Common/test/Common.Test/Steeltoe.Common.Test.csproj b/src/Common/test/Common.Test/Steeltoe.Common.Test.csproj index 3e31f221df..7e4592c38e 100644 --- a/src/Common/test/Common.Test/Steeltoe.Common.Test.csproj +++ b/src/Common/test/Common.Test/Steeltoe.Common.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Common/test/Common.TestResources/KubernetesTestClientFactory.cs b/src/Common/test/Common.TestResources/KubernetesTestClientFactory.cs new file mode 100644 index 0000000000..dc2d4b265f --- /dev/null +++ b/src/Common/test/Common.TestResources/KubernetesTestClientFactory.cs @@ -0,0 +1,60 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using k8s; +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; + +namespace Steeltoe.Common.TestResources; + +/// +/// Builds instances for tests using the same constructor pipeline as the upstream client +/// (Kubernetes.ConfigInit.cs). +/// has a protected setter, so tests cannot assign an directly. +/// +public static class KubernetesTestClientFactory +{ + /// + /// Creates a client that routes requests through (for example, MockHttpMessageHandler). + /// + /// Client configuration (must include a valid ). + /// The terminal handler that produces mock or test responses. + public static Kubernetes Create(KubernetesClientConfiguration configuration, HttpMessageHandler innerHandler) + { + if (configuration is null) + { + throw new ArgumentNullException(nameof(configuration)); + } + + if (innerHandler is null) + { + throw new ArgumentNullException(nameof(innerHandler)); + } + + return new Kubernetes(configuration, new DelegatingHandler[] { new RequestForwardingHandler(innerHandler) }); + } + + private sealed class RequestForwardingHandler : DelegatingHandler + { + private readonly HttpMessageInvoker _invoker; + + public RequestForwardingHandler(HttpMessageHandler inner) => + _invoker = new HttpMessageInvoker(inner, disposeHandler: false); + + protected override void Dispose(bool disposing) + { + if (disposing) + { + _invoker.Dispose(); + } + + base.Dispose(disposing); + } + + protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) => + _invoker.SendAsync(request, cancellationToken); + } +} diff --git a/src/Common/test/Common.TestResources/Steeltoe.Common.TestResources.csproj b/src/Common/test/Common.TestResources/Steeltoe.Common.TestResources.csproj index 6e942fdb44..165a4c6525 100644 --- a/src/Common/test/Common.TestResources/Steeltoe.Common.TestResources.csproj +++ b/src/Common/test/Common.TestResources/Steeltoe.Common.TestResources.csproj @@ -1,6 +1,6 @@  - net8.0;net6.0 + net8.0 false @@ -8,6 +8,7 @@ + @@ -25,4 +26,4 @@ - \ No newline at end of file + diff --git a/src/Common/test/Common.Utils.Test/Steeltoe.Common.Utils.Test.csproj b/src/Common/test/Common.Utils.Test/Steeltoe.Common.Utils.Test.csproj index e6627c7698..4dc8bd6685 100644 --- a/src/Common/test/Common.Utils.Test/Steeltoe.Common.Utils.Test.csproj +++ b/src/Common/test/Common.Utils.Test/Steeltoe.Common.Utils.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Configuration/src/Abstractions/Steeltoe.Extensions.Configuration.Abstractions.csproj b/src/Configuration/src/Abstractions/Steeltoe.Extensions.Configuration.Abstractions.csproj index 045aa3ddd0..cb5eafdbf3 100644 --- a/src/Configuration/src/Abstractions/Steeltoe.Extensions.Configuration.Abstractions.csproj +++ b/src/Configuration/src/Abstractions/Steeltoe.Extensions.Configuration.Abstractions.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0;netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Extensions.Configuration Abstractions used in Steeltoe Configuration libraries diff --git a/src/Configuration/src/CloudFoundryBase/Steeltoe.Extensions.Configuration.CloudFoundryBase.csproj b/src/Configuration/src/CloudFoundryBase/Steeltoe.Extensions.Configuration.CloudFoundryBase.csproj index 566b1e6602..6148e39a8e 100644 --- a/src/Configuration/src/CloudFoundryBase/Steeltoe.Extensions.Configuration.CloudFoundryBase.csproj +++ b/src/Configuration/src/CloudFoundryBase/Steeltoe.Extensions.Configuration.CloudFoundryBase.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Extensions.Configuration.CloudFoundry Configuration Provider for reading Cloud Foundry Environment Variables configuration;CloudFoundry;vcap diff --git a/src/Configuration/src/CloudFoundryCore/Steeltoe.Extensions.Configuration.CloudFoundryCore.csproj b/src/Configuration/src/CloudFoundryCore/Steeltoe.Extensions.Configuration.CloudFoundryCore.csproj index 5188a8b353..86dcc8e1b5 100644 --- a/src/Configuration/src/CloudFoundryCore/Steeltoe.Extensions.Configuration.CloudFoundryCore.csproj +++ b/src/Configuration/src/CloudFoundryCore/Steeltoe.Extensions.Configuration.CloudFoundryCore.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.Extensions.Configuration.CloudFoundry Package for adding Cloud Foundry environment variable configuration provider to ASP.NET Core applications aspnetcore;CloudFoundry;Spring;Spring Cloud;vcap diff --git a/src/Configuration/src/ConfigServerBase/ConfigServerConfigurationProvider.cs b/src/Configuration/src/ConfigServerBase/ConfigServerConfigurationProvider.cs index 9c19ec1186..cd011b9b81 100644 --- a/src/Configuration/src/ConfigServerBase/ConfigServerConfigurationProvider.cs +++ b/src/Configuration/src/ConfigServerBase/ConfigServerConfigurationProvider.cs @@ -790,7 +790,7 @@ protected internal void AddPropertySource(PropertySource source, IDictionary - netstandard2.1;netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Extensions.Configuration.ConfigServer Configuration provider for reading from Spring Cloud Config Server configuration;Spring Cloud;Spring Cloud Config Server @@ -10,7 +10,7 @@ - + diff --git a/src/Configuration/src/ConfigServerCore/Steeltoe.Extensions.Configuration.ConfigServerCore.csproj b/src/Configuration/src/ConfigServerCore/Steeltoe.Extensions.Configuration.ConfigServerCore.csproj index 1f3256b67b..dea5b47c59 100644 --- a/src/Configuration/src/ConfigServerCore/Steeltoe.Extensions.Configuration.ConfigServerCore.csproj +++ b/src/Configuration/src/ConfigServerCore/Steeltoe.Extensions.Configuration.ConfigServerCore.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.Extensions.Configuration.ConfigServer Package for adding Spring Cloud Config Server configuration provider to ASP.NET Core applications aspnetcore;Spring Cloud;Spring Cloud Config Server diff --git a/src/Configuration/src/Kubernetes.ServiceBinding/Steeltoe.Extensions.Configuration.Kubernetes.ServiceBinding.csproj b/src/Configuration/src/Kubernetes.ServiceBinding/Steeltoe.Extensions.Configuration.Kubernetes.ServiceBinding.csproj index a9e22df4e9..87c0b02ba0 100644 --- a/src/Configuration/src/Kubernetes.ServiceBinding/Steeltoe.Extensions.Configuration.Kubernetes.ServiceBinding.csproj +++ b/src/Configuration/src/Kubernetes.ServiceBinding/Steeltoe.Extensions.Configuration.Kubernetes.ServiceBinding.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Configuration Provider for reading Kubernetes Service Bindings Configuration;Kubernetes;Services;Bindings true diff --git a/src/Configuration/src/KubernetesBase/KubernetesConfigMapProvider.cs b/src/Configuration/src/KubernetesBase/KubernetesConfigMapProvider.cs index dfa007340e..5e95e0a02e 100644 --- a/src/Configuration/src/KubernetesBase/KubernetesConfigMapProvider.cs +++ b/src/Configuration/src/KubernetesBase/KubernetesConfigMapProvider.cs @@ -3,10 +3,10 @@ // See the LICENSE file in the project root for more information. using k8s; +using k8s.Autorest; using k8s.Models; using Microsoft.Extensions.Configuration.Json; using Microsoft.Extensions.Logging; -using Microsoft.Rest; using Steeltoe.Common.Kubernetes; using System; using System.Collections.Generic; @@ -35,8 +35,8 @@ public override void Load() { try { - var configMapResponse = K8sClient.ReadNamespacedConfigMapWithHttpMessagesAsync(Settings.Name, Settings.Namespace).GetAwaiter().GetResult(); - ProcessData(configMapResponse.Body); + var configMap = K8sClient.CoreV1.ReadNamespacedConfigMap(Settings.Name, Settings.Namespace); + ProcessData(configMap); EnableReloading(); } catch (HttpOperationException e) @@ -89,9 +89,9 @@ private void EnableReloading() switch (Settings.ReloadSettings.Mode) { case ReloadMethods.Event: - ConfigMapWatcher = K8sClient.WatchNamespacedConfigMapAsync( - Settings.Name, - Settings.Namespace, + ConfigMapWatcher = K8sClient.CoreV1.WatchListNamespacedConfigMap( + namespaceParameter: Settings.Namespace, + fieldSelector: $"metadata.name={Settings.Name}", onEvent: (eventType, item) => { Logger?.LogInformation("Recieved {eventType} event for ConfigMap {configMapName} with {entries} values", eventType.ToString(), Settings.Name, item?.Data?.Count); @@ -111,7 +111,7 @@ private void EnableReloading() { Logger?.LogCritical(exception, "ConfigMap watcher on {namespace}.{name} encountered an error!", Settings.Namespace, Settings.Name); }, - onClosed: () => { Logger?.LogInformation("ConfigMap watcher on {namespace}.{name} connection has closed", Settings.Namespace, Settings.Name); }).GetAwaiter().GetResult(); + onClosed: () => { Logger?.LogInformation("ConfigMap watcher on {namespace}.{name} connection has closed", Settings.Namespace, Settings.Name); }); break; case ReloadMethods.Polling: StartPolling(Settings.ReloadSettings.Period); diff --git a/src/Configuration/src/KubernetesBase/KubernetesSecretProvider.cs b/src/Configuration/src/KubernetesBase/KubernetesSecretProvider.cs index 9da215b441..9e56ec4e0c 100644 --- a/src/Configuration/src/KubernetesBase/KubernetesSecretProvider.cs +++ b/src/Configuration/src/KubernetesBase/KubernetesSecretProvider.cs @@ -3,9 +3,9 @@ // See the LICENSE file in the project root for more information. using k8s; +using k8s.Autorest; using k8s.Models; using Microsoft.Extensions.Logging; -using Microsoft.Rest; using Steeltoe.Common.Kubernetes; using System; using System.Collections.Generic; @@ -31,8 +31,8 @@ public override void Load() { try { - var secretResponse = K8sClient.ReadNamespacedSecretWithHttpMessagesAsync(Settings.Name, Settings.Namespace).GetAwaiter().GetResult(); - ProcessData(secretResponse.Body); + var secret = K8sClient.CoreV1.ReadNamespacedSecret(Settings.Name, Settings.Namespace); + ProcessData(secret); EnableReloading(); } catch (HttpOperationException e) @@ -82,9 +82,9 @@ private void EnableReloading() switch (Settings.ReloadSettings.Mode) { case ReloadMethods.Event: - SecretWatcher = K8sClient.WatchNamespacedSecretAsync( - Settings.Name, - Settings.Namespace, + SecretWatcher = K8sClient.CoreV1.WatchListNamespacedSecret( + namespaceParameter: Settings.Namespace, + fieldSelector: $"metadata.name={Settings.Name}", onEvent: (eventType, item) => { Logger?.LogInformation("Receved {eventType} event for Secret {secretName} with {entries} values", eventType.ToString(), Settings.Name, item?.Data?.Count); @@ -104,7 +104,7 @@ private void EnableReloading() { Logger?.LogCritical(exception, "Secret watcher on {namespace}.{name} encountered an error!", Settings.Namespace, Settings.Name); }, - onClosed: () => { Logger?.LogInformation("Secret watcher on {namespace}.{name} connection has closed", Settings.Namespace, Settings.Name); }).GetAwaiter().GetResult(); + onClosed: () => { Logger?.LogInformation("Secret watcher on {namespace}.{name} connection has closed", Settings.Namespace, Settings.Name); }); break; case ReloadMethods.Polling: if (!Polling) diff --git a/src/Configuration/src/KubernetesBase/Steeltoe.Extensions.Configuration.KubernetesBase.csproj b/src/Configuration/src/KubernetesBase/Steeltoe.Extensions.Configuration.KubernetesBase.csproj index 77fd05ff7d..37b3b11bee 100644 --- a/src/Configuration/src/KubernetesBase/Steeltoe.Extensions.Configuration.KubernetesBase.csproj +++ b/src/Configuration/src/KubernetesBase/Steeltoe.Extensions.Configuration.KubernetesBase.csproj @@ -1,6 +1,6 @@ - netstandard2.1;netstandard2.0 + net8.0 Steeltoe.Extensions.Configuration.Kubernetes Configuration Provider for reading Cloud Foundry Environment Variables configuration;Kubernetes diff --git a/src/Configuration/src/KubernetesCore/Steeltoe.Extensions.Configuration.KubernetesCore.csproj b/src/Configuration/src/KubernetesCore/Steeltoe.Extensions.Configuration.KubernetesCore.csproj index a6c5fe741c..4acb3c21e1 100644 --- a/src/Configuration/src/KubernetesCore/Steeltoe.Extensions.Configuration.KubernetesCore.csproj +++ b/src/Configuration/src/KubernetesCore/Steeltoe.Extensions.Configuration.KubernetesCore.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.Extensions.Configuration.Kubernetes Package for adding Kubernetes environment variables, ConfigMaps and Secrets to .NET applications Kubernetes;Spring;Spring Cloud;configuration;configmap diff --git a/src/Configuration/src/PlaceholderBase/Steeltoe.Extensions.Configuration.PlaceholderBase.csproj b/src/Configuration/src/PlaceholderBase/Steeltoe.Extensions.Configuration.PlaceholderBase.csproj index 823f75614c..854794663e 100644 --- a/src/Configuration/src/PlaceholderBase/Steeltoe.Extensions.Configuration.PlaceholderBase.csproj +++ b/src/Configuration/src/PlaceholderBase/Steeltoe.Extensions.Configuration.PlaceholderBase.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0;netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Extensions.Configuration.Placeholder Configuration provider for resolving property placeholders in configuration values configuration;placeholders;spring boot diff --git a/src/Configuration/src/PlaceholderCore/Steeltoe.Extensions.Configuration.PlaceholderCore.csproj b/src/Configuration/src/PlaceholderCore/Steeltoe.Extensions.Configuration.PlaceholderCore.csproj index 1c388faae5..611d362806 100644 --- a/src/Configuration/src/PlaceholderCore/Steeltoe.Extensions.Configuration.PlaceholderCore.csproj +++ b/src/Configuration/src/PlaceholderCore/Steeltoe.Extensions.Configuration.PlaceholderCore.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.Extensions.Configuration.Placeholder Packing for adding property placeholder resolving config provider to ASP.NET Core applications configuration;placeholders;aspnetcore;spring boot diff --git a/src/Configuration/src/RandomValueBase/Steeltoe.Extensions.Configuration.RandomValueBase.csproj b/src/Configuration/src/RandomValueBase/Steeltoe.Extensions.Configuration.RandomValueBase.csproj index 99754c5e05..73db954b85 100644 --- a/src/Configuration/src/RandomValueBase/Steeltoe.Extensions.Configuration.RandomValueBase.csproj +++ b/src/Configuration/src/RandomValueBase/Steeltoe.Extensions.Configuration.RandomValueBase.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Extensions.Configuration.RandomValue Configuration provider for generating random values configuration;random values diff --git a/src/Configuration/src/SpringBootBase/Steeltoe.Extensions.Configuration.SpringBootBase.csproj b/src/Configuration/src/SpringBootBase/Steeltoe.Extensions.Configuration.SpringBootBase.csproj index 1b0dba9c5b..1c7187f5ef 100644 --- a/src/Configuration/src/SpringBootBase/Steeltoe.Extensions.Configuration.SpringBootBase.csproj +++ b/src/Configuration/src/SpringBootBase/Steeltoe.Extensions.Configuration.SpringBootBase.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Extensions.Configuration.SpringBoot Configuration provider for reading Spring Boot style configuration configuration;springboot diff --git a/src/Configuration/src/SpringBootCore/Steeltoe.Extensions.Configuration.SpringBootCore.csproj b/src/Configuration/src/SpringBootCore/Steeltoe.Extensions.Configuration.SpringBootCore.csproj index 52435e5718..87191b740f 100644 --- a/src/Configuration/src/SpringBootCore/Steeltoe.Extensions.Configuration.SpringBootCore.csproj +++ b/src/Configuration/src/SpringBootCore/Steeltoe.Extensions.Configuration.SpringBootCore.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.Extensions.Configuration.SpringBoot Configuration provider for reading Spring Boot style configuration configuration;springboot diff --git a/src/Configuration/test/CloudFoundryBase.Test/Steeltoe.Extensions.Configuration.CloudFoundryBase.Test.csproj b/src/Configuration/test/CloudFoundryBase.Test/Steeltoe.Extensions.Configuration.CloudFoundryBase.Test.csproj index 1bf09a49ee..d3f46d0316 100644 --- a/src/Configuration/test/CloudFoundryBase.Test/Steeltoe.Extensions.Configuration.CloudFoundryBase.Test.csproj +++ b/src/Configuration/test/CloudFoundryBase.Test/Steeltoe.Extensions.Configuration.CloudFoundryBase.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Configuration/test/CloudFoundryCore.Test/Steeltoe.Extensions.Configuration.CloudFoundryCore.Test.csproj b/src/Configuration/test/CloudFoundryCore.Test/Steeltoe.Extensions.Configuration.CloudFoundryCore.Test.csproj index 647a1edb3c..42634418f4 100644 --- a/src/Configuration/test/CloudFoundryCore.Test/Steeltoe.Extensions.Configuration.CloudFoundryCore.Test.csproj +++ b/src/Configuration/test/CloudFoundryCore.Test/Steeltoe.Extensions.Configuration.CloudFoundryCore.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Configuration/test/ConfigServer.ITest/Steeltoe.Extensions.Configuration.ConfigServer.ITest.csproj b/src/Configuration/test/ConfigServer.ITest/Steeltoe.Extensions.Configuration.ConfigServer.ITest.csproj index 94beeaf27b..3ad2d3fc65 100644 --- a/src/Configuration/test/ConfigServer.ITest/Steeltoe.Extensions.Configuration.ConfigServer.ITest.csproj +++ b/src/Configuration/test/ConfigServer.ITest/Steeltoe.Extensions.Configuration.ConfigServer.ITest.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Configuration/test/ConfigServerBase.Test/Steeltoe.Extensions.Configuration.ConfigServerBase.Test.csproj b/src/Configuration/test/ConfigServerBase.Test/Steeltoe.Extensions.Configuration.ConfigServerBase.Test.csproj index e0a245ac32..c11a7afb1d 100644 --- a/src/Configuration/test/ConfigServerBase.Test/Steeltoe.Extensions.Configuration.ConfigServerBase.Test.csproj +++ b/src/Configuration/test/ConfigServerBase.Test/Steeltoe.Extensions.Configuration.ConfigServerBase.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.Extensions.Configuration.ConfigServer.Test diff --git a/src/Configuration/test/ConfigServerCore.Test/Steeltoe.Extensions.Configuration.ConfigServerCore.Test.csproj b/src/Configuration/test/ConfigServerCore.Test/Steeltoe.Extensions.Configuration.ConfigServerCore.Test.csproj index 82f6a7757b..0700f02f18 100644 --- a/src/Configuration/test/ConfigServerCore.Test/Steeltoe.Extensions.Configuration.ConfigServerCore.Test.csproj +++ b/src/Configuration/test/ConfigServerCore.Test/Steeltoe.Extensions.Configuration.ConfigServerCore.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Configuration/test/Kubernetes.ServiceBinding.Test/Steeltoe.Extensions.Configuration.Kubernetes.ServiceBinding.Test.csproj b/src/Configuration/test/Kubernetes.ServiceBinding.Test/Steeltoe.Extensions.Configuration.Kubernetes.ServiceBinding.Test.csproj index 62d85783ef..6cc0d36b9e 100644 --- a/src/Configuration/test/Kubernetes.ServiceBinding.Test/Steeltoe.Extensions.Configuration.Kubernetes.ServiceBinding.Test.csproj +++ b/src/Configuration/test/Kubernetes.ServiceBinding.Test/Steeltoe.Extensions.Configuration.Kubernetes.ServiceBinding.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Configuration/test/KubernetesBase.Test/KubernetesConfigMapProviderTest.cs b/src/Configuration/test/KubernetesBase.Test/KubernetesConfigMapProviderTest.cs index ed63c4ad85..eeff60e108 100644 --- a/src/Configuration/test/KubernetesBase.Test/KubernetesConfigMapProviderTest.cs +++ b/src/Configuration/test/KubernetesBase.Test/KubernetesConfigMapProviderTest.cs @@ -3,11 +3,12 @@ // See the LICENSE file in the project root for more information. using k8s; +using k8s.Autorest; using Microsoft.Extensions.Logging; -using Microsoft.Rest; using Moq; using RichardSzalay.MockHttp; using Steeltoe.Common.Kubernetes; +using Steeltoe.Common.TestResources; using System; using System.Net; using System.Net.Http; @@ -22,7 +23,7 @@ public class KubernetesConfigMapProviderTest [Fact] public void KubernetesConfigMapProvider_ThrowsOnNulls() { - var client = new Mock(); + var client = new Mock(); var settings = new KubernetesConfigSourceSettings("default", "test", new ReloadSettings()); var ex1 = Assert.Throws(() => new KubernetesConfigMapProvider(null, settings)); @@ -38,7 +39,7 @@ public void KubernetesConfigMapProvider_ThrowsOn403() var mockHttpMessageHandler = new MockHttpMessageHandler(); mockHttpMessageHandler.Expect(HttpMethod.Get, "*").Respond(HttpStatusCode.Forbidden); - using var client = new k8s.Kubernetes(new KubernetesClientConfiguration { Host = "http://localhost" }, httpClient: mockHttpMessageHandler.ToHttpClient()); + using var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); var settings = new KubernetesConfigSourceSettings("default", "test", new ReloadSettings()); var provider = new KubernetesConfigMapProvider(client, settings); @@ -53,7 +54,7 @@ public async Task KubernetesConfigMapProvider_ContinuesOn404() var mockHttpMessageHandler = new MockHttpMessageHandler(); mockHttpMessageHandler.Expect(HttpMethod.Get, "*").Respond(HttpStatusCode.NotFound); - using var client = new k8s.Kubernetes(new KubernetesClientConfiguration { Host = "http://localhost" }, httpClient: mockHttpMessageHandler.ToHttpClient()); + using var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); var settings = new KubernetesConfigSourceSettings("default", "test", new ReloadSettings() { ConfigMaps = true, Period = 0 }); var provider = new KubernetesConfigMapProvider(client, settings); @@ -71,7 +72,7 @@ public void KubernetesConfigMapProvider_AddsToDictionaryOnSuccess() .Expect(HttpMethod.Get, "*") .Respond(new StringContent("{\"kind\":\"ConfigMap\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"testconfigmap\",\"namespace\":\"default\",\"selfLink\":\"/api/v1/namespaces/default/configmaps/testconfigmap\",\"uid\":\"8582b94c-f4fa-47fa-bacc-47019223775c\",\"resourceVersion\":\"1320622\",\"creationTimestamp\":\"2020-04-15T18:33:49Z\",\"annotations\":{\"kubectl.kubernetes.io/last-applied-configuration\":\"{\\\"apiVersion\\\":\\\"v1\\\",\\\"data\\\":{\\\"ConfigMapName\\\":\\\"testconfigmap\\\"},\\\"kind\\\":\\\"ConfigMap\\\",\\\"metadata\\\":{\\\"annotations\\\":{},\\\"name\\\":\\\"kubernetes1\\\",\\\"namespace\\\":\\\"default\\\"}}\\n\"}},\"data\":{\"TestKey\":\"TestValue\"}}\n")); - using var client = new k8s.Kubernetes(new KubernetesClientConfiguration { Host = "http://localhost" }, httpClient: mockHttpMessageHandler.ToHttpClient()); + using var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); var settings = new KubernetesConfigSourceSettings("default", "testconfigmap", new ReloadSettings()); var provider = new KubernetesConfigMapProvider(client, settings); @@ -89,7 +90,7 @@ public void KubernetesConfigMapProvider_SeesDoubleUnderscore() .Expect(HttpMethod.Get, "*") .Respond(new StringContent("{\"kind\":\"ConfigMap\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"testconfigmap\",\"namespace\":\"default\",\"selfLink\":\"/api/v1/namespaces/default/configmaps/testconfigmap\",\"uid\":\"8582b94c-f4fa-47fa-bacc-47019223775c\",\"resourceVersion\":\"1320622\",\"creationTimestamp\":\"2020-04-15T18:33:49Z\",\"annotations\":{\"kubectl.kubernetes.io/last-applied-configuration\":\"{\\\"apiVersion\\\":\\\"v1\\\",\\\"data\\\":{\\\"ConfigMapName\\\":\\\"testconfigmap\\\"},\\\"kind\\\":\\\"ConfigMap\\\",\\\"metadata\\\":{\\\"annotations\\\":{},\\\"name\\\":\\\"kubernetes1\\\",\\\"namespace\\\":\\\"default\\\"}}\\n\"}},\"data\":{\"several__layers__deep__TestKey\":\"TestValue\"}}\n")); - using var client = new k8s.Kubernetes(new KubernetesClientConfiguration { Host = "http://localhost" }, httpClient: mockHttpMessageHandler.ToHttpClient()); + using var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); var settings = new KubernetesConfigSourceSettings("default", "testconfigmap", new ReloadSettings()); var provider = new KubernetesConfigMapProvider(client, settings); @@ -114,7 +115,7 @@ public async Task KubernetesConfigMapProvider_ReloadsDictionaryOnInterval() .Expect(HttpMethod.Get, "*") .Respond(new StringContent("{\"kind\":\"ConfigMap\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"testconfigmap\",\"namespace\":\"default\",\"selfLink\":\"/api/v1/namespaces/default/configmaps/testconfigmap\",\"uid\":\"8582b94c-f4fa-47fa-bacc-47019223775c\",\"resourceVersion\":\"1320622\",\"creationTimestamp\":\"2020-04-15T18:33:49Z\",\"annotations\":{\"kubectl.kubernetes.io/last-applied-configuration\":\"{\\\"apiVersion\\\":\\\"v1\\\",\\\"data\\\":{\\\"ConfigMapName\\\":\\\"testconfigmap\\\"},\\\"kind\\\":\\\"ConfigMap\\\",\\\"metadata\\\":{\\\"annotations\\\":{},\\\"name\\\":\\\"kubernetes1\\\",\\\"namespace\\\":\\\"default\\\"}}\\n\"}},\"data\":{\"TestKey3\":\"UpdatedAgain\"}}\n")); - using var client = new k8s.Kubernetes(new KubernetesClientConfiguration { Host = "http://localhost" }, httpClient: mockHttpMessageHandler.ToHttpClient()); + using var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); var settings = new KubernetesConfigSourceSettings("default", "testconfigmap", new ReloadSettings() { Period = 1, ConfigMaps = true }); var provider = new KubernetesConfigMapProvider(client, settings, new CancellationTokenSource(20000).Token); @@ -155,10 +156,10 @@ public void KubernetesConfigMapProvider_AddsJsonFileToDictionaryOnSuccess() mockHttpMessageHandler .Expect(HttpMethod.Get, "*") .Respond(new StringContent("{\"kind\":\"ConfigMap\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"testconfigmap\",\"namespace\":\"default\",\"selfLink\":\"/api/v1/namespaces/default/configmaps/testconfigmap\",\"uid\":\"8582b94c-f4fa-47fa-bacc-47019223775c\",\"resourceVersion\":\"1320622\",\"creationTimestamp\":\"2020-04-15T18:33:49Z\",\"annotations\":{\"kubectl.kubernetes.io/last-applied-configuration\":\"{\\\"apiVersion\\\":\\\"v1\\\",\\\"data\\\":{\\\"ConfigMapName\\\":\\\"testconfigmap\\\"},\\\"kind\\\":\\\"ConfigMap\\\",\\\"metadata\\\":{\\\"annotations\\\":{},\\\"name\\\":\\\"kubernetes1\\\",\\\"namespace\\\":\\\"default\\\"}}\\n\"}},\"data\":{" + - "\"appsettings.json\": \"{\n \\\"Test0\\\": \\\"Value0\\\",\n \\\"Test1\\\": [\n {\n \\\"Test2\\\": \\\"Value1\\\"\n }\n ]\n}\"" + + "\"appsettings.json\": \"{\\\"Test0\\\": \\\"Value0\\\",\\\"Test1\\\": [{\\\"Test2\\\": \\\"Value1\\\"}]}\"" + "}\n}\n")); - using var client = new k8s.Kubernetes(new KubernetesClientConfiguration { Host = "http://localhost" }, httpClient: mockHttpMessageHandler.ToHttpClient()); + using var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); var settings = new KubernetesConfigSourceSettings("default", "testconfigmap", new ReloadSettings()); var provider = new KubernetesConfigMapProvider(client, settings); @@ -178,10 +179,10 @@ public void KubernetesConfigMapProvider_AddsEnvSpecificJsonFileToDictionaryOnSuc mockHttpMessageHandler .Expect(HttpMethod.Get, "*") .Respond(new StringContent("{\"kind\":\"ConfigMap\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"testconfigmap\",\"namespace\":\"default\",\"selfLink\":\"/api/v1/namespaces/default/configmaps/testconfigmap\",\"uid\":\"8582b94c-f4fa-47fa-bacc-47019223775c\",\"resourceVersion\":\"1320622\",\"creationTimestamp\":\"2020-04-15T18:33:49Z\",\"annotations\":{\"kubectl.kubernetes.io/last-applied-configuration\":\"{\\\"apiVersion\\\":\\\"v1\\\",\\\"data\\\":{\\\"ConfigMapName\\\":\\\"testconfigmap\\\"},\\\"kind\\\":\\\"ConfigMap\\\",\\\"metadata\\\":{\\\"annotations\\\":{},\\\"name\\\":\\\"kubernetes1\\\",\\\"namespace\\\":\\\"default\\\"}}\\n\"}},\"data\":{" + - "\"appsettings.demo.json\": \"{\n \\\"Test0\\\": \\\"Value0\\\",\n \\\"Test1\\\": [\n {\n \\\"Test2\\\": \\\"Value1\\\"\n }\n ]\n}\"" + + "\"appsettings.demo.json\": \"{\\\"Test0\\\": \\\"Value0\\\",\\\"Test1\\\": [{\\\"Test2\\\": \\\"Value1\\\"}]}\"" + "}\n}\n")); - using var client = new k8s.Kubernetes(new KubernetesClientConfiguration { Host = "http://localhost" }, httpClient: mockHttpMessageHandler.ToHttpClient()); + using var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); var settings = new KubernetesConfigSourceSettings("default", "testconfigmap", new ReloadSettings()); var provider = new KubernetesConfigMapProvider(client, settings); @@ -198,7 +199,7 @@ public void KubernetesConfigMapProvider_AddsEnvSpecificJsonFileToDictionaryOnSuc public void KubernetesProviderGetsNewLoggerFactory() { // arrange - using var client = new k8s.Kubernetes(new KubernetesClientConfiguration { Host = "http://localhost" }, new HttpClient()); + using var client = new k8s.Kubernetes(new KubernetesClientConfiguration { Host = "http://localhost" }); var settings = new KubernetesConfigSourceSettings("default", "testconfigmap", new ReloadSettings()); var provider = new KubernetesConfigMapProvider(client, settings); var originalLoggerFactory = settings.LoggerFactory; @@ -213,7 +214,7 @@ public void KubernetesProviderGetsNewLoggerFactory() public void KubernetesProviderGetsNewLogger() { // arrange - using var client = new k8s.Kubernetes(new KubernetesClientConfiguration { Host = "http://localhost" }, new HttpClient()); + using var client = new k8s.Kubernetes(new KubernetesClientConfiguration { Host = "http://localhost" }); var settings = new KubernetesConfigSourceSettings("default", "testconfigmap", new ReloadSettings()); var provider = new KubernetesConfigMapProvider(client, settings); settings.LoggerFactory ??= new LoggerFactory(); diff --git a/src/Configuration/test/KubernetesBase.Test/KubernetesSecretProviderTest.cs b/src/Configuration/test/KubernetesBase.Test/KubernetesSecretProviderTest.cs index dd38549399..9183900662 100644 --- a/src/Configuration/test/KubernetesBase.Test/KubernetesSecretProviderTest.cs +++ b/src/Configuration/test/KubernetesBase.Test/KubernetesSecretProviderTest.cs @@ -3,10 +3,11 @@ // See the LICENSE file in the project root for more information. using k8s; -using Microsoft.Rest; +using k8s.Autorest; using Moq; using RichardSzalay.MockHttp; using Steeltoe.Common.Kubernetes; +using Steeltoe.Common.TestResources; using System; using System.Net; using System.Net.Http; @@ -21,7 +22,7 @@ public class KubernetesSecretProviderTest [Fact] public void KubernetesSecretProvider_ThrowsOnNulls() { - var client = new Mock(); + var client = new Mock(); var settings = new KubernetesConfigSourceSettings("default", "test", new ReloadSettings()); var ex1 = Assert.Throws(() => new KubernetesSecretProvider(null, settings)); @@ -37,7 +38,7 @@ public void KubernetesSecretProvider_ThrowsOn403() var mockHttpMessageHandler = new MockHttpMessageHandler(); mockHttpMessageHandler.Expect(HttpMethod.Get, "*").Respond(HttpStatusCode.Forbidden); - var client = new k8s.Kubernetes(new KubernetesClientConfiguration { Host = "http://localhost" }, httpClient: mockHttpMessageHandler.ToHttpClient()); + var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); var settings = new KubernetesConfigSourceSettings("default", "test", new ReloadSettings()); var provider = new KubernetesSecretProvider(client, settings); @@ -52,7 +53,7 @@ public async Task KubernetesSecretProvider_ContinuesOn404() var mockHttpMessageHandler = new MockHttpMessageHandler(); mockHttpMessageHandler.Expect(HttpMethod.Get, "*").Respond(HttpStatusCode.NotFound); - using var client = new k8s.Kubernetes(new KubernetesClientConfiguration { Host = "http://localhost" }, httpClient: mockHttpMessageHandler.ToHttpClient()); + using var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); var settings = new KubernetesConfigSourceSettings("default", "test", new ReloadSettings() { ConfigMaps = true, Period = 0 }); var provider = new KubernetesConfigMapProvider(client, settings); @@ -70,7 +71,7 @@ public void KubernetesSecretProvider_AddsToDictionaryOnSuccess() .Expect(HttpMethod.Get, "*") .Respond(new StringContent("{\"kind\":\"Secret\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"testsecret\",\"namespace\":\"default\",\"selfLink\":\"/api/v1/namespaces/default/secrets/testsecret\",\"uid\":\"04a256d5-5480-4e6a-ab1a-81b1df2b1f15\",\"resourceVersion\":\"724153\",\"creationTimestamp\":\"2020-04-17T14:32:42Z\",\"annotations\":{\"kubectl.kubernetes.io/last-applied-configuration\":\"{\\\"apiVersion\\\":\\\"v1\\\",\\\"data\\\":{\\\"testKey\\\":\\\"dGVzdFZhbHVl\\\"},\\\"kind\\\":\\\"Secret\\\",\\\"metadata\\\":{\\\"annotations\\\":{},\\\"name\\\":\\\"testsecret\\\",\\\"namespace\\\":\\\"default\\\"},\\\"type\\\":\\\"Opaque\\\"}\\n\"}},\"data\":{\"testKey\":\"dGVzdFZhbHVl\"},\"type\":\"Opaque\"}\n")); - var client = new k8s.Kubernetes(new KubernetesClientConfiguration() { Host = "http://localhost" }, httpClient: mockHttpMessageHandler.ToHttpClient()); + var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration() { Host = "http://localhost" }, mockHttpMessageHandler); var settings = new KubernetesConfigSourceSettings("default", "testsecret", new ReloadSettings()); var provider = new KubernetesSecretProvider(client, settings); @@ -88,7 +89,7 @@ public void KubernetesSecretProvider_SeesDoubleUnderscore() .Expect(HttpMethod.Get, "*") .Respond(new StringContent("{\"kind\":\"Secret\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"testsecret\",\"namespace\":\"default\",\"selfLink\":\"/api/v1/namespaces/default/secrets/testsecret\",\"uid\":\"04a256d5-5480-4e6a-ab1a-81b1df2b1f15\",\"resourceVersion\":\"724153\",\"creationTimestamp\":\"2020-04-17T14:32:42Z\",\"annotations\":{\"kubectl.kubernetes.io/last-applied-configuration\":\"{\\\"apiVersion\\\":\\\"v1\\\",\\\"data\\\":{\\\"testKey\\\":\\\"dGVzdFZhbHVl\\\"},\\\"kind\\\":\\\"Secret\\\",\\\"metadata\\\":{\\\"annotations\\\":{},\\\"name\\\":\\\"testsecret\\\",\\\"namespace\\\":\\\"default\\\"},\\\"type\\\":\\\"Opaque\\\"}\\n\"}},\"data\":{\"several__layers__deep__testKey\":\"dGVzdFZhbHVl\"},\"type\":\"Opaque\"}\n")); - var client = new k8s.Kubernetes(new KubernetesClientConfiguration() { Host = "http://localhost" }, httpClient: mockHttpMessageHandler.ToHttpClient()); + var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration() { Host = "http://localhost" }, mockHttpMessageHandler); var settings = new KubernetesConfigSourceSettings("default", "testsecret", new ReloadSettings()); var provider = new KubernetesSecretProvider(client, settings); @@ -113,7 +114,7 @@ public async Task KubernetesSecretProvider_ReloadsDictionaryOnInterval() .Expect(HttpMethod.Get, "*") .Respond(new StringContent("{\"kind\":\"Secret\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"testsecret\",\"namespace\":\"default\",\"selfLink\":\"/api/v1/namespaces/default/secrets/testsecret\",\"uid\":\"04a256d5-5480-4e6a-ab1a-81b1df2b1f15\",\"resourceVersion\":\"724153\",\"creationTimestamp\":\"2020-04-17T14:32:42Z\",\"annotations\":{\"kubectl.kubernetes.io/last-applied-configuration\":\"{\\\"apiVersion\\\":\\\"v1\\\",\\\"data\\\":{\\\"testKey\\\":\\\"dGVzdFZhbHVl\\\"},\\\"kind\\\":\\\"Secret\\\",\\\"metadata\\\":{\\\"annotations\\\":{},\\\"name\\\":\\\"testsecret\\\",\\\"namespace\\\":\\\"default\\\"},\\\"type\\\":\\\"Opaque\\\"}\\n\"}},\"data\":{\"updatedAgain\":\"dGVzdFZhbHVl\"},\"type\":\"Opaque\"}\n")); - var client = new k8s.Kubernetes(new KubernetesClientConfiguration() { Host = "http://localhost" }, httpClient: mockHttpMessageHandler.ToHttpClient()); + var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration() { Host = "http://localhost" }, mockHttpMessageHandler); var settings = new KubernetesConfigSourceSettings("default", "testsecret", new ReloadSettings() { Period = 1, Secrets = true }); var provider = new KubernetesSecretProvider(client, settings, new CancellationTokenSource(20000).Token); diff --git a/src/Configuration/test/KubernetesBase.Test/Steeltoe.Extensions.Configuration.KubernetesBase.Test.csproj b/src/Configuration/test/KubernetesBase.Test/Steeltoe.Extensions.Configuration.KubernetesBase.Test.csproj index 9c7fb53e5d..d84316df08 100644 --- a/src/Configuration/test/KubernetesBase.Test/Steeltoe.Extensions.Configuration.KubernetesBase.Test.csproj +++ b/src/Configuration/test/KubernetesBase.Test/Steeltoe.Extensions.Configuration.KubernetesBase.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.Extensions.Configuration.Kubernetes.Test diff --git a/src/Configuration/test/KubernetesCore.Test/MockKubeApiServer.cs b/src/Configuration/test/KubernetesCore.Test/MockKubeApiServer.cs index 2f1c92060a..93892dc48a 100644 --- a/src/Configuration/test/KubernetesCore.Test/MockKubeApiServer.cs +++ b/src/Configuration/test/KubernetesCore.Test/MockKubeApiServer.cs @@ -31,12 +31,15 @@ public MockKubeApiServer(Func> shouldNext = null) { if (await shouldNext(httpContext)) { - if (httpContext.Request.Path.Equals("/api/v1/namespaces/default/configmaps")) + var path = httpContext.Request.Path.Value ?? string.Empty; + if (path.StartsWith("/api/v1/namespaces/default/configmaps/", StringComparison.Ordinal)) { + httpContext.Response.ContentType = "application/json"; await httpContext.Response.WriteAsync(configMapResponse); } - else if (httpContext.Request.Path.Equals("/api/v1/namespaces/default/secrets")) + else if (path.StartsWith("/api/v1/namespaces/default/secrets/", StringComparison.Ordinal)) { + httpContext.Response.ContentType = "application/json"; await httpContext.Response.WriteAsync(secretResponse); } } diff --git a/src/Configuration/test/KubernetesCore.Test/Steeltoe.Extensions.Configuration.KubernetesCore.Test.csproj b/src/Configuration/test/KubernetesCore.Test/Steeltoe.Extensions.Configuration.KubernetesCore.Test.csproj index 92a8506265..ac420e7807 100644 --- a/src/Configuration/test/KubernetesCore.Test/Steeltoe.Extensions.Configuration.KubernetesCore.Test.csproj +++ b/src/Configuration/test/KubernetesCore.Test/Steeltoe.Extensions.Configuration.KubernetesCore.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.Extensions.Configuration.Kubernetes.Test diff --git a/src/Configuration/test/PlaceholderBase.Test/Steeltoe.Extensions.Configuration.PlaceholderBase.Test.csproj b/src/Configuration/test/PlaceholderBase.Test/Steeltoe.Extensions.Configuration.PlaceholderBase.Test.csproj index 3180395d74..f1def4586f 100644 --- a/src/Configuration/test/PlaceholderBase.Test/Steeltoe.Extensions.Configuration.PlaceholderBase.Test.csproj +++ b/src/Configuration/test/PlaceholderBase.Test/Steeltoe.Extensions.Configuration.PlaceholderBase.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 @@ -18,6 +18,7 @@ + diff --git a/src/Configuration/test/PlaceholderCore.Test/Steeltoe.Extensions.Configuration.PlaceholderCore.Test.csproj b/src/Configuration/test/PlaceholderCore.Test/Steeltoe.Extensions.Configuration.PlaceholderCore.Test.csproj index 38f60c7981..e8876a86af 100644 --- a/src/Configuration/test/PlaceholderCore.Test/Steeltoe.Extensions.Configuration.PlaceholderCore.Test.csproj +++ b/src/Configuration/test/PlaceholderCore.Test/Steeltoe.Extensions.Configuration.PlaceholderCore.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 @@ -16,6 +16,7 @@ + diff --git a/src/Configuration/test/RandomValuesBase.Test/Steeltoe.Extensions.Configuration.RandomValueBase.Test.csproj b/src/Configuration/test/RandomValuesBase.Test/Steeltoe.Extensions.Configuration.RandomValueBase.Test.csproj index 5325f29186..388fe31b27 100644 --- a/src/Configuration/test/RandomValuesBase.Test/Steeltoe.Extensions.Configuration.RandomValueBase.Test.csproj +++ b/src/Configuration/test/RandomValuesBase.Test/Steeltoe.Extensions.Configuration.RandomValueBase.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Configuration/test/SpringBootBase.Test/Steeltoe.Extensions.Configuration.SpringBootBase.Test.csproj b/src/Configuration/test/SpringBootBase.Test/Steeltoe.Extensions.Configuration.SpringBootBase.Test.csproj index 12acc507c2..cc88d54d5e 100644 --- a/src/Configuration/test/SpringBootBase.Test/Steeltoe.Extensions.Configuration.SpringBootBase.Test.csproj +++ b/src/Configuration/test/SpringBootBase.Test/Steeltoe.Extensions.Configuration.SpringBootBase.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Configuration/test/SpringBootCore.Test/Steeltoe.Extensions.Configuration.SpringBootCore.Test.csproj b/src/Configuration/test/SpringBootCore.Test/Steeltoe.Extensions.Configuration.SpringBootCore.Test.csproj index 1cc2702a9a..7eda87c3d6 100644 --- a/src/Configuration/test/SpringBootCore.Test/Steeltoe.Extensions.Configuration.SpringBootCore.Test.csproj +++ b/src/Configuration/test/SpringBootCore.Test/Steeltoe.Extensions.Configuration.SpringBootCore.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 @@ -16,6 +16,7 @@ + diff --git a/src/Connectors/src/Abstractions/Steeltoe.Connector.Abstractions.csproj b/src/Connectors/src/Abstractions/Steeltoe.Connector.Abstractions.csproj index 217f85ccbd..450bb8b99e 100644 --- a/src/Connectors/src/Abstractions/Steeltoe.Connector.Abstractions.csproj +++ b/src/Connectors/src/Abstractions/Steeltoe.Connector.Abstractions.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0;netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Connector Abstractions for working with backing services diff --git a/src/Connectors/src/CloudFoundry/Steeltoe.Connector.CloudFoundry.csproj b/src/Connectors/src/CloudFoundry/Steeltoe.Connector.CloudFoundry.csproj index a784935479..013b653292 100644 --- a/src/Connectors/src/CloudFoundry/Steeltoe.Connector.CloudFoundry.csproj +++ b/src/Connectors/src/CloudFoundry/Steeltoe.Connector.CloudFoundry.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Package for enabling Steeltoe Connectors on Cloud Foundry CloudFoundry;vcap;connectors diff --git a/src/Connectors/src/Connector.EF6Core/Steeltoe.Connector.EF6Core.csproj b/src/Connectors/src/Connector.EF6Core/Steeltoe.Connector.EF6Core.csproj index 1664d6cd26..8584e142bd 100644 --- a/src/Connectors/src/Connector.EF6Core/Steeltoe.Connector.EF6Core.csproj +++ b/src/Connectors/src/Connector.EF6Core/Steeltoe.Connector.EF6Core.csproj @@ -1,7 +1,7 @@ Connector Extensions for Entity Framework - netstandard2.0 + net8.0;netstandard2.0 connectors;EntityFramework;aspnetcore;services diff --git a/src/Connectors/src/Connector.EFCore/EntityFrameworkCoreTypeLocator.cs b/src/Connectors/src/Connector.EFCore/EntityFrameworkCoreTypeLocator.cs index 5a6b3835f2..f459079d84 100644 --- a/src/Connectors/src/Connector.EFCore/EntityFrameworkCoreTypeLocator.cs +++ b/src/Connectors/src/Connector.EFCore/EntityFrameworkCoreTypeLocator.cs @@ -4,6 +4,7 @@ using Steeltoe.Common.Reflection; using System; +using System.Linq; namespace Steeltoe.Connector.EFCore; @@ -37,7 +38,7 @@ public static class EntityFrameworkCoreTypeLocator /// /// Gets the ServerVersion base type used to identify MySQL Server versions (introduced in v5.0) /// - public static Type MySqlVersionType => ReflectionHelpers.FindType(new[] { "Pomelo.EntityFrameworkCore.MySql" }, new[] { "Microsoft.EntityFrameworkCore.ServerVersion" }); + public static Type MySqlVersionType => MySqlEntityAssemblies.Contains("Pomelo.EntityFrameworkCore.MySql") ? ReflectionHelpers.FindType(new[] { "Pomelo.EntityFrameworkCore.MySql" }, new[] { "Microsoft.EntityFrameworkCore.ServerVersion" }) : null; /// /// Gets a list of supported PostgreSQL Entity Framework Core Assemblies diff --git a/src/Connectors/src/Connector.EFCore/Steeltoe.Connector.EFCore.csproj b/src/Connectors/src/Connector.EFCore/Steeltoe.Connector.EFCore.csproj index c60a7ed2d5..4812deaef0 100644 --- a/src/Connectors/src/Connector.EFCore/Steeltoe.Connector.EFCore.csproj +++ b/src/Connectors/src/Connector.EFCore/Steeltoe.Connector.EFCore.csproj @@ -1,6 +1,6 @@  - net8.0;net6.0 + net8.0 Package for using Steeltoe Connectors with Entity Framework Core connectors;EFCore;EntityFrameworkCore;EF;Entity Framework Core;entity-framework-core;services diff --git a/src/Connectors/src/ConnectorBase/ConnectorException.cs b/src/Connectors/src/ConnectorBase/ConnectorException.cs index fa9ed8f71f..2973ccc93e 100644 --- a/src/Connectors/src/ConnectorBase/ConnectorException.cs +++ b/src/Connectors/src/ConnectorBase/ConnectorException.cs @@ -25,7 +25,9 @@ public ConnectorException(string message, Exception nested) } protected ConnectorException(SerializationInfo info, StreamingContext context) +#pragma warning disable SYSLIB0051 // Type or member is obsolete : base(info, context) +#pragma warning restore SYSLIB0051 // Type or member is obsolete { } } \ No newline at end of file diff --git a/src/Connectors/src/ConnectorBase/Steeltoe.Connector.ConnectorBase.csproj b/src/Connectors/src/ConnectorBase/Steeltoe.Connector.ConnectorBase.csproj index 3bc5a07edd..dbc8ccde8a 100644 --- a/src/Connectors/src/ConnectorBase/Steeltoe.Connector.ConnectorBase.csproj +++ b/src/Connectors/src/ConnectorBase/Steeltoe.Connector.ConnectorBase.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Connector Connectors for using service bindings in your application connectors;services diff --git a/src/Connectors/src/ConnectorCore/Steeltoe.Connector.ConnectorCore.csproj b/src/Connectors/src/ConnectorCore/Steeltoe.Connector.ConnectorCore.csproj index d17bee66f6..7488f8d0e3 100644 --- a/src/Connectors/src/ConnectorCore/Steeltoe.Connector.ConnectorCore.csproj +++ b/src/Connectors/src/ConnectorCore/Steeltoe.Connector.ConnectorCore.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Connector Package for using service connectors in your .NET Core application connectors;aspnetcore;services @@ -10,7 +10,7 @@ - + diff --git a/src/Connectors/test/Connector.CloudFoundry.Test/Steeltoe.Connector.CloudFoundry.Test.csproj b/src/Connectors/test/Connector.CloudFoundry.Test/Steeltoe.Connector.CloudFoundry.Test.csproj index 4465326a21..269e1ccfaf 100644 --- a/src/Connectors/test/Connector.CloudFoundry.Test/Steeltoe.Connector.CloudFoundry.Test.csproj +++ b/src/Connectors/test/Connector.CloudFoundry.Test/Steeltoe.Connector.CloudFoundry.Test.csproj @@ -1,7 +1,7 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Connectors/test/Connector.EF6Core.Test/Steeltoe.Connector.EF6Core.Test.csproj b/src/Connectors/test/Connector.EF6Core.Test/Steeltoe.Connector.EF6Core.Test.csproj index 4278a6fe03..92142de3ca 100644 --- a/src/Connectors/test/Connector.EF6Core.Test/Steeltoe.Connector.EF6Core.Test.csproj +++ b/src/Connectors/test/Connector.EF6Core.Test/Steeltoe.Connector.EF6Core.Test.csproj @@ -1,6 +1,6 @@  - net8.0;net6.0 + net8.0 diff --git a/src/Connectors/test/Connector.EFCore.Test/EntityFrameworkCoreTypeLocatorTest.cs b/src/Connectors/test/Connector.EFCore.Test/EntityFrameworkCoreTypeLocatorTest.cs index 0ea99b368a..b5572166cf 100644 --- a/src/Connectors/test/Connector.EFCore.Test/EntityFrameworkCoreTypeLocatorTest.cs +++ b/src/Connectors/test/Connector.EFCore.Test/EntityFrameworkCoreTypeLocatorTest.cs @@ -17,33 +17,25 @@ public void Property_Can_Locate_MySqlDbContextOptionsType() Assert.NotNull(type); } -#if NET8_0_OR_GREATER [Fact] public void Options_Found_In_MySql_Assembly() { - // arrange ~ narrow the assembly list to one specific nuget package - var types = EntityFrameworkCoreTypeLocator.MySqlEntityAssemblies; - EntityFrameworkCoreTypeLocator.MySqlEntityAssemblies = new string[] { "MySql.EntityFrameworkCore" }; + using var assemblyScope = new MySqlEntityFrameworkCoreAssemblyScope(new[] { "MySql.EntityFrameworkCore" }); var type = EntityFrameworkCoreTypeLocator.MySqlDbContextOptionsType; Assert.NotNull(type); - EntityFrameworkCoreTypeLocator.MySqlEntityAssemblies = types; } -#else + [Fact] public void Options_Found_In_Pomelo_Assembly() { - // arrange ~ narrow the assembly list to one specific nuget package - var types = EntityFrameworkCoreTypeLocator.MySqlEntityAssemblies; - EntityFrameworkCoreTypeLocator.MySqlEntityAssemblies = new string[] { "Pomelo.EntityFrameworkCore.MySql" }; + using var assemblyScope = new MySqlEntityFrameworkCoreAssemblyScope(new[] { "Pomelo.EntityFrameworkCore.MySql" }); var type = EntityFrameworkCoreTypeLocator.MySqlDbContextOptionsType; Assert.NotNull(type); - EntityFrameworkCoreTypeLocator.MySqlEntityAssemblies = types; } -#endif [Fact] public void Property_Can_Locate_PostgreSqlDbContextOptionsType() diff --git a/src/Connectors/test/Connector.EFCore.Test/MySqlDbContextOptionsExtensionsTest.cs b/src/Connectors/test/Connector.EFCore.Test/MySqlDbContextOptionsExtensionsTest.cs index 16d1f457a6..4426b04f89 100644 --- a/src/Connectors/test/Connector.EFCore.Test/MySqlDbContextOptionsExtensionsTest.cs +++ b/src/Connectors/test/Connector.EFCore.Test/MySqlDbContextOptionsExtensionsTest.cs @@ -3,19 +3,15 @@ // See the LICENSE file in the project root for more information. using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -#if NET8_0_OR_GREATER -using MySql.Data.MySqlClient; -#else -using MySqlConnector; -#endif using Steeltoe.Connector.EFCore.Test; using Steeltoe.Extensions.Configuration.CloudFoundry; using System; using System.Collections.Generic; using Xunit; +using OracleMySqlConnection = MySql.Data.MySqlClient.MySqlConnection; +using PomeloMySqlConnection = MySqlConnector.MySqlConnection; namespace Steeltoe.Connector.MySql.EFCore.Test; @@ -83,22 +79,37 @@ public void UseMySql_ThrowsIfServiceNameNull() } [Fact] - public void AddDbContext_NoVCAPs_AddsDbContext_WithMySqlConnection() + public void AddDbContext_NoVCAPs_AddsDbContext_WithMySqlConnection_OracleDriver() { + using var assemblyScope = CreateOracleAssemblyScope(); + IServiceCollection services = new ServiceCollection(); var config = new ConfigurationBuilder().Build(); -#if NET8_0_OR_GREATER services.AddDbContext(options => options.UseMySql(config)); -#else + + var service = services.BuildServiceProvider().GetService(); + Assert.NotNull(service); + var con = service.Database.GetDbConnection(); + Assert.NotNull(con); + Assert.True(con is OracleMySqlConnection); + } + + [Fact] + public void AddDbContext_NoVCAPs_AddsDbContext_WithMySqlConnection_PomeloDriver() + { + using var assemblyScope = CreatePomeloAssemblyScope(); + + IServiceCollection services = new ServiceCollection(); + var config = new ConfigurationBuilder().Build(); + services.AddDbContext(options => options.UseMySql(config, serverVersion: MySqlServerVersion.LatestSupportedServerVersion)); -#endif var service = services.BuildServiceProvider().GetService(); Assert.NotNull(service); var con = service.Database.GetDbConnection(); Assert.NotNull(con); - Assert.True(con is MySqlConnection); + Assert.True(con is PomeloMySqlConnection); } // Run a MySQL server with Docker to match creds below with this command @@ -106,6 +117,8 @@ public void AddDbContext_NoVCAPs_AddsDbContext_WithMySqlConnection() [Fact(Skip = "Requires a running MySQL server to support AutoDetect")] public void AddDbContext_NoVCAPs_AddsDbContext_WithMySqlConnection_AutodetectOn5_0() { + using var assemblyScope = CreateOracleAssemblyScope(); + IServiceCollection services = new ServiceCollection(); var config = new ConfigurationBuilder().AddInMemoryCollection(new Dictionary { { "mysql:client:database", "steeltoe2" }, { "mysql:client:username", "root" }, { "mysql:client:password", "steeltoe" } }).Build(); @@ -115,7 +128,7 @@ public void AddDbContext_NoVCAPs_AddsDbContext_WithMySqlConnection_AutodetectOn5 Assert.NotNull(service); var con = service.Database.GetDbConnection(); Assert.NotNull(con); - Assert.NotNull(con as MySqlConnection); + Assert.NotNull(con as OracleMySqlConnection); } [Fact] @@ -149,8 +162,10 @@ public void AddDbContext_MultipleMySqlServices_ThrowsConnectorException() } [Fact] - public void AddDbContext_MultipleMySqlServices_AddWithName_Adds() + public void AddDbContext_MultipleMySqlServices_AddWithName_Adds_OracleDriver() { + using var assemblyScope = CreateOracleAssemblyScope(); + IServiceCollection services = new ServiceCollection(); Environment.SetEnvironmentVariable("VCAP_APPLICATION", TestHelpers.VCAP_APPLICATION); @@ -160,11 +175,40 @@ public void AddDbContext_MultipleMySqlServices_AddWithName_Adds() builder.AddCloudFoundry(); var config = builder.Build(); -#if NET8_0_OR_GREATER services.AddDbContext(options => options.UseMySql(config, "spring-cloud-broker-db2")); -#else + + var built = services.BuildServiceProvider(); + var service = built.GetService(); + Assert.NotNull(service); + + var con = service.Database.GetDbConnection(); + Assert.NotNull(con); + Assert.IsType(con); + + var connString = con.ConnectionString; + Assert.NotNull(connString); + Assert.Contains("Server=192.168.0.91", connString, StringComparison.InvariantCultureIgnoreCase); + Assert.Contains("Port=3306", connString, StringComparison.InvariantCultureIgnoreCase); + Assert.Contains("Database=cf_b4f8d2fa_a3ea_4e3a_a0e8_2cd0407903550", connString, StringComparison.InvariantCultureIgnoreCase); + Assert.Contains("User Id=Dd6O1BPXUHdrmzbP0", connString, StringComparison.InvariantCultureIgnoreCase); + Assert.Contains("Password=7E1LxXnlH2hhlPVt0", connString, StringComparison.InvariantCultureIgnoreCase); + } + + [Fact] + public void AddDbContext_MultipleMySqlServices_AddWithName_Adds_PomeloDriver() + { + using var assemblyScope = CreatePomeloAssemblyScope(); + + IServiceCollection services = new ServiceCollection(); + + Environment.SetEnvironmentVariable("VCAP_APPLICATION", TestHelpers.VCAP_APPLICATION); + Environment.SetEnvironmentVariable("VCAP_SERVICES", MySqlTestHelpers.TwoServerVCAP); + + var builder = new ConfigurationBuilder(); + builder.AddCloudFoundry(); + var config = builder.Build(); + services.AddDbContext(options => options.UseMySql(config, "spring-cloud-broker-db2", serverVersion: MySqlServerVersion.LatestSupportedServerVersion)); -#endif var built = services.BuildServiceProvider(); var service = built.GetService(); @@ -172,7 +216,7 @@ public void AddDbContext_MultipleMySqlServices_AddWithName_Adds() var con = service.Database.GetDbConnection(); Assert.NotNull(con); - Assert.IsType(con); + Assert.IsType(con); var connString = con.ConnectionString; Assert.NotNull(connString); @@ -184,8 +228,10 @@ public void AddDbContext_MultipleMySqlServices_AddWithName_Adds() } [Fact] - public void AddDbContexts_WithVCAPs_AddsDbContexts() + public void AddDbContexts_WithVCAPs_AddsDbContexts_OracleDriver() { + using var assemblyScope = CreateOracleAssemblyScope(); + IServiceCollection services = new ServiceCollection(); Environment.SetEnvironmentVariable("VCAP_APPLICATION", TestHelpers.VCAP_APPLICATION); Environment.SetEnvironmentVariable("VCAP_SERVICES", MySqlTestHelpers.SingleServerVCAP); @@ -194,11 +240,39 @@ public void AddDbContexts_WithVCAPs_AddsDbContexts() builder.AddCloudFoundry(); var config = builder.Build(); -#if NET8_0_OR_GREATER services.AddDbContext(options => options.UseMySql(config)); -#else + + var built = services.BuildServiceProvider(); + var service = built.GetService(); + Assert.NotNull(service); + + var con = service.Database.GetDbConnection(); + Assert.NotNull(con); + Assert.IsType(con); + + var connString = con.ConnectionString; + Assert.NotNull(connString); + Assert.Contains("Server=192.168.0.90", connString, StringComparison.InvariantCultureIgnoreCase); + Assert.Contains("Port=3306", connString, StringComparison.InvariantCultureIgnoreCase); + Assert.Contains("Database=cf_b4f8d2fa_a3ea_4e3a_a0e8_2cd040790355", connString, StringComparison.InvariantCultureIgnoreCase); + Assert.Contains("User Id=Dd6O1BPXUHdrmzbP", connString, StringComparison.InvariantCultureIgnoreCase); + Assert.Contains("Password=7E1LxXnlH2hhlPVt", connString, StringComparison.InvariantCultureIgnoreCase); + } + + [Fact] + public void AddDbContexts_WithVCAPs_AddsDbContexts_PomeloDriver() + { + using var assemblyScope = CreatePomeloAssemblyScope(); + + IServiceCollection services = new ServiceCollection(); + Environment.SetEnvironmentVariable("VCAP_APPLICATION", TestHelpers.VCAP_APPLICATION); + Environment.SetEnvironmentVariable("VCAP_SERVICES", MySqlTestHelpers.SingleServerVCAP); + + var builder = new ConfigurationBuilder(); + builder.AddCloudFoundry(); + var config = builder.Build(); + services.AddDbContext(options => options.UseMySql(config, serverVersion: MySqlServerVersion.LatestSupportedServerVersion)); -#endif var built = services.BuildServiceProvider(); var service = built.GetService(); @@ -206,7 +280,7 @@ public void AddDbContexts_WithVCAPs_AddsDbContexts() var con = service.Database.GetDbConnection(); Assert.NotNull(con); - Assert.IsType(con); + Assert.IsType(con); var connString = con.ConnectionString; Assert.NotNull(connString); @@ -216,4 +290,14 @@ public void AddDbContexts_WithVCAPs_AddsDbContexts() Assert.Contains("User Id=Dd6O1BPXUHdrmzbP", connString, StringComparison.InvariantCultureIgnoreCase); Assert.Contains("Password=7E1LxXnlH2hhlPVt", connString, StringComparison.InvariantCultureIgnoreCase); } + + private static MySqlEntityFrameworkCoreAssemblyScope CreateOracleAssemblyScope() + { + return new MySqlEntityFrameworkCoreAssemblyScope(new[] { "MySql.EntityFrameworkCore" }); + } + + private static MySqlEntityFrameworkCoreAssemblyScope CreatePomeloAssemblyScope() + { + return new MySqlEntityFrameworkCoreAssemblyScope(new[] { "Pomelo.EntityFrameworkCore.MySql" }); + } } \ No newline at end of file diff --git a/src/Connectors/test/Connector.EFCore.Test/MySqlEntityFrameworkCoreAssemblyScope.cs b/src/Connectors/test/Connector.EFCore.Test/MySqlEntityFrameworkCoreAssemblyScope.cs new file mode 100644 index 0000000000..bde564ecc0 --- /dev/null +++ b/src/Connectors/test/Connector.EFCore.Test/MySqlEntityFrameworkCoreAssemblyScope.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; + +namespace Steeltoe.Connector.EFCore.Test; + +internal sealed class MySqlEntityFrameworkCoreAssemblyScope : IDisposable +{ + private readonly string[] _backupAssemblies; + + public MySqlEntityFrameworkCoreAssemblyScope(string[] assemblies) + { + _backupAssemblies = EntityFrameworkCoreTypeLocator.MySqlEntityAssemblies; + EntityFrameworkCoreTypeLocator.MySqlEntityAssemblies = assemblies; + } + + public void Dispose() + { + EntityFrameworkCoreTypeLocator.MySqlEntityAssemblies = _backupAssemblies; + } +} \ No newline at end of file diff --git a/src/Connectors/test/Connector.EFCore.Test/MySqlTypeLocatorTest.cs b/src/Connectors/test/Connector.EFCore.Test/MySqlTypeLocatorTest.cs index 967d63bc30..ac0840761a 100644 --- a/src/Connectors/test/Connector.EFCore.Test/MySqlTypeLocatorTest.cs +++ b/src/Connectors/test/Connector.EFCore.Test/MySqlTypeLocatorTest.cs @@ -23,7 +23,6 @@ public void Property_Can_Locate_ConnectionType() Assert.NotNull(type); } -#if NET8_0_OR_GREATER [Fact] public void Driver_Found_In_MySqlData_Assembly() { @@ -36,7 +35,7 @@ public void Driver_Found_In_MySqlData_Assembly() Assert.NotNull(type); MySqlTypeLocator.Assemblies = types; } -#else + [Fact] public void Driver_Found_In_MySqlConnector_Assembly() { @@ -49,5 +48,4 @@ public void Driver_Found_In_MySqlConnector_Assembly() Assert.NotNull(type); MySqlTypeLocator.Assemblies = types; } -#endif } \ No newline at end of file diff --git a/src/Connectors/test/Connector.EFCore.Test/Steeltoe.Connector.EFCore.Test.csproj b/src/Connectors/test/Connector.EFCore.Test/Steeltoe.Connector.EFCore.Test.csproj index 95d3f858ea..52246e4b2a 100644 --- a/src/Connectors/test/Connector.EFCore.Test/Steeltoe.Connector.EFCore.Test.csproj +++ b/src/Connectors/test/Connector.EFCore.Test/Steeltoe.Connector.EFCore.Test.csproj @@ -1,6 +1,6 @@  - net8.0;net6.0 + net8.0 @@ -24,12 +24,7 @@ - - - - - diff --git a/src/Connectors/test/ConnectorBase.Test/Steeltoe.Connector.ConnectorBase.Test.csproj b/src/Connectors/test/ConnectorBase.Test/Steeltoe.Connector.ConnectorBase.Test.csproj index 323e06d180..2a15c89f86 100644 --- a/src/Connectors/test/ConnectorBase.Test/Steeltoe.Connector.ConnectorBase.Test.csproj +++ b/src/Connectors/test/ConnectorBase.Test/Steeltoe.Connector.ConnectorBase.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.Connector.Test diff --git a/src/Connectors/test/ConnectorCore.Test/Steeltoe.Connector.ConnectorCore.Test.csproj b/src/Connectors/test/ConnectorCore.Test/Steeltoe.Connector.ConnectorCore.Test.csproj index e21603a423..ef20345d73 100644 --- a/src/Connectors/test/ConnectorCore.Test/Steeltoe.Connector.ConnectorCore.Test.csproj +++ b/src/Connectors/test/ConnectorCore.Test/Steeltoe.Connector.ConnectorCore.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Connectors/test/External.Connector.Test/External.Connector.Test.csproj b/src/Connectors/test/External.Connector.Test/External.Connector.Test.csproj index 3c70f82a12..9071d790a7 100644 --- a/src/Connectors/test/External.Connector.Test/External.Connector.Test.csproj +++ b/src/Connectors/test/External.Connector.Test/External.Connector.Test.csproj @@ -1,7 +1,7 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Discovery/src/Abstractions/Steeltoe.Discovery.Abstractions.csproj b/src/Discovery/src/Abstractions/Steeltoe.Discovery.Abstractions.csproj index dc7a846416..876fd1e02e 100644 --- a/src/Discovery/src/Abstractions/Steeltoe.Discovery.Abstractions.csproj +++ b/src/Discovery/src/Abstractions/Steeltoe.Discovery.Abstractions.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Discovery Abstractions for service registration and discovery diff --git a/src/Discovery/src/ClientBase/Steeltoe.Discovery.ClientBase.csproj b/src/Discovery/src/ClientBase/Steeltoe.Discovery.ClientBase.csproj index 2d19122f9e..78ad3698a4 100644 --- a/src/Discovery/src/ClientBase/Steeltoe.Discovery.ClientBase.csproj +++ b/src/Discovery/src/ClientBase/Steeltoe.Discovery.ClientBase.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0;netstandard2.0 + net8.0;netstandard2.0 Base package for using Steeltoe Service Discovery service discovery;service registry;Spring Cloud;eureka;consul;kubernetes Steeltoe.Discovery.Client diff --git a/src/Discovery/src/ClientCore/Steeltoe.Discovery.ClientCore.csproj b/src/Discovery/src/ClientCore/Steeltoe.Discovery.ClientCore.csproj index 899e49fdf7..6d9eb45cd4 100644 --- a/src/Discovery/src/ClientCore/Steeltoe.Discovery.ClientCore.csproj +++ b/src/Discovery/src/ClientCore/Steeltoe.Discovery.ClientCore.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Package for using Steeltoe Service Discovery Client in ASP.NET Core applications aspnetcore;service discovery;service registry;Spring Cloud;eureka;consul;kubernetes Steeltoe.Discovery.Client diff --git a/src/Discovery/src/Consul/Steeltoe.Discovery.Consul.csproj b/src/Discovery/src/Consul/Steeltoe.Discovery.Consul.csproj index 32ee80cdcb..0640395fc3 100644 --- a/src/Discovery/src/Consul/Steeltoe.Discovery.Consul.csproj +++ b/src/Discovery/src/Consul/Steeltoe.Discovery.Consul.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe compatibility package for service discovery and registration with Hashicorp Consul aspnetcore;Consul;Spring;Spring Cloud diff --git a/src/Discovery/src/Eureka/ApplicationInfoManager.cs b/src/Discovery/src/Eureka/ApplicationInfoManager.cs index 02b8c5f16c..eeb54ba623 100644 --- a/src/Discovery/src/Eureka/ApplicationInfoManager.cs +++ b/src/Discovery/src/Eureka/ApplicationInfoManager.cs @@ -60,7 +60,7 @@ public virtual InstanceStatus InstanceStatus } catch (Exception e) { - _logger?.LogError("StatusChangedEvent Exception:", e); + _logger?.LogError(e, "StatusChangedEvent Exception:"); } } } diff --git a/src/Discovery/src/Eureka/Steeltoe.Discovery.Eureka.csproj b/src/Discovery/src/Eureka/Steeltoe.Discovery.Eureka.csproj index 53bc3c32a5..01a1d5424b 100644 --- a/src/Discovery/src/Eureka/Steeltoe.Discovery.Eureka.csproj +++ b/src/Discovery/src/Eureka/Steeltoe.Discovery.Eureka.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + net8.0;netstandard2.0 Client for service discovery and registration with Neflix Eureka aspnetcore;Netflix Eureka;Spring;Spring Cloud @@ -9,7 +9,7 @@ - + diff --git a/src/Discovery/src/Eureka/Transport/EurekaTransportException.cs b/src/Discovery/src/Eureka/Transport/EurekaTransportException.cs index 84e9113cfb..aa7831c0cf 100644 --- a/src/Discovery/src/Eureka/Transport/EurekaTransportException.cs +++ b/src/Discovery/src/Eureka/Transport/EurekaTransportException.cs @@ -25,7 +25,9 @@ public EurekaTransportException() } protected EurekaTransportException(SerializationInfo info, StreamingContext context) +#pragma warning disable SYSLIB0051 // Type or member is obsolete : base(info, context) +#pragma warning restore SYSLIB0051 // Type or member is obsolete { } } \ No newline at end of file diff --git a/src/Discovery/src/Kubernetes/Discovery/KubernetesDiscoveryClient.cs b/src/Discovery/src/Kubernetes/Discovery/KubernetesDiscoveryClient.cs index b872df5a36..203a9de2cf 100644 --- a/src/Discovery/src/Kubernetes/Discovery/KubernetesDiscoveryClient.cs +++ b/src/Discovery/src/Kubernetes/Discovery/KubernetesDiscoveryClient.cs @@ -62,13 +62,13 @@ public IList GetServices(IDictionary labels) null; if (_discoveryOptions.CurrentValue.AllNamespaces) { - return KubernetesClient.ListServiceForAllNamespaces( + return KubernetesClient.CoreV1.ListServiceForAllNamespaces( labelSelector: labelSelectorValue).Items .Select(service => service.Metadata.Name).ToList(); } else { - return KubernetesClient.ListNamespacedService( + return KubernetesClient.CoreV1.ListNamespacedService( namespaceParameter: _discoveryOptions.CurrentValue.Namespace, labelSelector: labelSelectorValue).Items .Select(service => service.Metadata.Name).ToList(); @@ -84,8 +84,8 @@ public IList GetInstances(string serviceId) } var endpoints = _discoveryOptions.CurrentValue.AllNamespaces - ? KubernetesClient.ListEndpointsForAllNamespaces(fieldSelector: $"metadata.name={serviceId}").Items - : KubernetesClient.ListNamespacedEndpoints( + ? KubernetesClient.CoreV1.ListEndpointsForAllNamespaces(fieldSelector: $"metadata.name={serviceId}").Items + : KubernetesClient.CoreV1.ListNamespacedEndpoints( _discoveryOptions.CurrentValue.Namespace ?? DefaultNamespace, fieldSelector: $"metadata.name={serviceId}").Items; @@ -130,7 +130,7 @@ private IList GetNamespacedServiceInstances(EndpointSubsetNs e var instances = new List(); if (subsets.Any()) { - var service = KubernetesClient.ListNamespacedService( + var service = KubernetesClient.CoreV1.ListNamespacedService( namespaceParameter: k8SNamespace, fieldSelector: $"metadata.name={serviceId}").Items.FirstOrDefault(); var serviceMetadata = GetServiceMetadata(service); @@ -236,7 +236,7 @@ private EndpointSubsetNs GetSubsetsFromEndpoints(V1Endpoints endpoints) return es; } - es.Namespace = endpoints.Metadata.NamespaceProperty; + es.Namespace = endpoints.Metadata.Namespace(); es.EndpointSubsets = endpoints.Subsets; return es; diff --git a/src/Discovery/src/Kubernetes/Steeltoe.Discovery.Kubernetes.csproj b/src/Discovery/src/Kubernetes/Steeltoe.Discovery.Kubernetes.csproj index 66185c991a..73fdb5cea7 100644 --- a/src/Discovery/src/Kubernetes/Steeltoe.Discovery.Kubernetes.csproj +++ b/src/Discovery/src/Kubernetes/Steeltoe.Discovery.Kubernetes.csproj @@ -1,7 +1,7 @@ - netstandard2.1 + net8.0 Client for service discovery with Kubernetes native service discovery aspnetcore;Kubernetes;Spring;Spring Cloud Steeltoe.Discovery.Kubernetes diff --git a/src/Discovery/test/ClientBase.Test/Steeltoe.Discovery.ClientBase.Test.csproj b/src/Discovery/test/ClientBase.Test/Steeltoe.Discovery.ClientBase.Test.csproj index f2037bcd65..deb5a21f73 100644 --- a/src/Discovery/test/ClientBase.Test/Steeltoe.Discovery.ClientBase.Test.csproj +++ b/src/Discovery/test/ClientBase.Test/Steeltoe.Discovery.ClientBase.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Discovery/test/ClientCore.Test/Steeltoe.Discovery.ClientCore.Test.csproj b/src/Discovery/test/ClientCore.Test/Steeltoe.Discovery.ClientCore.Test.csproj index f9b03e26fd..0ad6b32c97 100644 --- a/src/Discovery/test/ClientCore.Test/Steeltoe.Discovery.ClientCore.Test.csproj +++ b/src/Discovery/test/ClientCore.Test/Steeltoe.Discovery.ClientCore.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Discovery/test/Consul.Test/Steeltoe.Discovery.Consul.Test.csproj b/src/Discovery/test/Consul.Test/Steeltoe.Discovery.Consul.Test.csproj index 00767d2258..96cf72c792 100644 --- a/src/Discovery/test/Consul.Test/Steeltoe.Discovery.Consul.Test.csproj +++ b/src/Discovery/test/Consul.Test/Steeltoe.Discovery.Consul.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Discovery/test/Eureka.Test/Steeltoe.Discovery.Eureka.Test.csproj b/src/Discovery/test/Eureka.Test/Steeltoe.Discovery.Eureka.Test.csproj index d7a0f28852..63b6edc20d 100644 --- a/src/Discovery/test/Eureka.Test/Steeltoe.Discovery.Eureka.Test.csproj +++ b/src/Discovery/test/Eureka.Test/Steeltoe.Discovery.Eureka.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Discovery/test/Kubernetes.Test/Discovery/KubernetesDiscoveryClientTest.cs b/src/Discovery/test/Kubernetes.Test/Discovery/KubernetesDiscoveryClientTest.cs index acc857263c..02c5fd9d85 100644 --- a/src/Discovery/test/Kubernetes.Test/Discovery/KubernetesDiscoveryClientTest.cs +++ b/src/Discovery/test/Kubernetes.Test/Discovery/KubernetesDiscoveryClientTest.cs @@ -5,6 +5,7 @@ using k8s; using RichardSzalay.MockHttp; using Steeltoe.Common; +using Steeltoe.Common.TestResources; using Steeltoe.Discovery.Kubernetes.Discovery; using System; using System.Collections.Generic; @@ -21,7 +22,7 @@ public class KubernetesDiscoveryClientTest public void Constructor_Initializes_Correctly() { var mockHttpMessageHandler = new MockHttpMessageHandler(); - using var client = new k8s.Kubernetes(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler.ToHttpClient()); + using var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); const string expectedDesc = "Steeltoe provided Kubernetes native service discovery client"; var k8SDiscoveryOptions = new TestOptionsMonitor(new KubernetesDiscoveryOptions()); @@ -70,9 +71,7 @@ public void GetInstances_ShouldBeAbleToHandleEndpointsFromMultipleNamespaces() new StringContent( "{\"apiVersion\":\"v1\",\"items\":[{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"labels\":{\"l\":\"v\"},\"name\":\"endpoint\",\"namespace\":\"test2\",\"uid\":\"uids2\"}}],\"kind\":\"List\",\"metadata\":{\"resourceVersion\":\"\",\"selfLink\":\"\"}}")); - using var client = new k8s.Kubernetes( - config: new KubernetesClientConfiguration { Host = "http://localhost" }, - httpClient: mockHttpMessageHandler.ToHttpClient()); + using var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); var options = new TestOptionsMonitor(new KubernetesDiscoveryOptions() { @@ -122,9 +121,7 @@ public void GetInstances_ShouldBeAbleToHandleEndpointsSingleAddress() new StringContent( "{\"apiVersion\":\"v1\",\"items\":[{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"labels\":{\"l\":\"v\"},\"name\":\"endpoint\",\"namespace\":\"test\",\"uid\":\"uids1\"}}],\"kind\":\"List\",\"metadata\":{\"resourceVersion\":\"\",\"selfLink\":\"\"}}")); - using var client = new k8s.Kubernetes( - config: new KubernetesClientConfiguration { Host = "http://localhost" }, - httpClient: mockHttpMessageHandler.ToHttpClient()); + using var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); var options = new TestOptionsMonitor(new KubernetesDiscoveryOptions() { @@ -163,9 +160,7 @@ public void GetInstances_ShouldBeAbleToHandleEndpointsSingleAddressAndMultiplePo new StringContent( "{\"apiVersion\":\"v1\",\"items\":[{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"labels\":{\"l\":\"v\"},\"name\":\"endpoint\",\"namespace\":\"test\",\"uid\":\"uids1\"}}],\"kind\":\"List\",\"metadata\":{\"resourceVersion\":\"\",\"selfLink\":\"\"}}")); - using var client = new k8s.Kubernetes( - config: new KubernetesClientConfiguration { Host = "http://localhost" }, - httpClient: mockHttpMessageHandler.ToHttpClient()); + using var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); var options = new TestOptionsMonitor(new KubernetesDiscoveryOptions() { @@ -205,9 +200,7 @@ public void GetInstances_ShouldBeAbleToHandleEndpointsMultipleAddresses() new StringContent( "{\"apiVersion\":\"v1\",\"items\":[{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"labels\":{\"l\":\"v\"},\"name\":\"endpoint\",\"namespace\":\"test\",\"uid\":\"uids1\"}}],\"kind\":\"List\",\"metadata\":{\"resourceVersion\":\"\",\"selfLink\":\"\"}}")); - using var client = new k8s.Kubernetes( - config: new KubernetesClientConfiguration { Host = "http://localhost" }, - httpClient: mockHttpMessageHandler.ToHttpClient()); + using var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); var options = new TestOptionsMonitor(new KubernetesDiscoveryOptions() { @@ -244,9 +237,7 @@ public void GetServices_ShouldReturnAllServicesWhenNoLabelsAreAppliedToTheClient "\"endpoint3\",\"namespace\":\"test\",\"uid\":\"uids2\"}}],\"kind\":\"List\",\"metadata\"" + ":{\"resourceVersion\":\"\",\"selfLink\":\"\"}}")); - using var client = new k8s.Kubernetes( - config: new KubernetesClientConfiguration { Host = "http://localhost" }, - httpClient: mockHttpMessageHandler.ToHttpClient()); + using var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); var options = new TestOptionsMonitor(new KubernetesDiscoveryOptions() { @@ -284,9 +275,7 @@ public void GetServices_ShouldReturnOnlyMatchingServicesWhenLabelsAreAppliedToTh "\"kind\":\"List\",\"metadata\"" + ":{\"resourceVersion\":\"\",\"selfLink\":\"\"}}")); - using var client = new k8s.Kubernetes( - config: new KubernetesClientConfiguration { Host = "http://localhost" }, - httpClient: mockHttpMessageHandler.ToHttpClient()); + using var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); var options = new TestOptionsMonitor(new KubernetesDiscoveryOptions() { @@ -326,9 +315,7 @@ public void EnabledPropertyWorksBothWays() "\"kind\":\"List\",\"metadata\"" + ":{\"resourceVersion\":\"\",\"selfLink\":\"\"}}")); - using var client = new k8s.Kubernetes( - config: new KubernetesClientConfiguration { Host = "http://localhost" }, - httpClient: mockHttpMessageHandler.ToHttpClient()); + using var client = KubernetesTestClientFactory.Create(new KubernetesClientConfiguration { Host = "http://localhost" }, mockHttpMessageHandler); var k8sOptions = new KubernetesDiscoveryOptions() { Enabled = false, Namespace = "test" }; var options = new TestOptionsMonitor(k8sOptions); diff --git a/src/Discovery/test/Kubernetes.Test/Steeltoe.Discovery.Kubernetes.Test.csproj b/src/Discovery/test/Kubernetes.Test/Steeltoe.Discovery.Kubernetes.Test.csproj index 556daf21d3..780d66aec1 100644 --- a/src/Discovery/test/Kubernetes.Test/Steeltoe.Discovery.Kubernetes.Test.csproj +++ b/src/Discovery/test/Kubernetes.Test/Steeltoe.Discovery.Kubernetes.Test.csproj @@ -1,7 +1,7 @@ - net8.0;net6.0 + net8.0 enable diff --git a/src/Integration/src/Abstractions/Steeltoe.Integration.Abstractions.csproj b/src/Integration/src/Abstractions/Steeltoe.Integration.Abstractions.csproj index 456519a7c2..97e3ae201e 100644 --- a/src/Integration/src/Abstractions/Steeltoe.Integration.Abstractions.csproj +++ b/src/Integration/src/Abstractions/Steeltoe.Integration.Abstractions.csproj @@ -1,6 +1,6 @@ - net6.0 + net8.0 Steeltoe.Integration Abstractions for use with Steeltoe Integration libraries diff --git a/src/Integration/src/IntegrationBase/Steeltoe.Integration.IntegrationBase.csproj b/src/Integration/src/IntegrationBase/Steeltoe.Integration.IntegrationBase.csproj index 69b7db88a9..ec35586572 100644 --- a/src/Integration/src/IntegrationBase/Steeltoe.Integration.IntegrationBase.csproj +++ b/src/Integration/src/IntegrationBase/Steeltoe.Integration.IntegrationBase.csproj @@ -5,7 +5,7 @@ Steeltoe Integration Base **PLEASE NOTE** The public API of this package is subject to change and is not recommended for direct use outside of Steeltoe. - net6.0 + net8.0 Steeltoe.Integration Integration, NET Core, Spring, Spring Cloud diff --git a/src/Integration/src/RabbitMQ/Steeltoe.Integration.RabbitMQ.csproj b/src/Integration/src/RabbitMQ/Steeltoe.Integration.RabbitMQ.csproj index 15a4f8a3c5..f593550fcc 100644 --- a/src/Integration/src/RabbitMQ/Steeltoe.Integration.RabbitMQ.csproj +++ b/src/Integration/src/RabbitMQ/Steeltoe.Integration.RabbitMQ.csproj @@ -5,7 +5,7 @@ Steeltoe Integration RabbitMQ **PLEASE NOTE** The public API of this package is subject to change and is not recommended for direct use outside of Steeltoe. - net6.0 + net8.0 Steeltoe.Integration.RabbitMQ Integration, ASPNET Core, Spring, Spring Cloud, RabbitMQ diff --git a/src/Integration/test/Benchmark/Benchmark.csproj b/src/Integration/test/Benchmark/Benchmark.csproj index 43ff5e7227..23f045cb80 100644 --- a/src/Integration/test/Benchmark/Benchmark.csproj +++ b/src/Integration/test/Benchmark/Benchmark.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 false diff --git a/src/Integration/test/IntegrationBase.Test/Steeltoe.Integration.IntegrationBase.Test.csproj b/src/Integration/test/IntegrationBase.Test/Steeltoe.Integration.IntegrationBase.Test.csproj index 2fd3fd1fe2..9f9f0b4e67 100644 --- a/src/Integration/test/IntegrationBase.Test/Steeltoe.Integration.IntegrationBase.Test.csproj +++ b/src/Integration/test/IntegrationBase.Test/Steeltoe.Integration.IntegrationBase.Test.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 Steeltoe.Integration diff --git a/src/Integration/test/RabbitMQ.Test/Steeltoe.Integration.RabbitMQ.Test.csproj b/src/Integration/test/RabbitMQ.Test/Steeltoe.Integration.RabbitMQ.Test.csproj index 5e3847ef06..3fe1b1513c 100644 --- a/src/Integration/test/RabbitMQ.Test/Steeltoe.Integration.RabbitMQ.Test.csproj +++ b/src/Integration/test/RabbitMQ.Test/Steeltoe.Integration.RabbitMQ.Test.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 Steeltoe.Integration.RabbitMQ diff --git a/src/Logging/src/Abstractions/Steeltoe.Extensions.Logging.Abstractions.csproj b/src/Logging/src/Abstractions/Steeltoe.Extensions.Logging.Abstractions.csproj index ef03fdc81a..036c62dcac 100644 --- a/src/Logging/src/Abstractions/Steeltoe.Extensions.Logging.Abstractions.csproj +++ b/src/Logging/src/Abstractions/Steeltoe.Extensions.Logging.Abstractions.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Extensions.Logging Abstractions for use with dynamic logging diff --git a/src/Logging/src/DynamicLogger/DynamicLoggingBuilder.cs b/src/Logging/src/DynamicLogger/DynamicLoggingBuilder.cs index 70c01b6313..e454f4e2dc 100644 --- a/src/Logging/src/DynamicLogger/DynamicLoggingBuilder.cs +++ b/src/Logging/src/DynamicLogger/DynamicLoggingBuilder.cs @@ -60,7 +60,6 @@ public ConsoleLoggerOptionsSetup(ILoggerProviderConfiguration - net8.0;net6.0;netstandard2.0 + net8.0;netstandard2.0 Steeltoe Dynamic Console Logger logging;dynamic logging;console;management;monitoring;Spring Cloud; @@ -8,7 +8,7 @@ - + diff --git a/src/Logging/src/DynamicSerilogBase/Steeltoe.Extensions.Logging.DynamicSerilogBase.csproj b/src/Logging/src/DynamicSerilogBase/Steeltoe.Extensions.Logging.DynamicSerilogBase.csproj index 72c9300f09..55e2588e43 100644 --- a/src/Logging/src/DynamicSerilogBase/Steeltoe.Extensions.Logging.DynamicSerilogBase.csproj +++ b/src/Logging/src/DynamicSerilogBase/Steeltoe.Extensions.Logging.DynamicSerilogBase.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + net8.0;netstandard2.0 Steeltoe library for enabling dynamic management of Serilog. logging;dynamic logging;serilog;management;monitoring;Spring Cloud; Steeltoe.Extensions.Logging.DynamicSerilog diff --git a/src/Logging/src/DynamicSerilogCore/Steeltoe.Extensions.Logging.DynamicSerilogCore.csproj b/src/Logging/src/DynamicSerilogCore/Steeltoe.Extensions.Logging.DynamicSerilogCore.csproj index 64e3447be7..362a1259ce 100644 --- a/src/Logging/src/DynamicSerilogCore/Steeltoe.Extensions.Logging.DynamicSerilogCore.csproj +++ b/src/Logging/src/DynamicSerilogCore/Steeltoe.Extensions.Logging.DynamicSerilogCore.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe library for enabling dynamic management of Serilog in ASP.NET Core applications. Includes Console sink. logging;dynamic logging;serilog;aspnetcore;management;monitoring;Spring Cloud; Steeltoe.Extensions.Logging.DynamicSerilog diff --git a/src/Logging/test/DynamicLogger.Test/DynamicLoggingBuilderTest.cs b/src/Logging/test/DynamicLogger.Test/DynamicLoggingBuilderTest.cs index 93eb1daaa4..93323041bc 100644 --- a/src/Logging/test/DynamicLogger.Test/DynamicLoggingBuilderTest.cs +++ b/src/Logging/test/DynamicLogger.Test/DynamicLoggingBuilderTest.cs @@ -178,9 +178,8 @@ public void DynamicLevelSetting_ParmLessAddDynamic_AddsConsoleOptions() Assert.NotNull(options); Assert.NotNull(options.CurrentValue); -#if !NET6_0_OR_GREATER + Assert.True(options.CurrentValue.DisableColors); -#endif } [Fact] @@ -237,9 +236,8 @@ public void AddDynamicConsole_DoesntSetColorLocal() var options = services.GetService(typeof(IOptions)) as IOptions; Assert.NotNull(options); -#if !NET6_0_OR_GREATER + Assert.False(options.Value.DisableColors); -#endif } [Fact] @@ -257,9 +255,9 @@ public void AddDynamicConsole_DisablesColorOnPivotalPlatform() var options = services.GetService(typeof(IOptions)) as IOptions; Assert.NotNull(options); -#if !NET6_0_OR_GREATER + Assert.True(options.Value.DisableColors); -#endif + Environment.SetEnvironmentVariable("VCAP_APPLICATION", string.Empty); } } \ No newline at end of file diff --git a/src/Logging/test/DynamicLogger.Test/Steeltoe.Extensions.Logging.DynamicLogger.Test.csproj b/src/Logging/test/DynamicLogger.Test/Steeltoe.Extensions.Logging.DynamicLogger.Test.csproj index 4a5c87712e..069eef7570 100644 --- a/src/Logging/test/DynamicLogger.Test/Steeltoe.Extensions.Logging.DynamicLogger.Test.csproj +++ b/src/Logging/test/DynamicLogger.Test/Steeltoe.Extensions.Logging.DynamicLogger.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Logging/test/DynamicSerilogBase.Test/Steeltoe.Extensions.Logging.DynamicSerilogBase.Test.csproj b/src/Logging/test/DynamicSerilogBase.Test/Steeltoe.Extensions.Logging.DynamicSerilogBase.Test.csproj index 9c37fef84e..3a8196424a 100644 --- a/src/Logging/test/DynamicSerilogBase.Test/Steeltoe.Extensions.Logging.DynamicSerilogBase.Test.csproj +++ b/src/Logging/test/DynamicSerilogBase.Test/Steeltoe.Extensions.Logging.DynamicSerilogBase.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.Extensions.Logging.DynamicSerilog.Test diff --git a/src/Logging/test/DynamicSerilogCore.Test/Steeltoe.Extensions.Logging.DynamicSerilogCore.Test.csproj b/src/Logging/test/DynamicSerilogCore.Test/Steeltoe.Extensions.Logging.DynamicSerilogCore.Test.csproj index ec69e79755..6d1eadb43c 100644 --- a/src/Logging/test/DynamicSerilogCore.Test/Steeltoe.Extensions.Logging.DynamicSerilogCore.Test.csproj +++ b/src/Logging/test/DynamicSerilogCore.Test/Steeltoe.Extensions.Logging.DynamicSerilogCore.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.Extensions.Logging.DynamicSerilog.Test diff --git a/src/Management/src/Abstractions/Steeltoe.Management.Abstractions.csproj b/src/Management/src/Abstractions/Steeltoe.Management.Abstractions.csproj index fb8ddbb78e..7c985afaa8 100644 --- a/src/Management/src/Abstractions/Steeltoe.Management.Abstractions.csproj +++ b/src/Management/src/Abstractions/Steeltoe.Management.Abstractions.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Management Abstractions for application management and monitoring @@ -11,7 +11,7 @@ - + diff --git a/src/Management/src/CloudFoundryCore/Steeltoe.Management.CloudFoundryCore.csproj b/src/Management/src/CloudFoundryCore/Steeltoe.Management.CloudFoundryCore.csproj index 96335387ad..63dede5487 100644 --- a/src/Management/src/CloudFoundryCore/Steeltoe.Management.CloudFoundryCore.csproj +++ b/src/Management/src/CloudFoundryCore/Steeltoe.Management.CloudFoundryCore.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.Management.CloudFoundry Package for using Steeltoe management endpoints with ASP.NET Core on Cloud Foundry. actuator;management;monitoring;aspnetcore;CloudFoundry;Spring Cloud; diff --git a/src/Management/src/Diagnostics/Steeltoe.Management.Diagnostics.csproj b/src/Management/src/Diagnostics/Steeltoe.Management.Diagnostics.csproj index 9665471197..af79717cb1 100644 --- a/src/Management/src/Diagnostics/Steeltoe.Management.Diagnostics.csproj +++ b/src/Management/src/Diagnostics/Steeltoe.Management.Diagnostics.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe Management Runtime Diagnostics actuator;management;monitoring;Spring Cloud; true diff --git a/src/Management/src/EndpointBase/Steeltoe.Management.EndpointBase.csproj b/src/Management/src/EndpointBase/Steeltoe.Management.EndpointBase.csproj index 7c9cf2720d..bb08fb6b6c 100644 --- a/src/Management/src/EndpointBase/Steeltoe.Management.EndpointBase.csproj +++ b/src/Management/src/EndpointBase/Steeltoe.Management.EndpointBase.csproj @@ -1,6 +1,6 @@ - + - netstandard2.1 + net8.0 Steeltoe.Management.Endpoint Steeltoe management endpoints actuator;management;monitoring;Spring Cloud; @@ -20,7 +20,7 @@ - + diff --git a/src/Management/src/EndpointCore/ActuatorRouteBuilderExtensions.cs b/src/Management/src/EndpointCore/ActuatorRouteBuilderExtensions.cs index 0de2281633..7855fafd27 100644 --- a/src/Management/src/EndpointCore/ActuatorRouteBuilderExtensions.cs +++ b/src/Management/src/EndpointCore/ActuatorRouteBuilderExtensions.cs @@ -65,23 +65,6 @@ public static void Map(this IEndpointRouteBuilder endpoints, Action - /// Generic routebuilder extension for Actuators. - /// - /// IEndpointRouteBuilder to Map route. - /// A convention builder that applies a convention to the whole collection. - /// Middleware for which the route is mapped. - /// When T is not found in service container - public static IEndpointConventionBuilder Map(this IEndpointRouteBuilder endpoints, EndpointCollectionConventionBuilder conventionBuilder) - where TEndpoint : IEndpoint - { -#pragma warning disable CS0618 // Type or member is obsolete - return MapActuatorEndpoint(endpoints, typeof(TEndpoint), conventionBuilder); -#pragma warning restore CS0618 // Type or member is obsolete - } -#endif - /// /// Maps all actuators that have been registered in /// @@ -103,33 +86,6 @@ public static void MapAllActuators(this IEndpointRouteBuilder endpoints, Action< } } -#if !NET6_0_OR_GREATER - /// - /// Maps all actuators that have been registered in - /// - /// The endpoint builder - /// Endpoint convention builder - [Obsolete("Use MapAllActuators(this IEndpointRouteBuilder endpoints, Action convention) instead")] - public static IEndpointConventionBuilder MapAllActuators(this IEndpointRouteBuilder endpoints) - { - var conventionBuilder = new EndpointCollectionConventionBuilder(); - - foreach (var endpointEntry in endpoints.ServiceProvider.GetServices()) - { - // Some actuators only work on some platforms. i.e. Windows and Linux - // Some actuators have different implementation depending on the MediaTypeVersion - // Previously those checks where performed here and when adding things to the IServiceCollection - // Now all that logic is handled in the IServiceCollection setup; no need to keep code in two different places in sync - - // This function just takes what has been registered, and sets up the endpoints - // This keeps this method flexible; new actuators that are added later should automatically become available - endpointEntry.Setup(endpoints, conventionBuilder); - } - - return conventionBuilder; - } -#else - /// /// Maps all actuators that have been registered in /// @@ -138,7 +94,6 @@ public static void MapAllActuators(this IEndpointRouteBuilder endpoints) { MapAllActuators(endpoints, null); } -#endif /// /// Maps all actuators that have been registered in @@ -187,49 +142,6 @@ internal static void MapActuatorEndpoint(this IEndpointRouteBuilder endpoints, T } } -#if !NET6_0_OR_GREATER - [Obsolete("MediaTypeVersion parameter is not used")] - internal static IEndpointConventionBuilder MapActuatorEndpoint(this IEndpointRouteBuilder endpoints, Type typeEndpoint, EndpointCollectionConventionBuilder conventionBuilder = null) - { - if (endpoints == null) - { - throw new ArgumentNullException(nameof(endpoints)); - } - - ConnectEndpointOptionsWithManagementOptions(endpoints); - - var (middleware, optionsType) = LookupMiddleware(typeEndpoint); - var options = endpoints.ServiceProvider.GetService(optionsType) as IEndpointOptions; - var mgmtOptionsCollection = endpoints.ServiceProvider.GetServices(); - var builder = conventionBuilder ?? new EndpointCollectionConventionBuilder(); - - foreach (var mgmtOptions in mgmtOptionsCollection) - { - if ((mgmtOptions is CloudFoundryManagementOptions && options is IActuatorHypermediaOptions) - || (mgmtOptions is ActuatorManagementOptions && options is ICloudFoundryOptions)) - { - continue; - } - - var fullPath = options.GetContextPath(mgmtOptions); - - var pattern = RoutePatternFactory.Parse(fullPath); - - // only add middleware if the route hasn't already been mapped - if (!endpoints.DataSources.Any(d => d.Endpoints.Any(ep => ep is RouteEndpoint endpoint && endpoint.RoutePattern.RawText == pattern.RawText))) - { - var pipeline = endpoints.CreateApplicationBuilder() - .UseMiddleware(middleware, mgmtOptions) - .Build(); - var allowedVerbs = options.AllowedVerbs ?? new List { "Get" }; - builder.AddConventionBuilder(endpoints.MapMethods(fullPath, allowedVerbs, pipeline)); - } - } - - return builder; - } -#endif - private static void ConnectEndpointOptionsWithManagementOptions(IEndpointRouteBuilder endpoints) { var serviceProvider = endpoints.ServiceProvider; diff --git a/src/Management/src/EndpointCore/Extensions/ServiceCollectionExtensions.cs b/src/Management/src/EndpointCore/Extensions/ServiceCollectionExtensions.cs index 30cedf1ce2..3771906618 100644 --- a/src/Management/src/EndpointCore/Extensions/ServiceCollectionExtensions.cs +++ b/src/Management/src/EndpointCore/Extensions/ServiceCollectionExtensions.cs @@ -21,12 +21,7 @@ public static IServiceCollection AddActuatorEndpointMapping(this ISer { services.AddSingleton(new EndpointMappingEntry { - // new way compatible with .NET 6 SetupConvention = (endpoints, conventionBuilder) => endpoints.Map(conventionBuilder), -#if !NET6_0_OR_GREATER - // old way for backwards compatibility, will be removed in the future - Setup = (endpoints, convention) => endpoints.Map(convention) -#endif }); return services; } diff --git a/src/Management/src/EndpointCore/Steeltoe.Management.EndpointCore.csproj b/src/Management/src/EndpointCore/Steeltoe.Management.EndpointCore.csproj index 99aac0bfe0..8cb1eefbba 100644 --- a/src/Management/src/EndpointCore/Steeltoe.Management.EndpointCore.csproj +++ b/src/Management/src/EndpointCore/Steeltoe.Management.EndpointCore.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.Management.Endpoint Package for using Steeltoe management endpoints with ASP.NET Core. Spring Cloud;Actuator;Management;Monitoring @@ -10,9 +10,9 @@ - + - + diff --git a/src/Management/src/KubernetesCore/KubernetesInfoContributor.cs b/src/Management/src/KubernetesCore/KubernetesInfoContributor.cs index e5fad6c935..043fbecb1b 100644 --- a/src/Management/src/KubernetesCore/KubernetesInfoContributor.cs +++ b/src/Management/src/KubernetesCore/KubernetesInfoContributor.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using k8s.Models; using Steeltoe.Common.Kubernetes; using Steeltoe.Management.Info; using System.Collections.Generic; @@ -25,7 +26,7 @@ public void Contribute(IInfoBuilder builder) if (current != null) { details.Add("inside", true); - details.Add("namespace", current.Metadata.NamespaceProperty); + details.Add("namespace", current.Metadata.Namespace()); details.Add("podName", current.Metadata.Name); details.Add("podIp", current.Status.PodIP); details.Add("serviceAccount", current.Spec.ServiceAccountName); diff --git a/src/Management/src/KubernetesCore/Steeltoe.Management.KubernetesCore.csproj b/src/Management/src/KubernetesCore/Steeltoe.Management.KubernetesCore.csproj index c1a7c71abb..56d93e01ba 100644 --- a/src/Management/src/KubernetesCore/Steeltoe.Management.KubernetesCore.csproj +++ b/src/Management/src/KubernetesCore/Steeltoe.Management.KubernetesCore.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Package for using Steeltoe management endpoints with ASP.NET Core on Kubernetes. actuator;management;monitoring;aspnetcore;Kubernetes;Spring Cloud;k8s diff --git a/src/Management/src/OpenTelemetryBase/Steeltoe - Backup.Management.OpenTelemetryBase.csproj b/src/Management/src/OpenTelemetryBase/Steeltoe - Backup.Management.OpenTelemetryBase.csproj deleted file mode 100644 index a7472073db..0000000000 --- a/src/Management/src/OpenTelemetryBase/Steeltoe - Backup.Management.OpenTelemetryBase.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - Steeltoe Management OpenTelemetry - net8.0;net6.0;netstandard2.0 - Steeltoe.Management.OpenTelemetryBase - Steeltoe.Management.OpenTelemetryBase - Tracing;OpenTelemetry;Management;Monitoring - Steeltoe.Management.OpenTelemetry - - - - - - - - - - - - - - - - diff --git a/src/Management/src/OpenTelemetryBase/Steeltoe.Management.OpenTelemetryBase.csproj b/src/Management/src/OpenTelemetryBase/Steeltoe.Management.OpenTelemetryBase.csproj index d0d8400067..7bb4c6e1f3 100644 --- a/src/Management/src/OpenTelemetryBase/Steeltoe.Management.OpenTelemetryBase.csproj +++ b/src/Management/src/OpenTelemetryBase/Steeltoe.Management.OpenTelemetryBase.csproj @@ -1,7 +1,7 @@ Steeltoe Management OpenTelemetry - netstandard2.1 + net8.0 Steeltoe.Management.OpenTelemetryBase Steeltoe.Management.OpenTelemetryBase Tracing;OpenTelemetry;Management;Monitoring diff --git a/src/Management/src/TaskCore/Steeltoe.Management.TaskCore.csproj b/src/Management/src/TaskCore/Steeltoe.Management.TaskCore.csproj index 5db4ea7d15..c0217ec588 100644 --- a/src/Management/src/TaskCore/Steeltoe.Management.TaskCore.csproj +++ b/src/Management/src/TaskCore/Steeltoe.Management.TaskCore.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Extensions for running tasks embedded in your ASP.NET Core application. Ideal for cf run-task in Cloud Foundry. tasks;management;monitoring;aspnetcore;Spring Cloud;cf run-task diff --git a/src/Management/src/TracingBase/Steeltoe.Management.TracingBase.csproj b/src/Management/src/TracingBase/Steeltoe.Management.TracingBase.csproj index 0275fba85b..2ba2e116de 100644 --- a/src/Management/src/TracingBase/Steeltoe.Management.TracingBase.csproj +++ b/src/Management/src/TracingBase/Steeltoe.Management.TracingBase.csproj @@ -1,6 +1,6 @@ - + - netstandard2.1 + net8.0 Steeltoe.Management.Tracing Base package for enabling request tracing in distributed systems. management;monitoring;distributed trace @@ -12,7 +12,7 @@ - + diff --git a/src/Management/src/TracingCore/Steeltoe.Management.TracingCore.csproj b/src/Management/src/TracingCore/Steeltoe.Management.TracingCore.csproj index c3758c8f13..71ab054274 100644 --- a/src/Management/src/TracingCore/Steeltoe.Management.TracingCore.csproj +++ b/src/Management/src/TracingCore/Steeltoe.Management.TracingCore.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.Management.Tracing Add distributed tracing to ASP.NET Core applications aspnetcore;management;monitoring;metrics;Distributed Trace @@ -11,7 +11,7 @@ - + diff --git a/src/Management/test/CloudFoundryCore.Test/Steeltoe.Management.CloudFoundryCore.Test.csproj b/src/Management/test/CloudFoundryCore.Test/Steeltoe.Management.CloudFoundryCore.Test.csproj index 5ec252cc25..5929652c07 100644 --- a/src/Management/test/CloudFoundryCore.Test/Steeltoe.Management.CloudFoundryCore.Test.csproj +++ b/src/Management/test/CloudFoundryCore.Test/Steeltoe.Management.CloudFoundryCore.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Management/test/EndpointBase.Test/Steeltoe.Management.EndpointBase.Test.csproj b/src/Management/test/EndpointBase.Test/Steeltoe.Management.EndpointBase.Test.csproj index 9edcafe547..a36dd6f78b 100644 --- a/src/Management/test/EndpointBase.Test/Steeltoe.Management.EndpointBase.Test.csproj +++ b/src/Management/test/EndpointBase.Test/Steeltoe.Management.EndpointBase.Test.csproj @@ -1,6 +1,6 @@  - net8.0;net6.0 + net8.0 Steeltoe.Management.Endpoint.Test diff --git a/src/Management/test/EndpointCore.Test/ManagementWebHostBuilderExtensionsTest.cs b/src/Management/test/EndpointCore.Test/ManagementWebHostBuilderExtensionsTest.cs index 2af1fc6d57..9b585063de 100644 --- a/src/Management/test/EndpointCore.Test/ManagementWebHostBuilderExtensionsTest.cs +++ b/src/Management/test/EndpointCore.Test/ManagementWebHostBuilderExtensionsTest.cs @@ -639,7 +639,8 @@ public async Task AddAllActuators_Doesnt_Interfere_With_OpenTelemetryExtensions_ Assert.Contains("OpenTelemetry for Steeltoe", output); // Assert Otel configuration is respected - Assert.Contains("Metric Name: TestCounter, Meter: TestMeter", output); + Assert.Contains("Metric Name: TestCounter", output); + Assert.Contains("Name: TestMeter", output); } } @@ -679,7 +680,8 @@ public async Task AddAllActuators_Doesnt_Interfere_With_OpenTelemetryExtensions_ Assert.Contains("OpenTelemetry for Steeltoe", output); // Assert Otel configuration is respected - Assert.Contains("Metric Name: TestCounter, Meter: TestMeter", output); + Assert.Contains("Metric Name: TestCounter", output); + Assert.Contains("Name: TestMeter", output); // Assert Steeltoe configuration is respected Assert.Contains("Metric Name: clr.process.uptime", output); @@ -722,7 +724,8 @@ public async Task AddAllActuators_Doesnt_Interfere_With_OpenTelemetryExtensions_ Assert.DoesNotContain("OpenTelemetry for Steeltoe", output); // Assert Otel configuration is respected - Assert.Contains("Metric Name: TestCounter, Meter: TestMeter", output); + Assert.Contains("Metric Name: TestCounter", output); + Assert.Contains("Name: TestMeter", output); } } diff --git a/src/Management/test/EndpointCore.Test/Steeltoe.Management.EndpointCore.Test.csproj b/src/Management/test/EndpointCore.Test/Steeltoe.Management.EndpointCore.Test.csproj index ee836f4c8a..6a17d4201a 100644 --- a/src/Management/test/EndpointCore.Test/Steeltoe.Management.EndpointCore.Test.csproj +++ b/src/Management/test/EndpointCore.Test/Steeltoe.Management.EndpointCore.Test.csproj @@ -1,6 +1,6 @@  - net8.0;net6.0 + net8.0 Steeltoe.Management.EndpointCore.Test Steeltoe.Management.Endpoint.Test diff --git a/src/Management/test/KubernetesCore.Test/FakePodUtilities.cs b/src/Management/test/KubernetesCore.Test/FakePodUtilities.cs index 19dda976a4..4798c61a5c 100644 --- a/src/Management/test/KubernetesCore.Test/FakePodUtilities.cs +++ b/src/Management/test/KubernetesCore.Test/FakePodUtilities.cs @@ -10,12 +10,19 @@ namespace Steeltoe.Management.Kubernetes.Test; internal class FakePodUtilities : IPodUtilities { - internal static V1Pod SamplePod { get; } = new V1Pod + internal static V1Pod SamplePod { get; } = CreateSamplePod(); + + private static V1Pod CreateSamplePod() { - Metadata = new V1ObjectMeta { NamespaceProperty = "mynamespace", Name = "mypod" }, - Status = new V1PodStatus { PodIP = "mypodip", HostIP = "myhostip" }, - Spec = new V1PodSpec { ServiceAccountName = "myserviceaccount", NodeName = "mynode" } - }; + var metadata = new V1ObjectMeta { Name = "mypod" }; + metadata.SetNamespace("mynamespace"); + return new V1Pod + { + Metadata = metadata, + Status = new V1PodStatus { PodIP = "mypodip", HostIP = "myhostip" }, + Spec = new V1PodSpec { ServiceAccountName = "myserviceaccount", NodeName = "mynode" } + }; + } private readonly V1Pod fakePod; diff --git a/src/Management/test/KubernetesCore.Test/Steeltoe.Management.KubernetesCore.Test.csproj b/src/Management/test/KubernetesCore.Test/Steeltoe.Management.KubernetesCore.Test.csproj index ea00df0f55..af1f54918a 100644 --- a/src/Management/test/KubernetesCore.Test/Steeltoe.Management.KubernetesCore.Test.csproj +++ b/src/Management/test/KubernetesCore.Test/Steeltoe.Management.KubernetesCore.Test.csproj @@ -1,7 +1,7 @@  - net8.0;net6.0 + net8.0 false diff --git a/src/Management/test/TaskCore.Test/Steeltoe.Management.TaskCore.Test.csproj b/src/Management/test/TaskCore.Test/Steeltoe.Management.TaskCore.Test.csproj index 97132e8bb9..a900c6f49e 100644 --- a/src/Management/test/TaskCore.Test/Steeltoe.Management.TaskCore.Test.csproj +++ b/src/Management/test/TaskCore.Test/Steeltoe.Management.TaskCore.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Management/test/TracingBase.Test/Steeltoe.Management.TracingBase.Test.csproj b/src/Management/test/TracingBase.Test/Steeltoe.Management.TracingBase.Test.csproj index 55769c8993..0bb01d5458 100644 --- a/src/Management/test/TracingBase.Test/Steeltoe.Management.TracingBase.Test.csproj +++ b/src/Management/test/TracingBase.Test/Steeltoe.Management.TracingBase.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Management/test/TracingBase.Test/TestBase.cs b/src/Management/test/TracingBase.Test/TestBase.cs index 233fc0e0eb..8af2deed76 100644 --- a/src/Management/test/TracingBase.Test/TestBase.cs +++ b/src/Management/test/TracingBase.Test/TestBase.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. @@ -9,6 +9,7 @@ using OpenTelemetry.Trace; using Steeltoe.Extensions.Logging; using Steeltoe.Management.OpenTelemetry.Trace; +using System; using System.Collections.Generic; using System.Reflection; using Xunit; @@ -38,10 +39,7 @@ protected TelemetrySpan GetCurrentSpan(Tracer tracer) return span.Context.IsValid ? span : null; } - protected object GetPrivateField(object baseObject, string fieldName) - => baseObject.GetType().GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance).GetValue(baseObject); - - protected void ValidateServiceCollectionCommon(ServiceProvider serviceProvider) + protected void ValidateServiceCollectionCommon(IServiceProvider serviceProvider) { // confirm Steeltoe types were registered Assert.NotNull(serviceProvider.GetService()); @@ -54,32 +52,51 @@ protected void ValidateServiceCollectionCommon(ServiceProvider serviceProvider) Assert.NotNull(hst); } - protected void ValidateServiceCollectionBase(ServiceProvider serviceProvider) + protected void ValidateServiceCollectionBase(IServiceProvider serviceProvider) { // confirm instrumentation(s) were added as expected var tracerProvider = serviceProvider.GetService(); - var instrumentations = GetPrivateField(tracerProvider, "instrumentations") as List; + var instrumentations = GetNonPublicTracerProviderInstrumentations(tracerProvider); Assert.NotNull(instrumentations); Assert.Single(instrumentations); Assert.Contains(instrumentations, obj => obj.GetType().Name.Contains("Http")); Assert.IsType(Propagators.DefaultTextMapPropagator); var comp = Propagators.DefaultTextMapPropagator as CompositeTextMapPropagator; - var props = GetPrivateField(comp, "propagators") as List; + var props = GetNonPublicCompositePropagators(comp); + Assert.NotNull(props); Assert.Equal(2, props.Count); Assert.Contains(props, p => p is B3Propagator); Assert.Contains(props, p => p is BaggagePropagator); } - protected void ValidateServiceContainerCore(ServiceProvider serviceProvider) + protected void ValidateServiceContainerCore(IServiceProvider serviceProvider) { var tracerProvider = serviceProvider.GetService(); // confirm instrumentation(s) were added as expected - var instrumentations = GetPrivateField(tracerProvider, "instrumentations") as List; + var instrumentations = GetNonPublicTracerProviderInstrumentations(tracerProvider); Assert.NotNull(instrumentations); Assert.Equal(2, instrumentations.Count); Assert.Contains(instrumentations, obj => obj.GetType().Name.Contains("Http")); Assert.Contains(instrumentations, obj => obj.GetType().Name.Contains("AspNetCore")); } + + private static List GetNonPublicTracerProviderInstrumentations(TracerProvider tracerProvider) + { + var property = tracerProvider?.GetType().GetProperty( + "Instrumentations", + BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); + + return property?.GetValue(tracerProvider) as List; + } + + private static List GetNonPublicCompositePropagators(CompositeTextMapPropagator composite) + { + var field = composite?.GetType().GetField( + "propagators", + BindingFlags.NonPublic | BindingFlags.Instance); + + return field?.GetValue(composite) as List; + } } \ No newline at end of file diff --git a/src/Management/test/TracingBase.Test/TracingBaseHostBuilderExtensionsTest.cs b/src/Management/test/TracingBase.Test/TracingBaseHostBuilderExtensionsTest.cs index a1d3b63ad4..f860680e75 100644 --- a/src/Management/test/TracingBase.Test/TracingBaseHostBuilderExtensionsTest.cs +++ b/src/Management/test/TracingBase.Test/TracingBaseHostBuilderExtensionsTest.cs @@ -1,17 +1,10 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Options; -using OpenTelemetry.Context.Propagation; -using OpenTelemetry.Exporter; -using OpenTelemetry.Trace; -using Steeltoe.Extensions.Logging; -using Steeltoe.Management.OpenTelemetry.Trace; using System; -using System.Collections.Generic; using Xunit; namespace Steeltoe.Management.Tracing.Test; @@ -29,16 +22,14 @@ public void AddDistributedTracing_ThrowsOnNulls() public void AddDistributedTracing_ConfiguresExpectedDefaults() { var hostBuilder = new HostBuilder(); - IServiceCollection services = null; hostBuilder.ConfigureServices(svc => { - services = svc; svc.AddSingleton(GetConfiguration()); svc.AddDistributedTracing(); }); - var host = hostBuilder.Build(); - var serviceProvider = services.BuildServiceProvider(); - ValidateServiceCollectionCommon(serviceProvider); - ValidateServiceCollectionBase(serviceProvider); + + using var host = hostBuilder.Build(); + ValidateServiceCollectionCommon(host.Services); + ValidateServiceCollectionBase(host.Services); } } \ No newline at end of file diff --git a/src/Management/test/TracingBase.Test/TracingBaseServiceCollectionExtensionsTest.cs b/src/Management/test/TracingBase.Test/TracingBaseServiceCollectionExtensionsTest.cs index ff6fb15817..36a9e9bd43 100644 --- a/src/Management/test/TracingBase.Test/TracingBaseServiceCollectionExtensionsTest.cs +++ b/src/Management/test/TracingBase.Test/TracingBaseServiceCollectionExtensionsTest.cs @@ -1,15 +1,12 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; -using OpenTelemetry.Context.Propagation; using OpenTelemetry.Exporter; using OpenTelemetry.Trace; -using Steeltoe.Extensions.Logging; -using Steeltoe.Management.OpenTelemetry.Trace; using System; using System.Collections.Generic; using Xunit; @@ -42,7 +39,7 @@ public void AddDistributedTracing_WiresIncludedExporters() { var services = new ServiceCollection().AddSingleton(GetConfiguration()); - var serviceProvider = services.AddDistributedTracing(null).BuildServiceProvider(); + var serviceProvider = services.AddDistributedTracing().BuildServiceProvider(); var hst = serviceProvider.GetService(); Assert.NotNull(hst); var tracerProvider = serviceProvider.GetService(); @@ -56,7 +53,7 @@ public void AddDistributedTracing_ConfiguresSamplers() { // test AlwaysOn var services = new ServiceCollection().AddSingleton(GetConfiguration(new Dictionary { { "Management:Tracing:AlwaysSample", "true" } })); - var serviceProvider = services.AddDistributedTracing(null).BuildServiceProvider(); + var serviceProvider = services.AddDistributedTracing().BuildServiceProvider(); var hst = serviceProvider.GetService(); Assert.NotNull(hst); var tracerProvider = serviceProvider.GetService(); @@ -64,7 +61,7 @@ public void AddDistributedTracing_ConfiguresSamplers() // test AlwaysOff services = new ServiceCollection().AddSingleton(GetConfiguration(new Dictionary { { "Management:Tracing:NeverSample", "true" } })); - serviceProvider = services.AddDistributedTracing(null).BuildServiceProvider(); + serviceProvider = services.AddDistributedTracing().BuildServiceProvider(); hst = serviceProvider.GetService(); Assert.NotNull(hst); tracerProvider = serviceProvider.GetService(); diff --git a/src/Management/test/TracingCore.Test/Steeltoe.Management.TracingCore.Test.csproj b/src/Management/test/TracingCore.Test/Steeltoe.Management.TracingCore.Test.csproj index 99d3b4f7e2..f3f86e840f 100644 --- a/src/Management/test/TracingCore.Test/Steeltoe.Management.TracingCore.Test.csproj +++ b/src/Management/test/TracingCore.Test/Steeltoe.Management.TracingCore.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Management/test/TracingCore.Test/TracingCoreHostBuilderExtensionsTest.cs b/src/Management/test/TracingCore.Test/TracingCoreHostBuilderExtensionsTest.cs index 45dab3226b..a80d9a749e 100644 --- a/src/Management/test/TracingCore.Test/TracingCoreHostBuilderExtensionsTest.cs +++ b/src/Management/test/TracingCore.Test/TracingCoreHostBuilderExtensionsTest.cs @@ -1,17 +1,9 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Options; -using OpenTelemetry.Exporter; -using OpenTelemetry.Trace; -using Steeltoe.Extensions.Logging; -using Steeltoe.Management.OpenTelemetry.Exporters.Wavefront; -using Steeltoe.Management.OpenTelemetry.Trace; -using System; -using System.Collections.Generic; using Xunit; namespace Steeltoe.Management.Tracing.Test; @@ -21,15 +13,12 @@ public class TracingCoreHostBuilderExtensionsTest : TestBase [Fact] public void AddDistributedTracingAspNetCore_ConfiguresExpectedDefaults() { -#if !NET6_0_OR_GREATER - AppContext.SetSwitch( - "System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); -#endif - var services = new ServiceCollection().AddSingleton(GetConfiguration()); + using var host = new HostBuilder() + .ConfigureServices(svc => svc.AddSingleton(GetConfiguration())) + .AddDistributedTracingAspNetCore() + .Build(); - var serviceProvider = services.AddDistributedTracingAspNetCore().BuildServiceProvider(); - - ValidateServiceCollectionCommon(serviceProvider); - ValidateServiceContainerCore(serviceProvider); + ValidateServiceCollectionCommon(host.Services); + ValidateServiceContainerCore(host.Services); } } \ No newline at end of file diff --git a/src/Management/test/TracingCore.Test/TracingCoreServiceCollectionExtensionsTest.cs b/src/Management/test/TracingCore.Test/TracingCoreServiceCollectionExtensionsTest.cs index 32cd85721a..cea29a32bc 100644 --- a/src/Management/test/TracingCore.Test/TracingCoreServiceCollectionExtensionsTest.cs +++ b/src/Management/test/TracingCore.Test/TracingCoreServiceCollectionExtensionsTest.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. @@ -7,9 +7,6 @@ using Microsoft.Extensions.Options; using OpenTelemetry.Exporter; using OpenTelemetry.Trace; -using Steeltoe.Extensions.Logging; -using Steeltoe.Management.OpenTelemetry.Exporters.Wavefront; -using Steeltoe.Management.OpenTelemetry.Trace; using System; using System.Collections.Generic; using Xunit; @@ -28,10 +25,6 @@ public void AddDistributedTracingAspNetCore_ThrowsOnNulls() [Fact] public void AddDistributedTracingAspNetCore_ConfiguresExpectedDefaults() { -#if !NET6_0_OR_GREATER - AppContext.SetSwitch( - "System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); -#endif var services = new ServiceCollection().AddSingleton(GetConfiguration()); var serviceProvider = services.AddDistributedTracingAspNetCore().BuildServiceProvider(); @@ -44,13 +37,9 @@ public void AddDistributedTracingAspNetCore_ConfiguresExpectedDefaults() [Fact] public void AddDistributedTracingAspNetCore_WiresIncludedExporters() { -#if !NET6_0_OR_GREATER - AppContext.SetSwitch( - "System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); -#endif var services = new ServiceCollection().AddSingleton(GetConfiguration()); - var serviceProvider = services.AddDistributedTracing(null).BuildServiceProvider(); + var serviceProvider = services.AddDistributedTracing().BuildServiceProvider(); var hst = serviceProvider.GetService(); Assert.NotNull(hst); var tracerProvider = serviceProvider.GetService(); @@ -62,10 +51,6 @@ public void AddDistributedTracingAspNetCore_WiresIncludedExporters() [Fact] public void AddDistributedTracingAspNetCore_WiresWavefrontExporters() { -#if !NET6_0_OR_GREATER - AppContext.SetSwitch( - "System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); -#endif var services = new ServiceCollection() .AddSingleton(GetConfiguration(new Dictionary() { @@ -73,7 +58,7 @@ public void AddDistributedTracingAspNetCore_WiresWavefrontExporters() { "management:metrics:export:wavefront:apiToken", "fakeSecret" } })); - var serviceProvider = services.AddDistributedTracing(null).BuildServiceProvider(); + var serviceProvider = services.AddDistributedTracing().BuildServiceProvider(); var tracerProvider = serviceProvider.GetService(); Assert.NotNull(tracerProvider); diff --git a/src/Messaging/src/Abstractions/Steeltoe.Messaging.Abstractions.csproj b/src/Messaging/src/Abstractions/Steeltoe.Messaging.Abstractions.csproj index 846fd6196c..b945bd9793 100644 --- a/src/Messaging/src/Abstractions/Steeltoe.Messaging.Abstractions.csproj +++ b/src/Messaging/src/Abstractions/Steeltoe.Messaging.Abstractions.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Messaging Abstractions for use with Steeltoe Messaging diff --git a/src/Messaging/src/MessagingBase/Steeltoe.Messaging.MessagingBase.csproj b/src/Messaging/src/MessagingBase/Steeltoe.Messaging.MessagingBase.csproj index 072730f4ab..ea06d27d61 100644 --- a/src/Messaging/src/MessagingBase/Steeltoe.Messaging.MessagingBase.csproj +++ b/src/Messaging/src/MessagingBase/Steeltoe.Messaging.MessagingBase.csproj @@ -2,7 +2,7 @@ Steeltoe Messaging Base - net6.0 + net8.0 Steeltoe.Messaging Steeltoe.Messaging.MessagingBase Steeltoe.Messaging.MessagingBase diff --git a/src/Messaging/src/RabbitMQ/Steeltoe.Messaging.RabbitMQ.csproj b/src/Messaging/src/RabbitMQ/Steeltoe.Messaging.RabbitMQ.csproj index b92a082ac3..a577bf7004 100644 --- a/src/Messaging/src/RabbitMQ/Steeltoe.Messaging.RabbitMQ.csproj +++ b/src/Messaging/src/RabbitMQ/Steeltoe.Messaging.RabbitMQ.csproj @@ -2,7 +2,7 @@ Steeltoe Messaging RabbitMQ - net6.0 + net8.0 Steeltoe.Messaging.RabbitMQ Steeltoe.Messaging.RabbitMQ Steeltoe.Messaging.RabbitMQ diff --git a/src/Messaging/test/Benchmarks/Channel/ChannelBenchmark.csproj b/src/Messaging/test/Benchmarks/Channel/ChannelBenchmark.csproj index e11b39043e..0315cc3a06 100644 --- a/src/Messaging/test/Benchmarks/Channel/ChannelBenchmark.csproj +++ b/src/Messaging/test/Benchmarks/Channel/ChannelBenchmark.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 false diff --git a/src/Messaging/test/MessagingBase.Test/Steeltoe.Messaging.MessagingBase.Test.csproj b/src/Messaging/test/MessagingBase.Test/Steeltoe.Messaging.MessagingBase.Test.csproj index 7d1c153aba..73760b139f 100644 --- a/src/Messaging/test/MessagingBase.Test/Steeltoe.Messaging.MessagingBase.Test.csproj +++ b/src/Messaging/test/MessagingBase.Test/Steeltoe.Messaging.MessagingBase.Test.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 Steeltoe.Messaging diff --git a/src/Messaging/test/RabbitMQ.Test/Steeltoe.Messaging.RabbitMQ.Test.csproj b/src/Messaging/test/RabbitMQ.Test/Steeltoe.Messaging.RabbitMQ.Test.csproj index 0fa8ee8970..db4b02b5fb 100644 --- a/src/Messaging/test/RabbitMQ.Test/Steeltoe.Messaging.RabbitMQ.Test.csproj +++ b/src/Messaging/test/RabbitMQ.Test/Steeltoe.Messaging.RabbitMQ.Test.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 Steeltoe.Messaging.RabbitMQ diff --git a/src/Security/src/Authentication.CloudFoundryBase/Steeltoe.Security.Authentication.CloudFoundryBase.csproj b/src/Security/src/Authentication.CloudFoundryBase/Steeltoe.Security.Authentication.CloudFoundryBase.csproj index 4820aa6d2c..7a61d29080 100644 --- a/src/Security/src/Authentication.CloudFoundryBase/Steeltoe.Security.Authentication.CloudFoundryBase.csproj +++ b/src/Security/src/Authentication.CloudFoundryBase/Steeltoe.Security.Authentication.CloudFoundryBase.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Security.Authentication.CloudFoundry Base Security Provider for CloudFoundry CloudFoundry;security;oauth2;sso;openid diff --git a/src/Security/src/Authentication.CloudFoundryCore/Steeltoe.Security.Authentication.CloudFoundryCore.csproj b/src/Security/src/Authentication.CloudFoundryCore/Steeltoe.Security.Authentication.CloudFoundryCore.csproj index 3649def035..0e44bd3265 100644 --- a/src/Security/src/Authentication.CloudFoundryCore/Steeltoe.Security.Authentication.CloudFoundryCore.csproj +++ b/src/Security/src/Authentication.CloudFoundryCore/Steeltoe.Security.Authentication.CloudFoundryCore.csproj @@ -1,6 +1,6 @@  - net8.0;net6.0 + net8.0 Steeltoe.Security.Authentication.CloudFoundry ASP.NET Core External Security Provider for CloudFoundry CloudFoundry;ASPNET Core;Security;OAuth2;SSO;OpenIDConnect diff --git a/src/Security/src/Authentication.MtlsCore/Steeltoe.Security.Authentication.MtlsCore.csproj b/src/Security/src/Authentication.MtlsCore/Steeltoe.Security.Authentication.MtlsCore.csproj index af67f4a807..9a6e27eb7b 100644 --- a/src/Security/src/Authentication.MtlsCore/Steeltoe.Security.Authentication.MtlsCore.csproj +++ b/src/Security/src/Authentication.MtlsCore/Steeltoe.Security.Authentication.MtlsCore.csproj @@ -1,6 +1,6 @@  - net8.0;net6.0 + net8.0 Steeltoe.Security.Authentication.Mtls ASP.NET Core middleware that enables an application to support certificate authentication. aspnetcore;authentication;security;x509;certificate;mtls diff --git a/src/Security/src/DataProtection.CredHubBase/Steeltoe.Security.DataProtection.CredHubBase.csproj b/src/Security/src/DataProtection.CredHubBase/Steeltoe.Security.DataProtection.CredHubBase.csproj index ba4927a232..18582df4f5 100644 --- a/src/Security/src/DataProtection.CredHubBase/Steeltoe.Security.DataProtection.CredHubBase.csproj +++ b/src/Security/src/DataProtection.CredHubBase/Steeltoe.Security.DataProtection.CredHubBase.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Security.DataProtection.CredHub .NET Client for CredHub - Base Package CloudFoundry;NET Core;Security;DataProtection;CredHub diff --git a/src/Security/src/DataProtection.CredHubCore/Steeltoe.Security.DataProtection.CredHubCore.csproj b/src/Security/src/DataProtection.CredHubCore/Steeltoe.Security.DataProtection.CredHubCore.csproj index f5622c3d15..10922479e6 100644 --- a/src/Security/src/DataProtection.CredHubCore/Steeltoe.Security.DataProtection.CredHubCore.csproj +++ b/src/Security/src/DataProtection.CredHubCore/Steeltoe.Security.DataProtection.CredHubCore.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.Security.DataProtection.CredHub ASP.NET Core Extensions for CredHub Client CloudFoundry;aspnetcore;Security;DataProtection;CredHub diff --git a/src/Security/src/DataProtection.RedisCore/Steeltoe.Security.DataProtection.RedisCore.csproj b/src/Security/src/DataProtection.RedisCore/Steeltoe.Security.DataProtection.RedisCore.csproj index 092bbf4ec9..3ae130f101 100644 --- a/src/Security/src/DataProtection.RedisCore/Steeltoe.Security.DataProtection.RedisCore.csproj +++ b/src/Security/src/DataProtection.RedisCore/Steeltoe.Security.DataProtection.RedisCore.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + net8.0;netstandard2.0 Steeltoe.Security.DataProtection.Redis Support for storing data protection keys in Redis. CloudFoundry;aspnetcore;security;dataprotection;redis @@ -13,5 +13,6 @@ + \ No newline at end of file diff --git a/src/Security/test/Authentication.CloudFoundryBase.Test/Steeltoe.Security.Authentication.CloudFoundryBase.Test.csproj b/src/Security/test/Authentication.CloudFoundryBase.Test/Steeltoe.Security.Authentication.CloudFoundryBase.Test.csproj index af6ceebe29..6c3dc3f965 100644 --- a/src/Security/test/Authentication.CloudFoundryBase.Test/Steeltoe.Security.Authentication.CloudFoundryBase.Test.csproj +++ b/src/Security/test/Authentication.CloudFoundryBase.Test/Steeltoe.Security.Authentication.CloudFoundryBase.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Security/test/Authentication.CloudFoundryCore.Test/Steeltoe.Security.Authentication.CloudFoundryCore.Test.csproj b/src/Security/test/Authentication.CloudFoundryCore.Test/Steeltoe.Security.Authentication.CloudFoundryCore.Test.csproj index 159a692073..07ac93d7cb 100644 --- a/src/Security/test/Authentication.CloudFoundryCore.Test/Steeltoe.Security.Authentication.CloudFoundryCore.Test.csproj +++ b/src/Security/test/Authentication.CloudFoundryCore.Test/Steeltoe.Security.Authentication.CloudFoundryCore.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 Steeltoe.Security.Authentication.CloudFoundry.Test diff --git a/src/Security/test/Authentication.MtlsCore.Test/Steeltoe.Security.Authentication.MtlsCore.Test.csproj b/src/Security/test/Authentication.MtlsCore.Test/Steeltoe.Security.Authentication.MtlsCore.Test.csproj index 0003409f7c..5d65f70ded 100644 --- a/src/Security/test/Authentication.MtlsCore.Test/Steeltoe.Security.Authentication.MtlsCore.Test.csproj +++ b/src/Security/test/Authentication.MtlsCore.Test/Steeltoe.Security.Authentication.MtlsCore.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Security/test/DataProtection.CredHubBase.Test/Steeltoe.Security.DataProtection.CredHubBase.Test.csproj b/src/Security/test/DataProtection.CredHubBase.Test/Steeltoe.Security.DataProtection.CredHubBase.Test.csproj index 6b2ea80d79..946a1d8a78 100644 --- a/src/Security/test/DataProtection.CredHubBase.Test/Steeltoe.Security.DataProtection.CredHubBase.Test.csproj +++ b/src/Security/test/DataProtection.CredHubBase.Test/Steeltoe.Security.DataProtection.CredHubBase.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Security/test/DataProtection.CredHubCore.Test/Steeltoe.Security.DataProtection.CredHubCore.Test.csproj b/src/Security/test/DataProtection.CredHubCore.Test/Steeltoe.Security.DataProtection.CredHubCore.Test.csproj index e00add32c3..de3c636844 100644 --- a/src/Security/test/DataProtection.CredHubCore.Test/Steeltoe.Security.DataProtection.CredHubCore.Test.csproj +++ b/src/Security/test/DataProtection.CredHubCore.Test/Steeltoe.Security.DataProtection.CredHubCore.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Security/test/DataProtection.RedisCore.Test/Steeltoe.Security.DataProtection.RedisCore.Test.csproj b/src/Security/test/DataProtection.RedisCore.Test/Steeltoe.Security.DataProtection.RedisCore.Test.csproj index a3c88c38fa..9469523ab2 100644 --- a/src/Security/test/DataProtection.RedisCore.Test/Steeltoe.Security.DataProtection.RedisCore.Test.csproj +++ b/src/Security/test/DataProtection.RedisCore.Test/Steeltoe.Security.DataProtection.RedisCore.Test.csproj @@ -1,6 +1,6 @@ - net8.0;net6.0 + net8.0 diff --git a/src/Stream/src/Abstractions/Steeltoe.Stream.Abstractions.csproj b/src/Stream/src/Abstractions/Steeltoe.Stream.Abstractions.csproj index d047548e80..831390a015 100644 --- a/src/Stream/src/Abstractions/Steeltoe.Stream.Abstractions.csproj +++ b/src/Stream/src/Abstractions/Steeltoe.Stream.Abstractions.csproj @@ -1,6 +1,6 @@ - net6.0 + net8.0 Steeltoe.Stream Abstractions for use with Steeltoe Stream diff --git a/src/Stream/src/BinderRabbitMQ/Steeltoe.Stream.Binder.RabbitMQ.csproj b/src/Stream/src/BinderRabbitMQ/Steeltoe.Stream.Binder.RabbitMQ.csproj index 7a02a29bd7..f3c6f37ceb 100644 --- a/src/Stream/src/BinderRabbitMQ/Steeltoe.Stream.Binder.RabbitMQ.csproj +++ b/src/Stream/src/BinderRabbitMQ/Steeltoe.Stream.Binder.RabbitMQ.csproj @@ -2,7 +2,7 @@ Steeltoe Stream RabbitMQ Binder - net6.0 + net8.0 Steeltoe.Stream.Binder.RabbitMQ Streams, ASPNET Core, Spring, Spring Cloud, RabbitMQ, Binder diff --git a/src/Stream/src/StreamBase/Steeltoe.Stream.StreamBase.csproj b/src/Stream/src/StreamBase/Steeltoe.Stream.StreamBase.csproj index 6a9cce9253..0c5b6d48a3 100644 --- a/src/Stream/src/StreamBase/Steeltoe.Stream.StreamBase.csproj +++ b/src/Stream/src/StreamBase/Steeltoe.Stream.StreamBase.csproj @@ -1,6 +1,6 @@ - net6.0 + net8.0 Steeltoe.Stream Steeltoe Stream Base Streams, NET Core, Spring, Spring Cloud diff --git a/src/Stream/test/BinderRabbitMQ.Test/Steeltoe.Stream.Binder.RabbitMQ.Test.csproj b/src/Stream/test/BinderRabbitMQ.Test/Steeltoe.Stream.Binder.RabbitMQ.Test.csproj index a61729e818..9c2a557005 100644 --- a/src/Stream/test/BinderRabbitMQ.Test/Steeltoe.Stream.Binder.RabbitMQ.Test.csproj +++ b/src/Stream/test/BinderRabbitMQ.Test/Steeltoe.Stream.Binder.RabbitMQ.Test.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 Steeltoe.Stream.Binder.Rabbit Exe diff --git a/src/Stream/test/BinderTests/Steeltoe.Stream.BinderTests.csproj b/src/Stream/test/BinderTests/Steeltoe.Stream.BinderTests.csproj index 24a80ba954..a36c3547b9 100644 --- a/src/Stream/test/BinderTests/Steeltoe.Stream.BinderTests.csproj +++ b/src/Stream/test/BinderTests/Steeltoe.Stream.BinderTests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 Steeltoe.Stream.Binder diff --git a/src/Stream/test/MockBinder/Steeltoe.Stream.MockBinder.csproj b/src/Stream/test/MockBinder/Steeltoe.Stream.MockBinder.csproj index 1538383b77..1117a05779 100644 --- a/src/Stream/test/MockBinder/Steeltoe.Stream.MockBinder.csproj +++ b/src/Stream/test/MockBinder/Steeltoe.Stream.MockBinder.csproj @@ -1,6 +1,6 @@ - net6.0 + net8.0 False diff --git a/src/Stream/test/StreamBase.Test/Steeltoe.Stream.StreamBase.Test.csproj b/src/Stream/test/StreamBase.Test/Steeltoe.Stream.StreamBase.Test.csproj index 1f52194309..970b446c9b 100644 --- a/src/Stream/test/StreamBase.Test/Steeltoe.Stream.StreamBase.Test.csproj +++ b/src/Stream/test/StreamBase.Test/Steeltoe.Stream.StreamBase.Test.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 Steeltoe.Stream diff --git a/src/Stream/test/StubBinder1/Steeltoe.Stream.StubBinder1.csproj b/src/Stream/test/StubBinder1/Steeltoe.Stream.StubBinder1.csproj index 9455923be2..5817a2b99a 100644 --- a/src/Stream/test/StubBinder1/Steeltoe.Stream.StubBinder1.csproj +++ b/src/Stream/test/StubBinder1/Steeltoe.Stream.StubBinder1.csproj @@ -1,6 +1,6 @@ - net6.0 + net8.0 False diff --git a/src/Stream/test/StubBinder2/Steeltoe.Stream.StubBinder2.csproj b/src/Stream/test/StubBinder2/Steeltoe.Stream.StubBinder2.csproj index 9455923be2..5817a2b99a 100644 --- a/src/Stream/test/StubBinder2/Steeltoe.Stream.StubBinder2.csproj +++ b/src/Stream/test/StubBinder2/Steeltoe.Stream.StubBinder2.csproj @@ -1,6 +1,6 @@ - net6.0 + net8.0 False diff --git a/src/Stream/test/TestBinder/Steeltoe.Stream.TestBinder.csproj b/src/Stream/test/TestBinder/Steeltoe.Stream.TestBinder.csproj index 9455923be2..5817a2b99a 100644 --- a/src/Stream/test/TestBinder/Steeltoe.Stream.TestBinder.csproj +++ b/src/Stream/test/TestBinder/Steeltoe.Stream.TestBinder.csproj @@ -1,6 +1,6 @@ - net6.0 + net8.0 False diff --git a/versions.props b/versions.props index 4d1a01ee4f..88102c902f 100644 --- a/versions.props +++ b/versions.props @@ -12,17 +12,18 @@ 7.7.1 1.2.0 1.4.0 - 8.0.0 - 8.0.5 - 3.2.1 - 4.6.0 + 8.0.0 + + + 8.0.5 + 1.8.4 1.6.10.3 2.0.0 - 3.1.0 - 2.2.5 13.0.1 - 1.8.1 + 1.15.3 + 1.15.1 + 1.15.2 1.8.0-beta 5.1.2 6.0.0 @@ -32,15 +33,23 @@ 4.4.0 4.3.0 8.0.0 - 8.0.1 - 3.1.0 - 3.1.0 + + + 8.0.1 + 4.7.0 0.2.236902 2.0.64 3.1.1 3.0.1 - 8.0.1 + + + 8.0.1 + + + + 8.0.3 + 4.3.1 4.3.4 @@ -64,7 +73,7 @@ 6.0.0 4.13.1 4.2.0 - 17.0.0 + 18.3.0 2.4.1 2.0.3 2.4.3 @@ -85,39 +94,12 @@ 1.1.118 - - - 2.0.16 - - - - - 5.0.13 - - - - - 6.0.0 - 6.0.0 - 6.0.0 - - - 6.0.0 - 6.0.0 - 6.0.11 - 6.0.0 - 3.21.90 - 6.21.5 - 6.0.0 - 6.0.0 - - + 19.0.2 8.0.0 8.0.0 - 8.0.0 - + 8.0.0 8.0.0