-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored k8s endpoints PR +semver: major
- Loading branch information
Showing
7 changed files
with
105 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/Ocelot.Provider.Kubernetes/KubeApiClientExtensions/EndPointClientV1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using HTTPlease; | ||
using KubeClient; | ||
using KubeClient.Models; | ||
using KubeClient.ResourceClients; | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Ocelot.Provider.Kubernetes.KubeApiClientExtensions | ||
{ | ||
public class EndPointClientV1 : KubeResourceClient | ||
{ | ||
private readonly HttpRequest _collection = KubeRequest.Create("api/v1/namespaces/{Namespace}/endpoints/{ServiceName}"); | ||
|
||
public EndPointClientV1(IKubeApiClient client) : base(client) | ||
{ | ||
} | ||
|
||
public async Task<EndpointsV1> Get(string serviceName, string kubeNamespace = null, CancellationToken cancellationToken = default) | ||
{ | ||
if (string.IsNullOrEmpty(serviceName)) throw new ArgumentNullException(nameof(serviceName)); | ||
|
||
var response = await Http.GetAsync( | ||
_collection.WithTemplateParameters(new | ||
{ | ||
Namespace = kubeNamespace ?? KubeClient.DefaultNamespace, | ||
ServiceName = serviceName | ||
}), | ||
cancellationToken | ||
); | ||
|
||
if (response.IsSuccessStatusCode) | ||
return await response.ReadContentAsAsync<EndpointsV1>(); | ||
|
||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters