Update customResource example + bump nuget packages versions (#720)

Update customResource example nuget packages + update example

Update httpClientFactory example nuget packages

Update nuget packages

Change DateTime to DateTimeOffset

Update tests nuget packages

Make KubernetesClient project reference instead of Nuget package reference

Co-authored-by: Boshi Lian <farmer1992@gmail.com>

Co-authored-by: Boshi Lian <farmer1992@gmail.com>
This commit is contained in:
Bliamoh
2021-10-14 18:02:51 +02:00
committed by GitHub
parent fb553c5c0d
commit 2d8915dff7
11 changed files with 63 additions and 53 deletions

View File

@@ -1,7 +1,7 @@
using System.Collections.Generic;
using k8s; using k8s;
using k8s.Models; using k8s.Models;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Collections.Generic;
[module: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "CA1724:TypeNamesShouldNotMatchNamespaces", Justification = "This is just an example.")] [module: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "CA1724:TypeNamesShouldNotMatchNamespaces", Justification = "This is just an example.")]
[module: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleClass", Justification = "This is just an example.")] [module: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleClass", Justification = "This is just an example.")]

View File

@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using k8s; using k8s;
using k8s.Models; using k8s.Models;
using System.Threading.Tasks;
using Microsoft.AspNetCore.JsonPatch; using Microsoft.AspNetCore.JsonPatch;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace customResource namespace customResource
@@ -12,7 +12,7 @@ namespace customResource
{ {
private static async Task Main(string[] args) private static async Task Main(string[] args)
{ {
Console.WriteLine("strating main()..."); Console.WriteLine("starting main()...");
// creating the k8s client // creating the k8s client
var k8SClientConfig = KubernetesClientConfiguration.BuildConfigFromConfigFile(); var k8SClientConfig = KubernetesClientConfiguration.BuildConfigFromConfigFile();
@@ -21,7 +21,7 @@ namespace customResource
// creating a K8s client for the CRD // creating a K8s client for the CRD
var myCRD = Utils.MakeCRD(); var myCRD = Utils.MakeCRD();
Console.WriteLine("working with CRD: {0}.{1}", myCRD.PluralName, myCRD.Group); Console.WriteLine("working with CRD: {0}.{1}", myCRD.PluralName, myCRD.Group);
var generic = new GenericClient(k8SClientConfig, myCRD.Group, myCRD.Version, myCRD.PluralName); var generic = new GenericClient(client, myCRD.Group, myCRD.Version, myCRD.PluralName);
// creating a sample custom resource content // creating a sample custom resource content
var myCr = Utils.MakeCResource(); var myCr = Utils.MakeCResource();

View File

@@ -1,6 +1,4 @@
using k8s.Models; using k8s.Models;
using System.Collections.Generic;
using k8s;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace customResource namespace customResource

View File

@@ -1,11 +1,23 @@
apiVersion: apiextensions.k8s.io/v1beta1 apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition kind: CustomResourceDefinition
metadata: metadata:
name: customresources.csharp.com name: customresources.csharp.com
spec: spec:
group: csharp.com group: csharp.com
version: v1alpha1 versions:
- name: v1alpha1
storage: true
served: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
cityName:
type: string
names: names:
kind: CResource kind: CResource
plural: customresources plural: customresources
scope: Namespaced scope: Namespaced

View File

@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="KubernetesClient" Version="3.0.16" /> <ProjectReference Include="..\..\src\KubernetesClient\KubernetesClient.csproj" />
<PackageReference Include="Microsoft.Build" Version="16.8.0" /> <PackageReference Include="Microsoft.Build" Version="16.11.0" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="5.0.1" /> <PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="5.0.10" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
@@ -6,9 +6,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,11 +1,11 @@
using IdentityModel.OidcClient;
using k8s.Exceptions;
using Microsoft.Rest;
using System; using System;
using System.IdentityModel.Tokens.Jwt;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.IdentityModel.Tokens.Jwt;
using Microsoft.Rest;
using IdentityModel.OidcClient;
using k8s.Exceptions;
namespace k8s.Authentication namespace k8s.Authentication
{ {
@@ -14,7 +14,7 @@ namespace k8s.Authentication
private OidcClient _oidcClient; private OidcClient _oidcClient;
private string _idToken; private string _idToken;
private string _refreshToken; private string _refreshToken;
private DateTime _expiry; private DateTimeOffset _expiry;
public OidcTokenProvider(string clientId, string clientSecret, string idpIssuerUrl, string idToken, string refreshToken) public OidcTokenProvider(string clientId, string clientSecret, string idpIssuerUrl, string idToken, string refreshToken)
{ {

View File

@@ -30,18 +30,18 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AutoMapper" Version="9.0.0" /> <PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="Fractions" Version="4.0.1" /> <PackageReference Include="Fractions" Version="7.0.0" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.3.37" PrivateAssets="all" /> <PackageReference Include="Nerdbank.GitVersioning" Version="3.4.240" PrivateAssets="all" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.1.3" /> <PackageReference Include="Portable.BouncyCastle" Version="1.8.10" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.23" /> <PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.23" />
<PackageReference Include="prometheus-net" Version="4.1.1" /> <PackageReference Include="prometheus-net" Version="5.0.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.11.1" /> <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.13.1" />
<PackageReference Include="System.IO.Abstractions" Version="13.2.33" /> <PackageReference Include="System.IO.Abstractions" Version="13.2.47" />
<PackageReference Include="System.Text.Encodings.Web" Version="4.5.1" /> <PackageReference Include="System.Text.Encodings.Web" Version="5.0.1" />
<PackageReference Include="YamlDotNet" Version="8.1.2" /> <PackageReference Include="YamlDotNet" Version="11.2.1" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" /> <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="IdentityModel.OidcClient" Version="3.1.2" /> <PackageReference Include="IdentityModel.OidcClient" Version="4.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -8,11 +8,11 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="5.0.0" /> <PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="5.0.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="Nito.AsyncEx.Coordination" Version="5.1.0" /> <PackageReference Include="Nito.AsyncEx.Coordination" Version="5.1.2" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>

View File

@@ -8,29 +8,29 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.1.2" /> <PackageReference Include="MartinCostello.Logging.XUnit" Version="0.2.0" />
<PackageReference Include="FluentAssertions" Version="5.10.3" /> <PackageReference Include="FluentAssertions" Version="6.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="13.2.33" /> <PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="13.2.47" />
<PackageReference Include="System.Reactive" Version="4.3.2" /> <PackageReference Include="System.Reactive" Version="5.0.0" />
<PackageReference Include="Nito.AsyncEx" Version="5.1.0" /> <PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.9.0"> <PackageReference Include="coverlet.msbuild" Version="3.1.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Xunit.StaFact" Version="1.0.37" /> <PackageReference Include="Xunit.StaFact" Version="1.0.37" />
<PackageReference Include="Moq" Version="4.13.1" /> <PackageReference Include="Moq" Version="4.16.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" /> <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup> </ItemGroup>

View File

@@ -5,7 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="16.8.0" /> <PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="16.11.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>