-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web-operator): Add validation webhooks. (#631)
BREAKING CHANGE: This overhauls the way webhooks worked. Webhooks now run with normal ASP.net ApiControllers. To use a webhook, refer to the documentation. Basically, create a subclass of the validation webhook class and decorate it with the correct validation attribute. Then, the webhook will run. Other elements like automatic install will follow this preview release.
- Loading branch information
Showing
78 changed files
with
3,067 additions
and
2,156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
examples/UserConfigOperator/Controller/V1UserConfigController.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
examples/WebhookOperator/Controller/V1TestEntityController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using KubeOps.Abstractions.Controller; | ||
using KubeOps.Abstractions.Rbac; | ||
|
||
using WebhookOperator.Entities; | ||
|
||
namespace WebhookOperator.Controller; | ||
|
||
[EntityRbac(typeof(V1TestEntity), Verbs = RbacVerb.All)] | ||
public class V1TestEntityController : IEntityController<V1TestEntity> | ||
{ | ||
private readonly ILogger<V1TestEntityController> _logger; | ||
|
||
public V1TestEntityController( | ||
ILogger<V1TestEntityController> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public Task ReconcileAsync(V1TestEntity entity) | ||
{ | ||
_logger.LogInformation("Reconciling entity {Entity}.", entity); | ||
return Task.CompletedTask; | ||
} | ||
|
||
public Task DeletedAsync(V1TestEntity entity) | ||
{ | ||
_logger.LogInformation("Deleted entity {Entity}.", entity); | ||
return Task.CompletedTask; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using k8s.Models; | ||
|
||
using KubeOps.Abstractions.Entities; | ||
|
||
namespace WebhookOperator.Entities; | ||
|
||
[KubernetesEntity(Group = "webhook.dev", ApiVersion = "v1", Kind = "TestEntity")] | ||
public partial class V1TestEntity : CustomKubernetesEntity<V1TestEntity.EntitySpec> | ||
{ | ||
public override string ToString() => $"Test Entity ({Metadata.Name}): {Spec.Username}"; | ||
|
||
public class EntitySpec | ||
{ | ||
public string Username { get; set; } = string.Empty; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using KubeOps.Operator; | ||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
builder.Services | ||
.AddKubernetesOperator() | ||
.RegisterComponents(); | ||
|
||
builder.Services | ||
.AddControllers(); | ||
|
||
var app = builder.Build(); | ||
|
||
app.UseRouting(); | ||
app.UseDeveloperExceptionPage(); | ||
app.MapControllers(); | ||
|
||
await app.RunAsync(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"profiles": { | ||
"WebhookOperator": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"applicationUrl": "http://localhost:5000", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.