Files
csharp/examples/customResource/cResource.cs
Ali Kanso 0e3cb942d1 Custom Resource example (#540)
* CR example

* minor changes
2020-12-19 08:26:25 -08:00

36 lines
914 B
C#

using k8s.Models;
using System.Collections.Generic;
using k8s;
using Newtonsoft.Json;
namespace customResource
{
public class CResource : CustomResource<CResourceSpec, CResourceStatus>
{
public override string ToString()
{
var labels = "{";
foreach (var kvp in Metadata.Labels)
{
labels += kvp.Key + " : " + kvp.Value + ", ";
}
labels = labels.TrimEnd(',', ' ') + "}";
return $"{Metadata.Name} (Labels: {labels}), Spec: {Spec.CityName}";
}
}
public class CResourceSpec
{
[JsonProperty(PropertyName = "cityName")]
public string CityName { get; set; }
}
public class CResourceStatus : V1Status
{
[JsonProperty(PropertyName = "temperature", NullValueHandling = NullValueHandling.Ignore)]
public string Temperature { get; set; }
}
}