Skip to content

Commit 1b8804e

Browse files
committed
Add KubernetesRequest.GVK(string,string)
1 parent 19b11fc commit 1b8804e

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

KubernetesClient.Fluent.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<TargetFrameworks>netstandard2.0;netstandard2.1;net452;netcoreapp2.1</TargetFrameworks>
2222
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0;netstandard2.1;netcoreapp2.1</TargetFrameworks>
2323
<AssemblyVersion>1.0.0.0</AssemblyVersion> <!-- the assembly version is the major version only -->
24-
<FileVersion>1.0.2.0</FileVersion>
25-
<Version>1.0.2</Version>
24+
<FileVersion>1.0.3.0</FileVersion>
25+
<Version>1.0.3</Version>
2626
</PropertyGroup>
2727
<ItemGroup>
2828
<PackageReference Include="KubernetesClient" Version="2.0.6" />

KubernetesRequest.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,20 @@ public KubernetesRequest GVK(IKubernetesObject obj)
378378
return this;
379379
}
380380

381+
/// <summary>Attempts to set the <see cref="Group()"/>, <see cref="Version()"/>, and <see cref="Type()"/> based on a Kubernetes
382+
/// API version (including the API group) and kind. The method uses heuristics and may not work in all cases.
383+
/// </summary>
384+
public KubernetesRequest GVK(string apiVersion, string kind)
385+
{
386+
string group = null, version = apiVersion;
387+
if(!string.IsNullOrEmpty(apiVersion))
388+
{
389+
int slash = apiVersion.IndexOf('/');
390+
if(slash >= 0) (group, version) = (apiVersion.Substring(0, slash), apiVersion.Substring(slash+1));
391+
}
392+
return GVK(group, version, kind);
393+
}
394+
381395
/// <summary>Attempts to set the <see cref="Group()"/>, <see cref="Version()"/>, and <see cref="Type()"/> based on a Kubernetes
382396
/// group, version, and kind. The method uses heuristics and may not work in all cases.
383397
/// </summary>

0 commit comments

Comments
 (0)