generate v1.26 (#1122)

* update swagger

* remove unused models in converter

* remove netcore3.1 from testr

* bump ver

* fix convert

* remove some unused autorest property

* move some clz from autorest to client

* fix import

* no longer expose SendRequestRaw

* make file utils inner

* fix build

* c# 11
This commit is contained in:
Boshi Lian
2022-12-15 18:21:36 -08:00
committed by GitHub
parent 93a1f16bb2
commit 4e74fd20b7
36 changed files with 9398 additions and 4385 deletions

View File

@@ -15,7 +15,6 @@ jobs:
uses: actions/setup-dotnet@v3 uses: actions/setup-dotnet@v3
with: with:
dotnet-version: | dotnet-version: |
3.1.x
6.0.x 6.0.x
7.0.x 7.0.x
# - name: Check Format # - name: Check Format
@@ -56,7 +55,6 @@ jobs:
uses: actions/setup-dotnet@v3 uses: actions/setup-dotnet@v3
with: with:
dotnet-version: | dotnet-version: |
3.1.x
6.0.x 6.0.x
7.0.x 7.0.x
- name: Minikube - name: Minikube

View File

@@ -33,7 +33,6 @@ jobs:
uses: actions/setup-dotnet@v3 uses: actions/setup-dotnet@v3
with: with:
dotnet-version: | dotnet-version: |
3.1.x
5.0.x 5.0.x
6.0.x 6.0.x

View File

@@ -18,7 +18,6 @@ jobs:
uses: actions/setup-dotnet@v3 uses: actions/setup-dotnet@v3
with: with:
dotnet-version: | dotnet-version: |
3.1.x
6.0.x 6.0.x
7.0.x 7.0.x

View File

@@ -18,7 +18,6 @@ jobs:
uses: actions/setup-dotnet@v3 uses: actions/setup-dotnet@v3
with: with:
dotnet-version: | dotnet-version: |
3.1.x
6.0.x 6.0.x
7.0.x 7.0.x

View File

@@ -26,7 +26,7 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat> <SymbolPackageFormat>snupkg</SymbolPackageFormat>
<EmbedUntrackedSources>true</EmbedUntrackedSources> <EmbedUntrackedSources>true</EmbedUntrackedSources>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder> <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<LangVersion>10.0</LangVersion> <LangVersion>11.0</LangVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'"> <PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">

View File

@@ -149,6 +149,7 @@ ${GEN_DIR}/openapi/csharp.sh ${REPO_DIR}/src/KubernetesClient ${REPO_DIR}/csharp
| SDK Version | Kubernetes Version | .NET Targeting | | SDK Version | Kubernetes Version | .NET Targeting |
|-------------|--------------------|------------------------------------------------------| |-------------|--------------------|------------------------------------------------------|
| 10.0 | 1.26 | net6.0;net7.0;net48*;netstandard2.0* |
| 9.1 | 1.25 | netstandard2.1;net6.0;net7.0;net48*;netstandard2.0* | | 9.1 | 1.25 | netstandard2.1;net6.0;net7.0;net48*;netstandard2.0* |
| 9.0 | 1.25 | netstandard2.1;net5.0;net6.0;net48*;netstandard2.0* | | 9.0 | 1.25 | netstandard2.1;net5.0;net6.0;net48*;netstandard2.0* |
| 8.0 | 1.24 | netstandard2.1;net5.0;net6.0;net48*;netstandard2.0* | | 8.0 | 1.24 | netstandard2.1;net5.0;net6.0;net48*;netstandard2.0* |

View File

@@ -1,3 +1,3 @@
export KUBERNETES_BRANCH=v1.25.0 export KUBERNETES_BRANCH=v1.26.0
export CLIENT_VERSION=0.0.1 export CLIENT_VERSION=0.0.1
export PACKAGE_NAME=k8s export PACKAGE_NAME=k8s

View File

@@ -1,5 +1,4 @@
using k8s; using k8s;
using k8s.Monitoring;
using Prometheus; using Prometheus;
using System; using System;
using System.Net.Http; using System.Net.Http;

View File

@@ -14,7 +14,13 @@ public abstract partial class AbstractKubernetes
public static readonly HttpMethod Post = HttpMethod.Post; public static readonly HttpMethod Post = HttpMethod.Post;
public static readonly HttpMethod Put = HttpMethod.Put; public static readonly HttpMethod Put = HttpMethod.Put;
public static readonly HttpMethod Trace = HttpMethod.Trace; public static readonly HttpMethod Trace = HttpMethod.Trace;
#if NETSTANDARD2_0
public static readonly HttpMethod Patch = new HttpMethod("PATCH"); public static readonly HttpMethod Patch = new HttpMethod("PATCH");
#else
public static readonly HttpMethod Patch = HttpMethod.Patch;
#endif
} }
private sealed class QueryBuilder private sealed class QueryBuilder
@@ -96,6 +102,4 @@ public abstract partial class AbstractKubernetes
protected abstract Task<HttpOperationResponse<T>> CreateResultAsync<T>(HttpRequestMessage httpRequest, HttpResponseMessage httpResponse, bool? watch, CancellationToken cancellationToken); protected abstract Task<HttpOperationResponse<T>> CreateResultAsync<T>(HttpRequestMessage httpRequest, HttpResponseMessage httpResponse, bool? watch, CancellationToken cancellationToken);
protected abstract Task<HttpResponseMessage> SendRequest<T>(string relativeUri, HttpMethod method, IReadOnlyDictionary<string, IReadOnlyList<string>> customHeaders, T body, CancellationToken cancellationToken); protected abstract Task<HttpResponseMessage> SendRequest<T>(string relativeUri, HttpMethod method, IReadOnlyDictionary<string, IReadOnlyList<string>> customHeaders, T body, CancellationToken cancellationToken);
protected abstract Task<HttpResponseMessage> SendRequestRaw(string requestContent, HttpRequestMessage httpRequest, CancellationToken cancellationToken);
} }

View File

@@ -9,7 +9,7 @@ namespace k8s.Autorest
/// Exception thrown for an invalid response with custom error information. /// Exception thrown for an invalid response with custom error information.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class HttpOperationException : RestException public class HttpOperationException : Exception
{ {
/// <summary> /// <summary>
/// Gets information about the associated HTTP request. /// Gets information about the associated HTTP request.

View File

@@ -24,20 +24,12 @@ namespace k8s.Autorest
throw new ArgumentNullException("httpRequest"); throw new ArgumentNullException("httpRequest");
} }
this.CopyHeaders(httpRequest.Headers); CopyHeaders(httpRequest.Headers);
this.CopyHeaders(httpRequest.GetContentHeaders()); CopyHeaders(httpRequest.GetContentHeaders());
this.Content = content; Content = content;
this.Method = httpRequest.Method; Method = httpRequest.Method;
this.RequestUri = httpRequest.RequestUri; RequestUri = httpRequest.RequestUri;
if (httpRequest.Properties != null)
{
Properties = new Dictionary<string, object>();
foreach (KeyValuePair<string, object> pair in httpRequest.Properties)
{
this.Properties[pair.Key] = pair.Value;
}
}
} }
/// <summary> /// <summary>
@@ -49,10 +41,5 @@ namespace k8s.Autorest
/// Gets or sets the Uri used for the HTTP request. /// Gets or sets the Uri used for the HTTP request.
/// </summary> /// </summary>
public Uri RequestUri { get; protected set; } public Uri RequestUri { get; protected set; }
/// <summary>
/// Gets a set of properties for the HTTP request.
/// </summary>
public IDictionary<string, object> Properties { get; private set; }
} }
} }

View File

@@ -25,12 +25,12 @@ namespace k8s.Autorest
throw new ArgumentNullException("httpResponse"); throw new ArgumentNullException("httpResponse");
} }
this.CopyHeaders(httpResponse.Headers); CopyHeaders(httpResponse.Headers);
this.CopyHeaders(httpResponse.GetContentHeaders()); CopyHeaders(httpResponse.GetContentHeaders());
this.Content = content; Content = content;
this.StatusCode = httpResponse.StatusCode; StatusCode = httpResponse.StatusCode;
this.ReasonPhrase = httpResponse.ReasonPhrase; ReasonPhrase = httpResponse.ReasonPhrase;
} }
/// <summary> /// <summary>

View File

@@ -1,50 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System.Runtime.Serialization;
namespace k8s.Autorest
{
/// <summary>
/// Generic exception for Microsoft Rest Client.
/// </summary>
[Serializable]
public class RestException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="RestException"/> class.
/// </summary>
public RestException()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="RestException"/> class.
/// </summary>
/// <param name="message">The exception message.</param>
public RestException(string message)
: this(message, null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="RestException"/> class.
/// </summary>
/// <param name="message">The exception message.</param>
/// <param name="innerException">Inner exception.</param>
public RestException(string message, Exception innerException)
: base(message, innerException)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="RestException"/> class.
/// </summary>
/// <param name="info">Serialization info.</param>
/// <param name="context">Streaming context.</param>
protected RestException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

View File

@@ -0,0 +1,3 @@
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("KubernetesClient.Tests")]

View File

@@ -50,6 +50,11 @@
<Compile Include="..\KubernetesClient\Authentication\GcpTokenProvider.cs" /> <Compile Include="..\KubernetesClient\Authentication\GcpTokenProvider.cs" />
<Compile Include="..\KubernetesClient\Authentication\OidcTokenProvider.cs" /> <Compile Include="..\KubernetesClient\Authentication\OidcTokenProvider.cs" />
<Compile Include="..\KubernetesClient\Authentication\TokenFileAuth.cs" /> <Compile Include="..\KubernetesClient\Authentication\TokenFileAuth.cs" />
<Compile Include="..\KubernetesClient\Authentication\BasicAuthenticationCredentials.cs" />
<Compile Include="..\KubernetesClient\Authentication\ITokenProvider.cs" />
<Compile Include="..\KubernetesClient\Authentication\ServiceClientCredentials.cs" />
<Compile Include="..\KubernetesClient\Authentication\StringTokenProvider.cs" />
<Compile Include="..\KubernetesClient\Authentication\TokenCredentials.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -148,21 +148,17 @@ namespace k8s.Versioning
obj.Kind = metadata.Kind; obj.Kind = metadata.Kind;
}); });
}); });
cfg.CreateMap<V1Subject, V1beta1Subject>()
.ForMember(dest => dest.Group, opt => opt.Ignore())
.ForMember(dest => dest.ServiceAccount, opt => opt.Ignore())
.ForMember(dest => dest.User, opt => opt.Ignore())
.ReverseMap();
cfg.CreateMap<V1Subject, V1beta2Subject>() cfg.CreateMap<V1Subject, V1beta2Subject>()
.ForMember(dest => dest.Group, opt => opt.Ignore()) .ForMember(dest => dest.Group, opt => opt.Ignore())
.ForMember(dest => dest.ServiceAccount, opt => opt.Ignore()) .ForMember(dest => dest.ServiceAccount, opt => opt.Ignore())
.ForMember(dest => dest.User, opt => opt.Ignore()) .ForMember(dest => dest.User, opt => opt.Ignore())
.ReverseMap(); .ReverseMap();
cfg.CreateMap<V1Subject, V1beta3Subject>()
cfg.CreateMap<V1HorizontalPodAutoscalerSpec, V2beta2HorizontalPodAutoscalerSpec>() .ForMember(dest => dest.Group, opt => opt.Ignore())
.ForMember(dest => dest.Metrics, opt => opt.Ignore()) .ForMember(dest => dest.ServiceAccount, opt => opt.Ignore())
.ForMember(dest => dest.Behavior, opt => opt.Ignore()) .ForMember(dest => dest.User, opt => opt.Ignore())
.ReverseMap(); .ReverseMap();
cfg.CreateMap<V1HorizontalPodAutoscalerSpec, V2HorizontalPodAutoscalerSpec>() cfg.CreateMap<V1HorizontalPodAutoscalerSpec, V2HorizontalPodAutoscalerSpec>()
@@ -171,14 +167,18 @@ namespace k8s.Versioning
.ReverseMap(); .ReverseMap();
cfg.CreateMap<V1HorizontalPodAutoscalerStatus, V2beta2HorizontalPodAutoscalerStatus>()
.ForMember(dest => dest.Conditions, opt => opt.Ignore())
.ForMember(dest => dest.CurrentMetrics, opt => opt.Ignore())
.ReverseMap();
cfg.CreateMap<V1HorizontalPodAutoscalerStatus, V2HorizontalPodAutoscalerStatus>() cfg.CreateMap<V1HorizontalPodAutoscalerStatus, V2HorizontalPodAutoscalerStatus>()
.ForMember(dest => dest.Conditions, opt => opt.Ignore()) .ForMember(dest => dest.Conditions, opt => opt.Ignore())
.ForMember(dest => dest.CurrentMetrics, opt => opt.Ignore()) .ForMember(dest => dest.CurrentMetrics, opt => opt.Ignore())
.ReverseMap(); .ReverseMap();
cfg.CreateMap<V1alpha1ResourceClaim, V1ResourceClaim>()
.ForMember(dest => dest.Name, opt => opt.Ignore())
.ReverseMap();
cfg.CreateMap<V1beta2LimitedPriorityLevelConfiguration, V1beta3LimitedPriorityLevelConfiguration>()
.ForMember(dest => dest.NominalConcurrencyShares, opt => opt.Ignore())
.ReverseMap();
} }
} }
} }

View File

@@ -5,8 +5,10 @@ using System.Globalization;
using System.Net.Http; using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace k8s.Autorest namespace k8s.Authentication
{ {
/// <summary> /// <summary>
/// Basic Auth credentials for use with a REST Service Client. /// Basic Auth credentials for use with a REST Service Client.

View File

@@ -1,4 +1,3 @@
using k8s.Autorest;
using k8s.KubeConfigModels; using k8s.KubeConfigModels;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Threading; using System.Threading;

View File

@@ -1,4 +1,3 @@
using k8s.Autorest;
using k8s.Exceptions; using k8s.Exceptions;
using System.Diagnostics; using System.Diagnostics;
using System.Net.Http.Headers; using System.Net.Http.Headers;

View File

@@ -2,10 +2,12 @@
// Licensed under the MIT License. See License.txt in the project root for license information. // Licensed under the MIT License. See License.txt in the project root for license information.
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
#pragma warning disable SA1606 #pragma warning disable SA1606
#pragma warning disable SA1614 #pragma warning disable SA1614
namespace k8s.Autorest namespace k8s.Authentication
{ {
/// <summary> /// <summary>
/// Interface to a source of access tokens. /// Interface to a source of access tokens.

View File

@@ -1,5 +1,4 @@
using IdentityModel.OidcClient; using IdentityModel.OidcClient;
using k8s.Autorest;
using k8s.Exceptions; using k8s.Exceptions;
using System.IdentityModel.Tokens.Jwt; using System.IdentityModel.Tokens.Jwt;
using System.Net.Http.Headers; using System.Net.Http.Headers;

View File

@@ -2,8 +2,10 @@
// Licensed under the MIT License. See License.txt in the project root for license information. // Licensed under the MIT License. See License.txt in the project root for license information.
using System.Net.Http; using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace k8s.Autorest namespace k8s.Authentication
{ {
/// <summary> /// <summary>
/// ServiceClientCredentials is the abstraction for credentials used by ServiceClients accessing REST services. /// ServiceClientCredentials is the abstraction for credentials used by ServiceClients accessing REST services.

View File

@@ -2,8 +2,10 @@
// Licensed under the MIT License. See License.txt in the project root for license information. // Licensed under the MIT License. See License.txt in the project root for license information.
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
namespace k8s.Autorest namespace k8s.Authentication
{ {
/// <summary> /// <summary>
/// A simple token provider that always provides a static access token. /// A simple token provider that always provides a static access token.

View File

@@ -2,8 +2,10 @@
// Licensed under the MIT License. See License.txt in the project root for license information. // Licensed under the MIT License. See License.txt in the project root for license information.
using System.Net.Http; using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace k8s.Autorest namespace k8s.Authentication
{ {
/// <summary> /// <summary>
/// Token based credentials for use with a REST Service Client. /// Token based credentials for use with a REST Service Client.
@@ -73,7 +75,7 @@ namespace k8s.Autorest
throw new ArgumentNullException("tokenProvider"); throw new ArgumentNullException("tokenProvider");
} }
this.TokenProvider = tokenProvider; TokenProvider = tokenProvider;
} }
/// <summary> /// <summary>
@@ -86,8 +88,8 @@ namespace k8s.Autorest
public TokenCredentials(ITokenProvider tokenProvider, string tenantId, string callerId) public TokenCredentials(ITokenProvider tokenProvider, string tenantId, string callerId)
: this(tokenProvider) : this(tokenProvider)
{ {
this.TenantId = tenantId; TenantId = tenantId;
this.CallerId = callerId; CallerId = callerId;
} }
/// <summary> /// <summary>

View File

@@ -1,4 +1,3 @@
using k8s.Autorest;
using System.IO; using System.IO;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Threading; using System.Threading;

View File

@@ -2,7 +2,7 @@ using System.IO.Abstractions;
namespace k8s namespace k8s
{ {
public static class FileUtils internal static class FileUtils
{ {
private static readonly IFileSystem RealFileSystem = new FileSystem(); private static readonly IFileSystem RealFileSystem = new FileSystem();
private static IFileSystem currentFileSystem = null; private static IFileSystem currentFileSystem = null;

View File

@@ -1,4 +1,4 @@
using k8s.Autorest; using k8s.Authentication;
using k8s.Exceptions; using k8s.Exceptions;
using System.Net.Http; using System.Net.Http;
using System.Net.Security; using System.Net.Security;

View File

@@ -1,3 +1,4 @@
using k8s.Authentication;
using k8s.Autorest; using k8s.Autorest;
using System.IO; using System.IO;
using System.Net; using System.Net;
@@ -138,7 +139,7 @@ namespace k8s
return SendRequestRaw("", httpRequest, cancellationToken); return SendRequestRaw("", httpRequest, cancellationToken);
} }
protected override async Task<HttpResponseMessage> SendRequestRaw(string requestContent, HttpRequestMessage httpRequest, CancellationToken cancellationToken) protected virtual async Task<HttpResponseMessage> SendRequestRaw(string requestContent, HttpRequestMessage httpRequest, CancellationToken cancellationToken)
{ {
if (httpRequest == null) if (httpRequest == null)
{ {

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.1;net6.0;net7.0</TargetFrameworks> <TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<RootNamespace>k8s</RootNamespace> <RootNamespace>k8s</RootNamespace>
</PropertyGroup> </PropertyGroup>
@@ -10,8 +10,6 @@
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.25.1" /> <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.25.1" />
<PackageReference Include="System.IO.Abstractions" Version="18.0.1" /> <PackageReference Include="System.IO.Abstractions" Version="18.0.1" />
<PackageReference Include="IdentityModel.OidcClient" Version="5.2.0" /> <PackageReference Include="IdentityModel.OidcClient" Version="5.2.0" />
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" Condition="'$(TargetFramework)' == 'netstandard2.1'" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,4 +1,4 @@
using k8s.Autorest; using k8s.Authentication;
using System.Net.Http; using System.Net.Http;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;

View File

@@ -3,7 +3,7 @@ using System.Net.Http;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace k8s.Monitoring namespace k8s
{ {
public class PrometheusHandler : DelegatingHandler public class PrometheusHandler : DelegatingHandler
{ {

13592
swagger.json

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>
<RootNamespace>k8s.E2E</RootNamespace> <RootNamespace>k8s.E2E</RootNamespace>
<TargetFrameworks>netcoreapp3.1;net6.0;net7.0</TargetFrameworks> <TargetFrameworks>net6.0;net7.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<RootNamespace>k8s.Tests</RootNamespace> <RootNamespace>k8s.Tests</RootNamespace>
<TargetFrameworks>netcoreapp3.1;net6.0;net7.0</TargetFrameworks> <TargetFrameworks>net6.0;net7.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,4 +1,4 @@
using k8s.Autorest; using k8s.Authentication;
using k8s.Tests.Logging; using k8s.Tests.Logging;
using k8s.Tests.Mock.Server; using k8s.Tests.Mock.Server;
using Microsoft.AspNetCore; using Microsoft.AspNetCore;

View File

@@ -1,6 +1,6 @@
{ {
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "9.1", "version": "10.0",
"publicReleaseRefSpec": [ "publicReleaseRefSpec": [
"^refs/heads/master$", "^refs/heads/master$",
"^refs/tags/v\\d+\\.\\d+\\.\\d+" "^refs/tags/v\\d+\\.\\d+\\.\\d+"