Class TypedSecret<TSecretData>
Extends a Kubernetes V1Secret to support strongly typed secrets. This is implemented by serializing the secret data as JSON and adding that to the low-level secret under the DataPropertyName key.
Namespace: Neon.Kube
Assembly: Neon.Kube.dll
Syntax
public class TypedSecret<TSecretData> where TSecretData : class, new()
Type Parameters
Name | Description |
---|---|
TSecretData | Specifies the secret data type. |
Remarks
To create a secret, use the TypedSecret(string, string, TSecretData) constructor, specifying the secret's Kubernetes name and namespace as well as an instance of the typesafe secret; your typed secret will be available as the Data property. Configure your secret as required and then call IKubernetes.CreateNamespacedTypedSecretAsync(), passing UntypedSecret as the request body (this holds the V1Secret).
To read an existing secret, call IKubernetes.CoreV1.ReadNamespacedTypedSecretAsync() to retrieve the Kubernetes secret and then call the static From(V1Secret) method to wrap the result into a TypedSecret<TSecretData> where your typesafe values can be accessed via the Data property.
To update an existing secret, call IKubernetes.CoreV1.ReadNamespacedTypedSecretAsync to retrieve it, modify it via the Data property and then call IKubernetes.CoreV1.ReplaceNamespacedTypedSecretAsync() passing the new UntypedSecret.
Constructors
TypedSecret(string, string, TSecretData)
Constructs a typed secret with the specified name and an optional initial value
TSecretData
value.
Declaration
public TypedSecret(string name, string @namespace, TSecretData data = null)
Parameters
Type | Name | Description |
---|---|---|
string | name | Specifies the secret name. |
string | namespace | specifies the namespace. |
TSecretData | data | Optionally specifies the secret data. A default instance will be created
when this is |
TypedSecret(V1Secret)
Constructs an instance from an untyped V1Secret.
Declaration
public TypedSecret(V1Secret untypedSecret)
Parameters
Type | Name | Description |
---|---|---|
V1Secret | untypedSecret | The secret name as it will be persisted to Kubernetes. |
Fields
DataPropertyName
Identifies the key used to store typed data within an untyped secret.
note
WARNING: DO NOT MODIFY! Any change will break existing clusters.
Declaration
public const string DataPropertyName = "typed-data"
Field Value
Type | Description |
---|---|
string |
Properties
Data
Specifies the current typed secret data.
Declaration
public TSecretData Data { get; set; }
Property Value
Type | Description |
---|---|
TSecretData |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the value being set is |
UntypedSecret
Returns the associated untyped secret.
Declaration
public V1Secret UntypedSecret { get; }
Property Value
Type | Description |
---|---|
V1Secret |
Methods
From(V1Secret)
Constructs an instance by parsing a V1Secret.
Declaration
public static TypedSecret<TSecretData> From(V1Secret untypedSecret)
Parameters
Type | Name | Description |
---|---|---|
V1Secret | untypedSecret | Specifies the untyped secret. |
Returns
Type | Description |
---|---|
TypedSecret<TSecretData> | The typed secret. |
Update()
Updates the secret by persisting any changes to Data back to the Kubernetes secret's DataPropertyName key.
Declaration
public void Update()