Skip to content

Commit

Permalink
Port HTTPlease.Testability.Xunit and fix remaining compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tintoy committed Dec 24, 2024
1 parent 7f6a846 commit ea22621
Show file tree
Hide file tree
Showing 41 changed files with 1,903 additions and 126 deletions.
6 changes: 3 additions & 3 deletions samples/ConfigFromConfigMap/ConfigFromConfigMap.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\KubeClient\KubeClient.csproj" />
<ProjectReference Include="..\..\src\KubeClient.Extensions.Configuration\KubeClient.Extensions.Configuration.csproj" />
<ProjectReference Include="..\..\src\KubeClient.Extensions.KubeConfig\KubeClient.Extensions.KubeConfig.csproj" />
<ProjectReference Include="../../src/KubeClient/KubeClient.csproj" />
<ProjectReference Include="../../src/KubeClient.Extensions.Configuration/KubeClient.Extensions.Configuration.csproj" />
<ProjectReference Include="../../src/KubeClient.Extensions.KubeConfig/KubeClient.Extensions.KubeConfig.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions samples/ConfigFromConfigMap/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using HTTPlease;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
Expand All @@ -11,6 +10,7 @@
namespace KubeClient.Samples.ConfigFromConfigMap
{
using Extensions.Configuration;
using Http;
using Models;

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions samples/DeploymentWithRollback/DeploymentWithRollback.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\KubeClient\KubeClient.csproj" />
<ProjectReference Include="..\..\src\KubeClient.Extensions.KubeConfig\KubeClient.Extensions.KubeConfig.csproj" />
<ProjectReference Include="../../src/KubeClient/KubeClient.csproj" />
<ProjectReference Include="../../src/KubeClient.Extensions.KubeConfig/KubeClient.Extensions.KubeConfig.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/DeploymentWithRollback/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
using HTTPlease;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
Expand All @@ -9,6 +8,7 @@

namespace KubeClient.Samples.DeploymentWithRollback
{
using Http;
using Models;

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions samples/ExtensionsSample/ExtensionsSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\KubeClient.Extensions.Configuration\KubeClient.Extensions.Configuration.csproj" />
<ProjectReference Include="..\..\src\KubeClient\KubeClient.csproj" />
<ProjectReference Include="../../src/KubeClient.Extensions.Configuration/KubeClient.Extensions.Configuration.csproj" />
<ProjectReference Include="../../src/KubeClient/KubeClient.csproj" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions samples/WatchEvents/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using HTTPlease;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
Expand All @@ -10,6 +9,7 @@

namespace KubeClient.Samples.WatchEvents
{
using Http;
using Models;
using ResourceClients;

Expand Down
4 changes: 2 additions & 2 deletions samples/WatchEvents/WatchEvents.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\KubeClient\KubeClient.csproj" />
<ProjectReference Include="..\..\src\KubeClient.Extensions.KubeConfig\KubeClient.Extensions.KubeConfig.csproj" />
<ProjectReference Include="../../src/KubeClient/KubeClient.csproj" />
<ProjectReference Include="../../src/KubeClient.Extensions.KubeConfig/KubeClient.Extensions.KubeConfig.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions samples/noob-exec/NoobExec.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\KubeClient\KubeClient.csproj" />
<ProjectReference Include="..\..\src\KubeClient.Extensions.KubeConfig\KubeClient.Extensions.KubeConfig.csproj" />
<ProjectReference Include="..\..\src\KubeClient.Extensions.WebSockets\KubeClient.Extensions.WebSockets.csproj" />
<ProjectReference Include="../../src/KubeClient/KubeClient.csproj" />
<ProjectReference Include="../../src/KubeClient.Extensions.KubeConfig/KubeClient.Extensions.KubeConfig.csproj" />
<ProjectReference Include="../../src/KubeClient.Extensions.WebSockets/KubeClient.Extensions.WebSockets.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\KubeClient\KubeClient.csproj" />
<ProjectReference Include="../KubeClient/KubeClient.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
Expand All @@ -29,5 +29,5 @@
<PackageReference Include="System.Reactive" Version="6.0.1" />
</ItemGroup>

<Import Project="..\Common.props" />
<Import Project="../Common.props" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\KubeClient.Extensions.CustomResources.Schema\KubeClient.Extensions.CustomResources.Schema.csproj" />
<ProjectReference Include="..\KubeClient\KubeClient.csproj" />
<ProjectReference Include="..\KubeClient.Extensions.CustomResources\KubeClient.Extensions.CustomResources.csproj" />
<ProjectReference Include="../KubeClient.Extensions.CustomResources.Schema/KubeClient.Extensions.CustomResources.Schema.csproj" />
<ProjectReference Include="../KubeClient/KubeClient.csproj" />
<ProjectReference Include="../KubeClient.Extensions.CustomResources/KubeClient.Extensions.CustomResources.csproj" />
</ItemGroup>

<ItemGroup>
Expand All @@ -21,5 +21,5 @@
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>

<Import Project="..\Common.props" />
<Import Project="../Common.props" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\KubeClient.Extensions.CustomResources\KubeClient.Extensions.CustomResources.csproj" />
<ProjectReference Include="..\KubeClient\KubeClient.csproj" />
<ProjectReference Include="../KubeClient.Extensions.CustomResources/KubeClient.Extensions.CustomResources.csproj" />
<ProjectReference Include="../KubeClient/KubeClient.csproj" />
</ItemGroup>

<Import Project="..\Common.props" />
<Import Project="../Common.props" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
using HTTPlease;
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Threading;
using System.Net;
using System.Threading.Tasks;

namespace KubeClient.ResourceClients
{
using Http;
using Models;

/// <summary>
Expand Down Expand Up @@ -43,7 +40,7 @@ public async Task<CustomResourceDefinitionV1> Get(string name, CancellationToken
{
if (String.IsNullOrWhiteSpace(name))
throw new ArgumentException("Argument cannot be null, empty, or entirely composed of whitespace: 'name'.", nameof(name));

return await GetSingleResource<CustomResourceDefinitionV1>(
Requests.ByName.WithTemplateParameters(new
{
Expand Down Expand Up @@ -147,7 +144,7 @@ public async Task<CustomResourceDefinitionV1> Create(CustomResourceDefinitionV1
{
if (newCustomResourceDefinition == null)
throw new ArgumentNullException(nameof(newCustomResourceDefinition));

return await Http
.PostAsJsonAsync(Requests.Collection,
postBody: newCustomResourceDefinition,
Expand Down Expand Up @@ -184,22 +181,22 @@ static class Requests
/// <summary>
/// A collection-level CustomResourceDefinition (v1) request.
/// </summary>
public static readonly HttpRequest Collection = KubeRequest.Create("apis/apiextensions.k8s.io/v1/customresourcedefinitions?labelSelector={LabelSelector?}&limit={Limit?}&continue={Continue?}");
public static readonly HttpRequest Collection = KubeRequest.Create("apis/apiextensions.k8s.io/v1/customresourcedefinitions?labelSelector={LabelSelector?}&limit={Limit?}&continue={Continue?}");

/// <summary>
/// A get-by-name CustomResourceDefinition (v1) request.
/// </summary>
public static readonly HttpRequest ByName = KubeRequest.Create("apis/apiextensions.k8s.io/v1/customresourcedefinitions/{Name}");
public static readonly HttpRequest ByName = KubeRequest.Create("apis/apiextensions.k8s.io/v1/customresourcedefinitions/{Name}");

/// <summary>
/// A collection-level CustomResourceDefinition watch (v1) request.
/// </summary>
public static readonly HttpRequest WatchCollection = KubeRequest.Create("/apis/apiextensions.k8s.io/v1/watch/customresourcedefinitions?labelSelector={LabelSelector?}");
public static readonly HttpRequest WatchCollection = KubeRequest.Create("/apis/apiextensions.k8s.io/v1/watch/customresourcedefinitions?labelSelector={LabelSelector?}");

/// <summary>
/// A watch-by-name CustomResourceDefinition (v1) request.
/// </summary>
public static readonly HttpRequest WatchByName = KubeRequest.Create("/apis/apiextensions.k8s.io/v1/watch/customresourcedefinitions/{Name}");
public static readonly HttpRequest WatchByName = KubeRequest.Create("/apis/apiextensions.k8s.io/v1/watch/customresourcedefinitions/{Name}");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
using HTTPlease;
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Threading;
using System.Net;
using System.Threading.Tasks;

namespace KubeClient.ResourceClients
{
using Http;
using Models;

/// <summary>
Expand Down Expand Up @@ -43,7 +40,7 @@ public async Task<CustomResourceDefinitionV1Beta1> Get(string name, Cancellation
{
if (String.IsNullOrWhiteSpace(name))
throw new ArgumentException("Argument cannot be null, empty, or entirely composed of whitespace: 'name'.", nameof(name));

return await GetSingleResource<CustomResourceDefinitionV1Beta1>(
Requests.ByName.WithTemplateParameters(new
{
Expand Down Expand Up @@ -135,7 +132,7 @@ public async Task<CustomResourceDefinitionV1Beta1> Create(CustomResourceDefiniti
{
if (newCustomResourceDefinition == null)
throw new ArgumentNullException(nameof(newCustomResourceDefinition));

return await Http
.PostAsJsonAsync(Requests.Collection,
postBody: newCustomResourceDefinition,
Expand Down Expand Up @@ -172,22 +169,22 @@ static class Requests
/// <summary>
/// A collection-level CustomResourceDefinition (v1) request.
/// </summary>
public static readonly HttpRequest Collection = KubeRequest.Create("apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions?labelSelector={LabelSelector?}");
public static readonly HttpRequest Collection = KubeRequest.Create("apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions?labelSelector={LabelSelector?}");

/// <summary>
/// A get-by-name CustomResourceDefinition (v1) request.
/// </summary>
public static readonly HttpRequest ByName = KubeRequest.Create("apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/{Name}");
public static readonly HttpRequest ByName = KubeRequest.Create("apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/{Name}");

/// <summary>
/// A collection-level CustomResourceDefinition watch (v1) request.
/// </summary>
public static readonly HttpRequest WatchCollection = KubeRequest.Create("/apis/apiextensions.k8s.io/v1beta1/watch/customresourcedefinitions?labelSelector={LabelSelector?}");
public static readonly HttpRequest WatchCollection = KubeRequest.Create("/apis/apiextensions.k8s.io/v1beta1/watch/customresourcedefinitions?labelSelector={LabelSelector?}");

/// <summary>
/// A watch-by-name CustomResourceDefinition (v1) request.
/// </summary>
public static readonly HttpRequest WatchByName = KubeRequest.Create("/apis/apiextensions.k8s.io/v1beta1/watch/customresourcedefinitions/{Name}");
public static readonly HttpRequest WatchByName = KubeRequest.Create("/apis/apiextensions.k8s.io/v1beta1/watch/customresourcedefinitions/{Name}");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\KubeClient\KubeClient.csproj" />
<ProjectReference Include="../KubeClient/KubeClient.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>

<Import Project="..\Common.props" />
<Import Project="../Common.props" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\KubeClient\KubeClient.csproj" />
<ProjectReference Include="..\KubeClient.Extensions.Configuration\KubeClient.Extensions.Configuration.csproj" />
<ProjectReference Include="../KubeClient/KubeClient.csproj" />
<ProjectReference Include="../KubeClient.Extensions.Configuration/KubeClient.Extensions.Configuration.csproj" />
</ItemGroup>

<ItemGroup>
Expand All @@ -32,5 +32,5 @@
<PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="9.0.0" />
</ItemGroup>

<Import Project="..\Common.props" />
<Import Project="../Common.props" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\KubeClient\KubeClient.csproj" />
<ProjectReference Include="..\KubeClient.Extensions.KubeConfig\KubeClient.Extensions.KubeConfig.csproj" />
<ProjectReference Include="../KubeClient/KubeClient.csproj" />
<ProjectReference Include="../KubeClient.Extensions.KubeConfig/KubeClient.Extensions.KubeConfig.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
Expand All @@ -37,6 +37,6 @@
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.0" />
</ItemGroup>

<Import Project="..\Common.props" />
<Import Project="../Common.props" />

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\KubeClient\KubeClient.csproj" />
<ProjectReference Include="../KubeClient/KubeClient.csproj" />
</ItemGroup>

<ItemGroup>
Expand All @@ -17,6 +17,6 @@
<PackageReference Include="YamlDotNet" Version="16.1.3" />
</ItemGroup>

<Import Project="..\Common.props" />
<Import Project="../Common.props" />

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\KubeClient\KubeClient.csproj" />
<ProjectReference Include="../KubeClient/KubeClient.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Nito.AsyncEx.Coordination" Version="5.1.2" />
</ItemGroup>

<Import Project="..\Common.props" />
<Import Project="../Common.props" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using HTTPlease;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
Expand All @@ -10,6 +9,7 @@
namespace KubeClient
{
using Extensions.WebSockets;
using Http;

/// <summary>
/// WebSockets extension methods for <see cref="KubeClient"/>.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using HTTPlease;
using System;
using System.Net.WebSockets;
using System.Threading;
using System.Threading.Tasks;

namespace KubeClient
{
using ResourceClients;
using Extensions.WebSockets;
using System.Net.WebSockets;
using ResourceClients;

/// <summary>
/// WebSocket-related extension methods for Kubernetes resource clients.
Expand Down
6 changes: 6 additions & 0 deletions src/KubeClient/Http/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# KubeClient.Http

## Introduction

`KubeClient.Http` is a port of [HTTPlease](https://github.com/tintoy/HTTPlease), the HTTP client library that dotnet-kube-client was originally built on top of.
A subset of HTTPlease functionality has now been folded into dotnet-kube-client so that consumers no longer need to reference HTTPlease or its dependencies.
Loading

0 comments on commit ea22621

Please sign in to comment.