Skip to content

Commit

Permalink
feat(Webhooks): Make StatusCode/StatusMessage public. (#295)
Browse files Browse the repository at this point in the history
This fixes #288. `StatusCode`, `StatusMessage` and `Valid`
are now public members of the `AdmissionResult` instead of internal ones.
This may help in unit/integration testing webhooks.
  • Loading branch information
buehler committed Oct 11, 2021
1 parent 7789296 commit 2bd5166
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/KubeOps/Operator/Webhooks/AdmissionResult.cs
Expand Up @@ -12,19 +12,32 @@ internal AdmissionResult()
{
}

internal bool Valid { get; init; } = true;
/// <summary>
/// Determines if the result of the admission webhook is
/// either valid or invalid.
/// </summary>
public bool Valid { get; init; } = true;

/// <summary>
/// Provides a (http) status code for Kubernetes for an admission result.
/// This field may be used to provide additional information to the
/// user.
/// </summary>
public int? StatusCode { get; init; }

/// <summary>
/// Provide an additional status message for the admission result.
/// This provides additional information for the user.
/// </summary>
public string? StatusMessage { get; init; }

/// <summary>
/// Despite being "valid", the validation can add a list of warnings to the user.
/// If this is not yet supported by the cluster, the field is ignored.
/// Warnings may contain up to 256 characters but they should be limited to 120 characters.
/// If more than 4096 characters are submitted, additional messages are ignored.
/// </summary>
internal IList<string> Warnings { get; init; } = new List<string>();

internal int? StatusCode { get; init; }

internal string? StatusMessage { get; init; }
public IList<string> Warnings { get; init; } = new List<string>();

internal static TResult NotImplemented<TResult>()
where TResult : AdmissionResult, new() => new()
Expand Down

0 comments on commit 2bd5166

Please sign in to comment.