Skip to content

Commit 8e86191

Browse files
authored
netstandard2 extendable lib model, basic rest (#793)
* first lib model * add missing files * happy test * add vanilla rest for extend * fix new url pattern * address comments * add v to tag * bump ver * add missing file when ren * support multi pkg * fix gh action * fix env var * ren title * use gh action to set ver * remove unused * remove unused
1 parent 0f09a33 commit 8e86191

File tree

65 files changed

+333
-895
lines changed

Some content is hidden

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

65 files changed

+333
-895
lines changed

.github/workflows/draft.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Nuget
1+
name: Draft Release
22

33
on:
44
push:
@@ -35,13 +35,13 @@ jobs:
3535
- name: dotnet test
3636
run: dotnet test
3737

38-
- name: dotnet pack
39-
run: dotnet pack -c Release src/KubernetesClient -o pkg --include-symbols
38+
- uses: dotnet/nbgv@master
39+
with:
40+
setAllVars: true
4041

4142
- name: create release
4243
shell: pwsh
4344
env:
4445
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4546
run: |
46-
$VERSION = Get-ChildItem -Path pkg/*.nupkg -Name | Select-String -Pattern '\d+.\d+.\d+' | foreach {$_.Matches.Value}
47-
gh release create -d --generate-notes v$VERSION
47+
gh release create -d --generate-notes v$env:NBGV_NuGetPackageVersion

.github/workflows/nuget.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
run: dotnet test
3737

3838
- name: dotnet pack
39-
run: dotnet pack -c Release src/KubernetesClient -o pkg --include-symbols
39+
run: dotnet pack -c Release src/nuget.proj -o pkg --include-symbols
4040

4141
- name: dotnet nuget push
4242
run: dotnet nuget push pkg\*.nupkg -s https://www.nuget.org/ -k ${{ secrets.nuget_api_key }}

Directory.Build.props

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,35 @@
55
<EnableNETAnalyzers>true</EnableNETAnalyzers>
66
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
77
</PropertyGroup>
8+
9+
<PropertyGroup>
10+
<Authors>The Kubernetes Project Authors</Authors>
11+
<Copyright>2017 The Kubernetes Project Authors</Copyright>
12+
<Description>Client library for the Kubernetes open source container orchestrator.</Description>
13+
14+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
15+
<PackageProjectUrl>https://github.com/kubernetes-client/csharp</PackageProjectUrl>
16+
<PackageIconUrl>https://raw.githubusercontent.com/kubernetes/kubernetes/master/logo/logo.png</PackageIconUrl>
17+
<PackageIcon>logo.png</PackageIcon>
18+
<PackageTags>kubernetes;docker;containers;</PackageTags>
19+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
20+
21+
<!-- Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
22+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
23+
24+
<!-- Build symbol package (.snupkg) to distribute the PDB containing Source Link -->
25+
<IncludeSymbols>true</IncludeSymbols>
26+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
27+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
28+
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
29+
<LangVersion>10.0</LangVersion>
30+
</PropertyGroup>
31+
32+
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
33+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
34+
</PropertyGroup>
35+
36+
<ItemGroup>
37+
<None Include="../../logo.png" Pack="true" Visible="false" PackagePath="" />
38+
</ItemGroup>
839
</Project>

Directory.Build.targets

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<ItemGroup>
3-
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
4-
<PrivateAssets>All</PrivateAssets>
5-
</PackageReference>
6-
7-
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
8-
<PrivateAssets>All</PrivateAssets>
9-
</PackageReference>
3+
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
4+
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0" PrivateAssets="all" />
5+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.255" PrivateAssets="all" />
6+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
107
</ItemGroup>
118

129
<ItemGroup>

examples/attach/Attach.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Threading.Tasks;
33
using k8s;
44
using k8s.Models;
5-
using k8s.Autorest;
65

76
namespace attach
87
{

examples/watch/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Threading.Tasks;
44
using k8s;
55
using k8s.Models;
6-
using k8s.Autorest;
76

87
namespace watch
98
{

examples/yaml/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.IO;
43
using System.Threading.Tasks;
54
using k8s;
65
using k8s.Models;

global.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
"sdk": {
44
"version": "6.0.100",
55
"rollForward": "latestMajor"
6+
},
7+
"msbuild-sdks": {
8+
"Microsoft.Build.Traversal" : "3.1.6"
69
}
710
}

kubernetes-client.sln

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "prometheus", "examples\prom
4949
EndProject
5050
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "yaml", "examples\yaml\yaml.csproj", "{17AB0AD8-6C90-42DD-880C-16B5AC4A373F}"
5151
EndProject
52+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KubernetesClient.Models", "src\KubernetesClient.Models\KubernetesClient.Models.csproj", "{F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}"
53+
EndProject
54+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KubernetesClient.Basic", "src\KubernetesClient.Basic\KubernetesClient.Basic.csproj", "{927995F5-05CC-4078-8805-8E6CC06914D8}"
55+
EndProject
5256
Global
5357
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5458
Debug|Any CPU = Debug|Any CPU
@@ -299,6 +303,30 @@ Global
299303
{17AB0AD8-6C90-42DD-880C-16B5AC4A373F}.Release|x64.Build.0 = Release|Any CPU
300304
{17AB0AD8-6C90-42DD-880C-16B5AC4A373F}.Release|x86.ActiveCfg = Release|Any CPU
301305
{17AB0AD8-6C90-42DD-880C-16B5AC4A373F}.Release|x86.Build.0 = Release|Any CPU
306+
{F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
307+
{F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Debug|Any CPU.Build.0 = Debug|Any CPU
308+
{F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Debug|x64.ActiveCfg = Debug|Any CPU
309+
{F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Debug|x64.Build.0 = Debug|Any CPU
310+
{F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Debug|x86.ActiveCfg = Debug|Any CPU
311+
{F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Debug|x86.Build.0 = Debug|Any CPU
312+
{F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Release|Any CPU.ActiveCfg = Release|Any CPU
313+
{F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Release|Any CPU.Build.0 = Release|Any CPU
314+
{F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Release|x64.ActiveCfg = Release|Any CPU
315+
{F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Release|x64.Build.0 = Release|Any CPU
316+
{F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Release|x86.ActiveCfg = Release|Any CPU
317+
{F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8}.Release|x86.Build.0 = Release|Any CPU
318+
{927995F5-05CC-4078-8805-8E6CC06914D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
319+
{927995F5-05CC-4078-8805-8E6CC06914D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
320+
{927995F5-05CC-4078-8805-8E6CC06914D8}.Debug|x64.ActiveCfg = Debug|Any CPU
321+
{927995F5-05CC-4078-8805-8E6CC06914D8}.Debug|x64.Build.0 = Debug|Any CPU
322+
{927995F5-05CC-4078-8805-8E6CC06914D8}.Debug|x86.ActiveCfg = Debug|Any CPU
323+
{927995F5-05CC-4078-8805-8E6CC06914D8}.Debug|x86.Build.0 = Debug|Any CPU
324+
{927995F5-05CC-4078-8805-8E6CC06914D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
325+
{927995F5-05CC-4078-8805-8E6CC06914D8}.Release|Any CPU.Build.0 = Release|Any CPU
326+
{927995F5-05CC-4078-8805-8E6CC06914D8}.Release|x64.ActiveCfg = Release|Any CPU
327+
{927995F5-05CC-4078-8805-8E6CC06914D8}.Release|x64.Build.0 = Release|Any CPU
328+
{927995F5-05CC-4078-8805-8E6CC06914D8}.Release|x86.ActiveCfg = Release|Any CPU
329+
{927995F5-05CC-4078-8805-8E6CC06914D8}.Release|x86.Build.0 = Release|Any CPU
302330
EndGlobalSection
303331
GlobalSection(SolutionProperties) = preSolution
304332
HideSolutionNode = FALSE
@@ -324,6 +352,8 @@ Global
324352
{DFBB1025-BD22-459D-A04D-E2AB31E129E2} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40}
325353
{682B94E4-1761-48FF-B5D0-87B45DC0C735} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40}
326354
{17AB0AD8-6C90-42DD-880C-16B5AC4A373F} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40}
355+
{F066A4D8-2EF0-4C07-AC0D-BD325DE3FFA8} = {3D1864AA-1FFC-4512-BB13-46055E410F73}
356+
{927995F5-05CC-4078-8805-8E6CC06914D8} = {3D1864AA-1FFC-4512-BB13-46055E410F73}
327357
EndGlobalSection
328358
GlobalSection(ExtensibilityGlobals) = postSolution
329359
SolutionGuid = {049A763A-C891-4E8D-80CF-89DD3E22ADC7}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using System.Net.Http;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
using k8s.Autorest;
5+
using System.Net.Http.Headers;
6+
7+
8+
namespace k8s
9+
{
10+
public abstract partial class AbstractKubernetes
11+
{
12+
private sealed class QueryBuilder
13+
{
14+
private List<string> parameters = new List<string>();
15+
16+
public void Append(string key, params object[] values)
17+
{
18+
foreach (var value in values)
19+
{
20+
switch (value)
21+
{
22+
case int intval:
23+
parameters.Add($"{key}={intval}");
24+
break;
25+
case string strval:
26+
parameters.Add($"{key}={Uri.EscapeDataString(strval)}");
27+
break;
28+
case bool boolval:
29+
parameters.Add($"{key}={(boolval ? "true" : "false")}");
30+
break;
31+
default:
32+
// null
33+
break;
34+
}
35+
}
36+
}
37+
38+
public override string ToString()
39+
{
40+
if (parameters.Count > 0)
41+
{
42+
return "?" + string.Join("&", parameters);
43+
}
44+
45+
return "";
46+
}
47+
}
48+
49+
private Task<HttpResponseMessage> SendRequest<T>(T body, HttpRequestMessage httpRequest, CancellationToken cancellationToken)
50+
{
51+
if (body != null)
52+
{
53+
var requestContent = KubernetesJson.Serialize(body);
54+
httpRequest.Content = new StringContent(requestContent, System.Text.Encoding.UTF8);
55+
httpRequest.Content.Headers.ContentType = GetHeader(body);
56+
return SendRequestRaw(requestContent, httpRequest, cancellationToken);
57+
}
58+
59+
return SendRequestRaw("", httpRequest, cancellationToken);
60+
}
61+
62+
public virtual TimeSpan HttpClientTimeout { get; set; } = TimeSpan.FromSeconds(100);
63+
64+
protected abstract Task<HttpOperationResponse<T>> CreateResultAsync<T>(HttpRequestMessage httpRequest, HttpResponseMessage httpResponse, bool? watch, CancellationToken cancellationToken);
65+
66+
protected abstract HttpRequestMessage CreateRequest(string relativeUri, string method, IDictionary<string, IList<string>> customHeaders);
67+
68+
protected abstract MediaTypeHeaderValue GetHeader(object body);
69+
70+
protected abstract Task<HttpResponseMessage> SendRequestRaw(string requestContent, HttpRequestMessage httpRequest, CancellationToken cancellationToken);
71+
}
72+
}

0 commit comments

Comments
 (0)