From 2d8915dff77195ea6315c411ef4eb79c8d2ecb8a Mon Sep 17 00:00:00 2001 From: Bliamoh Date: Thu, 14 Oct 2021 18:02:51 +0200 Subject: [PATCH] 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 Co-authored-by: Boshi Lian --- .../CustomResourceDefinition.cs | 2 +- examples/customResource/Program.cs | 10 +++++----- examples/customResource/cResource.cs | 2 -- examples/customResource/config/crd.yaml | 18 ++++++++++++++--- examples/customResource/customResource.csproj | 20 +++++++++---------- .../httpClientFactory.csproj | 8 ++++---- .../Authentication/OidcTokenProvider.cs | 10 +++++----- src/KubernetesClient/KubernetesClient.csproj | 20 +++++++++---------- tests/E2E.Tests/E2E.Tests.csproj | 6 +++--- .../KubernetesClient.Tests.csproj | 18 ++++++++--------- tests/SkipTestLogger/SkipTestLogger.csproj | 2 +- 11 files changed, 63 insertions(+), 53 deletions(-) diff --git a/examples/customResource/CustomResourceDefinition.cs b/examples/customResource/CustomResourceDefinition.cs index a83d027..302d22f 100644 --- a/examples/customResource/CustomResourceDefinition.cs +++ b/examples/customResource/CustomResourceDefinition.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; using k8s; using k8s.Models; 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", "SA1402:FileMayOnlyContainASingleClass", Justification = "This is just an example.")] diff --git a/examples/customResource/Program.cs b/examples/customResource/Program.cs index 9ecbbd7..0be2560 100644 --- a/examples/customResource/Program.cs +++ b/examples/customResource/Program.cs @@ -1,9 +1,9 @@ -using System; -using System.Collections.Generic; using k8s; using k8s.Models; -using System.Threading.Tasks; using Microsoft.AspNetCore.JsonPatch; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; namespace customResource @@ -12,7 +12,7 @@ namespace customResource { private static async Task Main(string[] args) { - Console.WriteLine("strating main()..."); + Console.WriteLine("starting main()..."); // creating the k8s client var k8SClientConfig = KubernetesClientConfiguration.BuildConfigFromConfigFile(); @@ -21,7 +21,7 @@ namespace customResource // creating a K8s client for the CRD var myCRD = Utils.MakeCRD(); 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 var myCr = Utils.MakeCResource(); diff --git a/examples/customResource/cResource.cs b/examples/customResource/cResource.cs index a1e1414..188ee84 100644 --- a/examples/customResource/cResource.cs +++ b/examples/customResource/cResource.cs @@ -1,6 +1,4 @@ using k8s.Models; -using System.Collections.Generic; -using k8s; using Newtonsoft.Json; namespace customResource diff --git a/examples/customResource/config/crd.yaml b/examples/customResource/config/crd.yaml index 23e27b6..424546f 100644 --- a/examples/customResource/config/crd.yaml +++ b/examples/customResource/config/crd.yaml @@ -1,11 +1,23 @@ -apiVersion: apiextensions.k8s.io/v1beta1 +apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: customresources.csharp.com spec: 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: kind: CResource plural: customresources - scope: Namespaced \ No newline at end of file + scope: Namespaced diff --git a/examples/customResource/customResource.csproj b/examples/customResource/customResource.csproj index da54913..15c3cfb 100644 --- a/examples/customResource/customResource.csproj +++ b/examples/customResource/customResource.csproj @@ -1,15 +1,15 @@ - - Exe - net5.0 - + + Exe + net5.0 + - - - - - - + + + + + + diff --git a/examples/httpClientFactory/httpClientFactory.csproj b/examples/httpClientFactory/httpClientFactory.csproj index 9e704cd..0394190 100644 --- a/examples/httpClientFactory/httpClientFactory.csproj +++ b/examples/httpClientFactory/httpClientFactory.csproj @@ -1,4 +1,4 @@ - + Exe @@ -6,9 +6,9 @@ - - - + + + diff --git a/src/KubernetesClient/Authentication/OidcTokenProvider.cs b/src/KubernetesClient/Authentication/OidcTokenProvider.cs index 4ce2d76..4043211 100644 --- a/src/KubernetesClient/Authentication/OidcTokenProvider.cs +++ b/src/KubernetesClient/Authentication/OidcTokenProvider.cs @@ -1,11 +1,11 @@ +using IdentityModel.OidcClient; +using k8s.Exceptions; +using Microsoft.Rest; using System; +using System.IdentityModel.Tokens.Jwt; using System.Net.Http.Headers; using System.Threading; using System.Threading.Tasks; -using System.IdentityModel.Tokens.Jwt; -using Microsoft.Rest; -using IdentityModel.OidcClient; -using k8s.Exceptions; namespace k8s.Authentication { @@ -14,7 +14,7 @@ namespace k8s.Authentication private OidcClient _oidcClient; private string _idToken; private string _refreshToken; - private DateTime _expiry; + private DateTimeOffset _expiry; public OidcTokenProvider(string clientId, string clientSecret, string idpIssuerUrl, string idToken, string refreshToken) { diff --git a/src/KubernetesClient/KubernetesClient.csproj b/src/KubernetesClient/KubernetesClient.csproj index b1269a3..06295fb 100644 --- a/src/KubernetesClient/KubernetesClient.csproj +++ b/src/KubernetesClient/KubernetesClient.csproj @@ -30,18 +30,18 @@ - - - - + + + + - - - - - + + + + + - + diff --git a/tests/E2E.Tests/E2E.Tests.csproj b/tests/E2E.Tests/E2E.Tests.csproj index 3990798..ec4494f 100644 --- a/tests/E2E.Tests/E2E.Tests.csproj +++ b/tests/E2E.Tests/E2E.Tests.csproj @@ -8,11 +8,11 @@ - + - + - + all diff --git a/tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj b/tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj index eaa58ae..26e883b 100755 --- a/tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj +++ b/tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj @@ -8,29 +8,29 @@ - - - - - - + + + + + + - + all runtime; build; native; contentfiles; analyzers - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/tests/SkipTestLogger/SkipTestLogger.csproj b/tests/SkipTestLogger/SkipTestLogger.csproj index e7d5824..ea1e077 100644 --- a/tests/SkipTestLogger/SkipTestLogger.csproj +++ b/tests/SkipTestLogger/SkipTestLogger.csproj @@ -5,7 +5,7 @@ - +