Skip to content

Commit eca9898

Browse files
authored
API v1.23.0 + system.text.json + remove WatchXXX API (#750)
* gen v1.23.0 * fix converter * bump ver * update readme runtime * fix warning * update dep ver * newtonjson -> system.text.json * generate for new json api * readme lf * dotnet fmt * dotnet fmt tests/ * dotnet fmt * Revert "dotnet fmt" This reverts commit e14c590. * fix err introduce by dotnet fmt * fix test * remove deprecated /watch api * generate code after /watch removed * remove /watch related code * trim Microsoft.Rest.Serialization
1 parent 6c53987 commit eca9898

File tree

699 files changed

+91237
-154570
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

699 files changed

+91237
-154570
lines changed

Directory.Build.targets

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<PrivateAssets>All</PrivateAssets>
55
</PackageReference>
66

7-
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="5.0.3">
7+
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
88
<PrivateAssets>All</PrivateAssets>
99
</PackageReference>
1010
</ItemGroup>

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,17 @@ ${GEN_DIR}/openapi/csharp.sh generated ../csharp.settings
151151

152152
| SDK Version | Kubernetes Version | .NET Targeting |
153153
|-------------|--------------------|---------------------------------------|
154+
| 7.0 | 1.23 | netstandard2.1;net5;net6 |
154155
| 6.0 | 1.22 | netstandard2.1;net5 |
155156
| 5.0 | 1.21 | netstandard2.1;net5 |
156157
| 4.0 | 1.20 | netstandard2.0;netstandard2.1 |
157158
| 3.0 | 1.19 | netstandard2.0;net452 |
158-
| 2.0 | 1.18 | netstandard2.0;net453 |
159+
| 2.0 | 1.18 | netstandard2.0;net452 |
159160
| 1.6 | 1.16 | netstandard1.4;netstandard2.0;net452; |
160161
| 1.4 | 1.13 | netstandard1.4;net451 |
161162
| 1.3 | 1.12 | netstandard1.4;net452 |
162163

163-
* Starting form `2.0`, [dotnet sdk versioning](https://github.com/kubernetes-client/csharp/issues/400) adopted
164+
* Starting from `2.0`, [dotnet sdk versioning](https://github.com/kubernetes-client/csharp/issues/400) adopted
164165
* `Kubernetes Version` here means the version sdk models and apis were generated from
165166
* Kubernetes api server guarantees the compatibility with `n-2` version. for exmaple, 1.19 based sdk should work with 1.21 cluster, but no guarantee works with 1.22 cluster. see also <https://kubernetes.io/releases/version-skew-policy/>
166167

csharp.settings

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export KUBERNETES_BRANCH=v1.22.0
1+
export KUBERNETES_BRANCH=v1.23.0
22
export CLIENT_VERSION=0.0.1
33
export PACKAGE_NAME=k8s

gen/KubernetesGenerator/Program.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ private static async Task RunAsync(Options options)
8080
helper.RegisterHelper();
8181
}
8282

83-
if (options.GenerateWatch)
84-
{
85-
container.Resolve<WatchGenerator>().Generate(swaggerUnprocessed, outputDirectory);
86-
}
83+
//if (options.GenerateWatch)
84+
//{
85+
// container.Resolve<WatchGenerator>().Generate(swaggerUnprocessed, outputDirectory);
86+
//}
8787

8888
if (options.GenerateApi)
8989
{
@@ -112,8 +112,8 @@ public class Options
112112
[Value(0, Required = true, HelpText = "path to src/KubernetesClient/generated")]
113113
public string OutputPath { get; set; }
114114

115-
[Option("watch", Required = false, Default = true)]
116-
public bool GenerateWatch { get; set; }
115+
//[Option("watch", Required = false, Default = true)]
116+
//public bool GenerateWatch { get; set; }
117117

118118
[Option("api", Required = false, Default = true)]
119119
public bool GenerateApi { get; set; }

gen/KubernetesGenerator/StringHelpers.cs

+8-4
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void EscapeDataString(RenderContext context, IList<object> arguments,
109109

110110
if (name == "pretty")
111111
{
112-
context.Write($"{name}.Value == true ? \"true\" : \"false\"");
112+
context.Write($"{name}.Value ? \"true\" : \"false\"");
113113
return;
114114
}
115115

@@ -118,10 +118,14 @@ public void EscapeDataString(RenderContext context, IList<object> arguments,
118118
case JsonObjectType.String:
119119
context.Write($"System.Uri.EscapeDataString({name})");
120120
break;
121-
default:
122-
context.Write(
123-
$"System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject({name}, SerializationSettings).Trim('\"'))");
121+
case JsonObjectType.Boolean:
122+
context.Write($"{name}.Value ? \"true\" : \"false\"");
123+
break;
124+
case JsonObjectType.Integer:
125+
context.Write($"{name}.Value");
124126
break;
127+
default:
128+
throw new ArgumentException("type not supportted");
125129
}
126130
}
127131
}
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,57 @@
1-
// <auto-generated>
2-
// Code generated by https://github.com/kubernetes-client/csharp/tree/master/gen/KubernetesGenerator
3-
// Changes may cause incorrect behavior and will be lost if the code is
4-
// regenerated.
5-
// </auto-generated>
1+
// <auto-generated>
2+
// Code generated by https://github.com/kubernetes-client/csharp/tree/master/gen/KubernetesGenerator
3+
// Changes may cause incorrect behavior and will be lost if the code is
4+
// regenerated.
5+
// </auto-generated>
6+
7+
namespace k8s
8+
{
9+
using Microsoft.Rest;
10+
using Models;
11+
12+
using System.Collections;
13+
using System.Collections.Generic;
14+
using System.IO;
15+
using System.Threading;
16+
using System.Threading.Tasks;
17+
18+
/// <summary>
19+
/// </summary>
20+
public partial interface IKubernetes : System.IDisposable
21+
{
22+
/// <summary>
23+
/// The base URI of the service.
24+
/// </summary>
25+
System.Uri BaseUri { get; set; }
26+
27+
/// <summary>
28+
/// Subscription credentials which uniquely identify client
29+
/// subscription.
30+
/// </summary>
31+
ServiceClientCredentials Credentials { get; }
632

7-
namespace k8s
8-
{
9-
using Microsoft.Rest;
10-
using Models;
11-
using Newtonsoft.Json;
12-
using System.Collections;
13-
using System.Collections.Generic;
14-
using System.IO;
15-
using System.Threading;
16-
using System.Threading.Tasks;
17-
18-
/// <summary>
19-
/// </summary>
20-
public partial interface IKubernetes : System.IDisposable
21-
{
22-
/// <summary>
23-
/// The base URI of the service.
24-
/// </summary>
25-
System.Uri BaseUri { get; set; }
26-
27-
/// <summary>
28-
/// Gets or sets json serialization settings.
29-
/// </summary>
30-
JsonSerializerSettings SerializationSettings { get; }
31-
32-
/// <summary>
33-
/// Gets or sets json deserialization settings.
34-
/// </summary>
35-
JsonSerializerSettings DeserializationSettings { get; }
36-
37-
/// <summary>
38-
/// Subscription credentials which uniquely identify client
39-
/// subscription.
40-
/// </summary>
41-
ServiceClientCredentials Credentials { get; }
42-
43-
{{#.}}
44-
/// <summary>
45-
/// {{ToXmlDoc operation.description}}
46-
/// </summary>
47-
{{#operation.parameters}}
48-
/// <param name="{{GetDotNetName .}}">
49-
/// {{ToXmlDoc description}}
50-
/// </param>
51-
{{/operation.parameters}}
52-
/// <param name="customHeaders">
53-
/// The headers that will be added to request.
54-
/// </param>
55-
/// <param name="cancellationToken">
56-
/// A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.
57-
/// </param>
58-
Task<HttpOperationResponse{{GetReturnType operation "<>"}}> {{GetMethodName operation "WithHttpMessagesAsync"}}(
59-
{{#operation.parameters}}
60-
{{GetDotNetType .}} {{GetDotNetName . "true"}},
61-
{{/operation.parameters}}
62-
Dictionary<string, List<string>> customHeaders = null,
63-
CancellationToken cancellationToken = default(CancellationToken));
64-
65-
{{/.}}
66-
}
67-
}
33+
{{#.}}
34+
/// <summary>
35+
/// {{ToXmlDoc operation.description}}
36+
/// </summary>
37+
{{#operation.parameters}}
38+
/// <param name="{{GetDotNetName .}}">
39+
/// {{ToXmlDoc description}}
40+
/// </param>
41+
{{/operation.parameters}}
42+
/// <param name="customHeaders">
43+
/// The headers that will be added to request.
44+
/// </param>
45+
/// <param name="cancellationToken">
46+
/// A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.
47+
/// </param>
48+
Task<HttpOperationResponse{{GetReturnType operation "<>"}}> {{GetMethodName operation "WithHttpMessagesAsync"}}(
49+
{{#operation.parameters}}
50+
{{GetDotNetType .}} {{GetDotNetName . "true"}},
51+
{{/operation.parameters}}
52+
IDictionary<string, IList<string>> customHeaders = null,
53+
CancellationToken cancellationToken = default);
54+
55+
{{/.}}
56+
}
57+
}

0 commit comments

Comments
 (0)