Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/Steeltoe.All.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
branches:
- main
- '[0-9]+.x'
- 'release/*'
pull_request:

concurrency:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
branches:
- main
- '[0-9]+.x'
- 'release/*'
pull_request:
release:
types:
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/scan-vulnerable-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Scan vulnerable dependencies

on:
workflow_dispatch:
push:
branches:
- main
- '[0-9]+.x'
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: true
SOLUTION_FILE: 'src/Steeltoe.All.sln'

jobs:
scan:
name: Scan
timeout-minutes: 15
runs-on: ubuntu-latest

steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.*
9.0.*

- name: Git checkout
uses: actions/checkout@v4

- name: Report vulnerable dependencies
run: dotnet restore ${{ env.SOLUTION_FILE }} --verbosity minimal /p:NuGetAudit=true /p:NuGetAuditMode=all /p:NuGetAuditLevel=low /p:TreatWarningsAsErrors=True
1 change: 0 additions & 1 deletion .github/workflows/sonarcube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
branches:
- main
- '[0-9]+.x'
- 'release/*'
pull_request:
types: [opened, synchronize, reopened]

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/verify-code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
branches:
- main
- '[0-9]+.x'
- 'release/*'
pull_request:

concurrency:
Expand Down
17 changes: 12 additions & 5 deletions src/Discovery/src/Consul/ConsulDiscoveryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using Consul;
using Consul.Filtering;
Comment thread
TimHess marked this conversation as resolved.
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -130,7 +131,7 @@ public async Task<IList<IServiceInstance>> GetAllInstancesAsync(QueryOptions que

if (options.Enabled)
{
ISet<string> serviceIds = await GetServiceIdsAsync(queryOptions, cancellationToken);
ISet<string> serviceIds = await GetServiceIdsAsync(null, null, queryOptions, cancellationToken);

foreach (string serviceId in serviceIds)
{
Expand All @@ -144,22 +145,28 @@ public async Task<IList<IServiceInstance>> GetAllInstancesAsync(QueryOptions que
/// <inheritdoc />
public Task<ISet<string>> GetServiceIdsAsync(CancellationToken cancellationToken)
{
return GetServiceIdsAsync(QueryOptions.Default, cancellationToken);
return GetServiceIdsAsync(null, null, QueryOptions.Default, cancellationToken);
}

/// <summary>
/// Gets all registered service IDs from the Consul catalog.
/// </summary>
/// <param name="dataCenter">
/// Specifies the datacenter to query.
/// </param>
/// <param name="filter">
/// Specifies the expression used to filter the queries results prior to returning the data.
/// </param>
/// <param name="queryOptions">
/// Any Consul query options to use.
/// Options to parameterize the Consul query.
/// </param>
/// <param name="cancellationToken">
/// The token to monitor for cancellation requests.
/// </param>
/// <returns>
/// The list of service IDs.
/// </returns>
public async Task<ISet<string>> GetServiceIdsAsync(QueryOptions queryOptions, CancellationToken cancellationToken)
public async Task<ISet<string>> GetServiceIdsAsync(string? dataCenter, Filter? filter, QueryOptions queryOptions, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(queryOptions);

Expand All @@ -170,7 +177,7 @@ public async Task<ISet<string>> GetServiceIdsAsync(QueryOptions queryOptions, Ca
return new HashSet<string>();
}

QueryResult<Dictionary<string, string[]>> result = await _client.Catalog.Services(queryOptions, cancellationToken);
QueryResult<Dictionary<string, string[]>> result = await _client.Catalog.Services(dataCenter, filter, queryOptions, cancellationToken);
return result.Response.Keys.ToHashSet();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Discovery/src/Consul/ConsulHealthContributor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal Task<string> GetLeaderStatusAsync(CancellationToken cancellationToken)

internal async Task<Dictionary<string, string[]>> GetCatalogServicesAsync(CancellationToken cancellationToken)
{
QueryResult<Dictionary<string, string[]>> result = await _client.Catalog.Services(QueryOptions.Default, cancellationToken);
QueryResult<Dictionary<string, string[]>> result = await _client.Catalog.Services(cancellationToken);
return result.Response;
}
}
2 changes: 1 addition & 1 deletion src/Discovery/src/Consul/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Steeltoe.Discovery.Consul.ConsulDiscoveryClient.GetAllInstancesAsync(Consul.Quer
Steeltoe.Discovery.Consul.ConsulDiscoveryClient.GetInstancesAsync(string! serviceId, Consul.QueryOptions! queryOptions, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<System.Collections.Generic.IList<Steeltoe.Common.Discovery.IServiceInstance!>!>!
Steeltoe.Discovery.Consul.ConsulDiscoveryClient.GetInstancesAsync(string! serviceId, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<System.Collections.Generic.IList<Steeltoe.Common.Discovery.IServiceInstance!>!>!
Steeltoe.Discovery.Consul.ConsulDiscoveryClient.GetLocalServiceInstance() -> Steeltoe.Common.Discovery.IServiceInstance?
Steeltoe.Discovery.Consul.ConsulDiscoveryClient.GetServiceIdsAsync(Consul.QueryOptions! queryOptions, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<System.Collections.Generic.ISet<string!>!>!
Steeltoe.Discovery.Consul.ConsulDiscoveryClient.GetServiceIdsAsync(string? dataCenter, Consul.Filtering.Filter? filter, Consul.QueryOptions! queryOptions, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<System.Collections.Generic.ISet<string!>!>!
Steeltoe.Discovery.Consul.ConsulDiscoveryClient.GetServiceIdsAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<System.Collections.Generic.ISet<string!>!>!
Steeltoe.Discovery.Consul.ConsulDiscoveryClient.ShutdownAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task!
Steeltoe.Discovery.Consul.ConsulServiceCollectionExtensions
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ public async Task GetServicesAsync_ReturnsExpected()
};

var catalogMoq = new Mock<ICatalogEndpoint>();
catalogMoq.Setup(endpoint => endpoint.Services(QueryOptions.Default, It.IsAny<CancellationToken>())).Returns(Task.FromResult(queryResult));
catalogMoq.Setup(endpoint => endpoint.Services(null, null, QueryOptions.Default, It.IsAny<CancellationToken>())).Returns(Task.FromResult(queryResult));

var clientMoq = new Mock<IConsulClient>();
clientMoq.Setup(client => client.Catalog).Returns(catalogMoq.Object);

TestOptionsMonitor<ConsulDiscoveryOptions> optionsMonitor = TestOptionsMonitor.Create(options);
var discoveryClient = new ConsulDiscoveryClient(clientMoq.Object, optionsMonitor, NullLoggerFactory.Instance);
ISet<string> serviceIds = await discoveryClient.GetServiceIdsAsync(QueryOptions.Default, TestContext.Current.CancellationToken);
ISet<string> serviceIds = await discoveryClient.GetServiceIdsAsync(TestContext.Current.CancellationToken);

serviceIds.Should().HaveCount(2);
serviceIds.Should().Contain("foo");
Expand Down Expand Up @@ -196,7 +196,7 @@ public async Task GetAllInstances_ReturnsExpected()
};

var catalogMoq = new Mock<ICatalogEndpoint>();
catalogMoq.Setup(endpoint => endpoint.Services(QueryOptions.Default, It.IsAny<CancellationToken>())).Returns(Task.FromResult(queryResult1));
catalogMoq.Setup(endpoint => endpoint.Services(null, null, QueryOptions.Default, It.IsAny<CancellationToken>())).Returns(Task.FromResult(queryResult1));

var clientMoq = new Mock<IConsulClient>();
clientMoq.Setup(client => client.Catalog).Returns(catalogMoq.Object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public async Task GetCatalogServicesAsync_ReturnsExpected()
};

var catalogMoq = new Mock<ICatalogEndpoint>();
catalogMoq.Setup(endpoint => endpoint.Services(QueryOptions.Default, It.IsAny<CancellationToken>())).Returns(Task.FromResult(queryResult));
catalogMoq.Setup(endpoint => endpoint.Services(It.IsAny<CancellationToken>())).Returns(Task.FromResult(queryResult));

var clientMoq = new Mock<IConsulClient>();
clientMoq.Setup(client => client.Catalog).Returns(catalogMoq.Object);
Expand Down Expand Up @@ -89,7 +89,7 @@ public async Task Health_ReturnsExpected()
statusMoq.Setup(endpoint => endpoint.Leader(It.IsAny<CancellationToken>())).Returns(Task.FromResult("the-status"));

var catalogMoq = new Mock<ICatalogEndpoint>();
catalogMoq.Setup(endpoint => endpoint.Services(QueryOptions.Default, It.IsAny<CancellationToken>())).Returns(Task.FromResult(queryResult));
catalogMoq.Setup(endpoint => endpoint.Services(It.IsAny<CancellationToken>())).Returns(Task.FromResult(queryResult));

var clientMoq = new Mock<IConsulClient>();
clientMoq.Setup(client => client.Status).Returns(statusMoq.Object);
Expand Down
Loading