refactor: reorganize Kubernetes client models into separate files (#1663)

This commit is contained in:
Boshi Lian
2025-09-16 07:40:17 -07:00
committed by GitHub
parent a99fbe4693
commit 11a9641fbe
10 changed files with 68 additions and 70 deletions

View File

@@ -1,6 +1,7 @@
// See https://aka.ms/new-console-template for more information
// See https://aka.ms/new-console-template for more information
using k8s;
using k8s.ClientSets;
using k8s.Models;
using System.Threading.Tasks;
namespace clientset

View File

@@ -20,14 +20,14 @@
<Compile Include="..\KubernetesClient\Extensions.cs" />
<Compile Include="..\KubernetesClient\FloatEmitter.cs" />
<Compile Include="..\KubernetesClient\Models\GeneratedModelVersion.cs" />
<Compile Include="..\KubernetesClient\IItems.cs" />
<Compile Include="..\KubernetesClient\Models\IItems.cs" />
<Compile Include="..\KubernetesClient\IKubernetesObject.cs" />
<Compile Include="..\KubernetesClient\IMetadata.cs" />
<Compile Include="..\KubernetesClient\Models\IMetadata.cs" />
<Compile Include="..\KubernetesClient\Models\IntOrStringJsonConverter.cs" />
<Compile Include="..\KubernetesClient\Models\IntOrStringYamlConverter.cs" />
<Compile Include="..\KubernetesClient\Models\IntstrIntOrString.cs" />
<Compile Include="..\KubernetesClient\ISpec.cs" />
<Compile Include="..\KubernetesClient\IStatus.cs" />
<Compile Include="..\KubernetesClient\Models\ISpec.cs" />
<Compile Include="..\KubernetesClient\Models\IStatus.cs" />
<Compile Include="..\KubernetesClient\IValidate.cs" />
<Compile Include="..\KubernetesClient\Models\KubernetesEntityAttribute.cs" />
<Compile Include="..\KubernetesClient\Models\KubernetesList.cs" />

View File

@@ -22,14 +22,14 @@
<Compile Include="..\KubernetesClient\Extensions.cs" />
<Compile Include="..\KubernetesClient\FloatEmitter.cs" />
<Compile Include="..\KubernetesClient\Models\GeneratedModelVersion.cs" />
<Compile Include="..\KubernetesClient\IItems.cs" />
<Compile Include="..\KubernetesClient\Models\IItems.cs" />
<Compile Include="..\KubernetesClient\IKubernetesObject.cs" />
<Compile Include="..\KubernetesClient\IMetadata.cs" />
<Compile Include="..\KubernetesClient\Models\IMetadata.cs" />
<Compile Include="..\KubernetesClient\Models\IntOrStringJsonConverter.cs" />
<Compile Include="..\KubernetesClient\Models\IntOrStringYamlConverter.cs" />
<Compile Include="..\KubernetesClient\Models\IntstrIntOrString.cs" />
<Compile Include="..\KubernetesClient\ISpec.cs" />
<Compile Include="..\KubernetesClient\IStatus.cs" />
<Compile Include="..\KubernetesClient\Models\ISpec.cs" />
<Compile Include="..\KubernetesClient\Models\IStatus.cs" />
<Compile Include="..\KubernetesClient\IValidate.cs" />
<Compile Include="..\KubernetesClient\Models\KubernetesEntityAttribute.cs" />
<Compile Include="..\KubernetesClient\KubernetesJson.cs" />

View File

@@ -1,28 +0,0 @@
namespace k8s
{
/// <summary>
/// Kubernetes object that exposes list of objects
/// </summary>
/// <typeparam name="T">type of the objects</typeparam>
public interface IItems<T>
{
/// <summary>
/// Gets or sets list of objects. More info:
/// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md
/// </summary>
IList<T> Items { get; set; }
}
public static class ItemsExt
{
public static IEnumerator<T> GetEnumerator<T>(this IItems<T> items)
{
if (items is null)
{
throw new ArgumentNullException(nameof(items));
}
return items.Items.GetEnumerator();
}
}
}

View File

@@ -1,16 +0,0 @@
namespace k8s
{
/// <summary>
/// Kubernetes object that exposes metadata
/// </summary>
/// <typeparam name="T">Type of metadata exposed. Usually this will be either
/// <see cref="V1ListMeta"/> for lists or <see cref="V1ObjectMeta"/> for objects</typeparam>
public interface IMetadata<T>
{
/// <summary>
/// Gets or sets standard object's metadata. More info:
/// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
/// </summary>
T Metadata { get; set; }
}
}

View File

@@ -1,16 +0,0 @@
namespace k8s
{
/// <summary>
/// Represents a Kubernetes object that has a spec
/// </summary>
/// <typeparam name="T">type of Kubernetes object</typeparam>
public interface ISpec<T>
{
/// <summary>
/// Gets or sets specification of the desired behavior of the entity. More
/// info:
/// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
/// </summary>
T Spec { get; set; }
}
}

View File

@@ -0,0 +1,27 @@
namespace k8s.Models;
/// <summary>
/// Kubernetes object that exposes list of objects
/// </summary>
/// <typeparam name="T">type of the objects</typeparam>
public interface IItems<T>
{
/// <summary>
/// Gets or sets list of objects. More info:
/// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md
/// </summary>
IList<T> Items { get; set; }
}
public static class ItemsExt
{
public static IEnumerator<T> GetEnumerator<T>(this IItems<T> items)
{
if (items is null)
{
throw new ArgumentNullException(nameof(items));
}
return items.Items.GetEnumerator();
}
}

View File

@@ -0,0 +1,15 @@
namespace k8s.Models;
/// <summary>
/// Kubernetes object that exposes metadata
/// </summary>
/// <typeparam name="T">Type of metadata exposed. Usually this will be either
/// <see cref="V1ListMeta"/> for lists or <see cref="V1ObjectMeta"/> for objects</typeparam>
public interface IMetadata<T>
{
/// <summary>
/// Gets or sets standard object's metadata. More info:
/// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
/// </summary>
T Metadata { get; set; }
}

View File

@@ -0,0 +1,15 @@
namespace k8s.Models;
/// <summary>
/// Represents a Kubernetes object that has a spec
/// </summary>
/// <typeparam name="T">type of Kubernetes object</typeparam>
public interface ISpec<T>
{
/// <summary>
/// Gets or sets specification of the desired behavior of the entity. More
/// info:
/// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
/// </summary>
T Spec { get; set; }
}

View File

@@ -1,4 +1,4 @@
namespace k8s
namespace k8s.Models
{
/// <summary>
/// Kubernetes object that exposes status