Skip to content

Commit

Permalink
Merge pull request #116 from neuroglia-io/fix-resource-oriented-admis…
Browse files Browse the repository at this point in the history
…sion-problems

Fix the ResourceAdmissionControl to properly document errors that have occured during admission of evaluated resources
  • Loading branch information
cdavernas authored Oct 9, 2024
2 parents d72da38 + 1b69c14 commit cf8684a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
<value>Namespaced resource must reference a valid namespace</value>
</data>
<data name="ResourceAdmissionFailed" xml:space="preserve">
<value>Failed to admit operation '{operation}' the specified resource '{resource}':\n{errors}</value>
<value>Failed to admit operation '{operation}' on the specified resource '{resource}':\r\n{errors}</value>
</data>
<data name="ResourceAlreadyExists" xml:space="preserve">
<value>The specified resource '{resource}' already exists</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected virtual async Task<AdmissionReviewResponse> ValidateAsync(AdmissionRev

var results = tasks.Select(t => t.Result);
if (results.All(t => t.Allowed)) return new(request.Uid, true);
else return new(request.Uid, false, null, new ProblemDetails(ProblemTypes.AdmissionFailed, ProblemTitles.AdmissionFailed, (int)HttpStatusCode.BadRequest, errors: results.Where(r => !r.Allowed && r.Problem != null && r.Problem.Errors != null).SelectMany(r => r.Problem!.Errors!).ToDictionary(e => e.Key, e => e.Value)));
else return new(request.Uid, false, null, new ProblemDetails(ProblemTypes.AdmissionFailed, ProblemTitles.AdmissionFailed, (int)HttpStatusCode.BadRequest, errors: results.Where(r => !r.Allowed && r.Problem != null).Select(r => r.Problem!).ToDictionary(p => $"[{p.Status} - {p.Title ?? p.Type?.OriginalString ?? "Unknown"}]", p => new string[] { p.Detail! })));
}

}

0 comments on commit cf8684a

Please sign in to comment.