-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
CancellationToken
support and a lot of async improvements (#725)
This PR adds the ability to cancel (almost) all asynchronous operations with the built-in `CancellationToken`. Due to the nature of interfaces, almost all of those changes are breaking the existing API. It also adds an `WatchAsync` method to the `IKubernetesClient`, which is making use of the newer asynchronous enumerables. BREAKING CHANGE: Some methods do now feature the cancellation token which changed the method signature.
- Loading branch information
1 parent
8a6cfe1
commit 2d17bff
Showing
197 changed files
with
12,222 additions
and
11,602 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,3 @@ | ||
# Normalize line endings in Git: https://www.aleksandrhovhannisyan.com/blog/crlf-vs-lf-normalizing-line-endings-in-git/ | ||
* text=auto | ||
*.cs text eol=crlf |
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 |
---|---|---|
@@ -1,44 +1,44 @@ | ||
name: Bug Report | ||
description: "Create a report to help fix a problem." | ||
title: "[bug]: " | ||
labels: ["bug"] | ||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Thanks for taking the time to fill out this bug report! | ||
- type: textarea | ||
id: description | ||
attributes: | ||
label: Describe the bug | ||
description: A clear and concise description of what the bug is. | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: reproduce | ||
attributes: | ||
label: To reproduce | ||
description: Steps to reproduce the behaviour | ||
placeholder: | | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: expected | ||
attributes: | ||
label: Expected behavior | ||
description: A clear and concise description of what you expected to happen. | ||
- type: textarea | ||
id: screenshots | ||
attributes: | ||
label: Screenshots | ||
description: If applicable, add screenshots to help explain your problem. | ||
- type: textarea | ||
id: additional | ||
attributes: | ||
label: Additional Context | ||
description: Please add any other infos that could be useful. | ||
name: Bug Report | ||
description: "Create a report to help fix a problem." | ||
title: "[bug]: " | ||
labels: ["bug"] | ||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Thanks for taking the time to fill out this bug report! | ||
- type: textarea | ||
id: description | ||
attributes: | ||
label: Describe the bug | ||
description: A clear and concise description of what the bug is. | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: reproduce | ||
attributes: | ||
label: To reproduce | ||
description: Steps to reproduce the behaviour | ||
placeholder: | | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: expected | ||
attributes: | ||
label: Expected behavior | ||
description: A clear and concise description of what you expected to happen. | ||
- type: textarea | ||
id: screenshots | ||
attributes: | ||
label: Screenshots | ||
description: If applicable, add screenshots to help explain your problem. | ||
- type: textarea | ||
id: additional | ||
attributes: | ||
label: Additional Context | ||
description: Please add any other infos that could be useful. |
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
name: Documentation | ||
description: "Suggest a topic that is not correctly documented (or not documented at all)" | ||
title: "[docs]: " | ||
labels: ["documentation"] | ||
body: | ||
- type: textarea | ||
id: description | ||
attributes: | ||
label: Describe the missing piece of documentation | ||
description: Describe what you miss in the docs (or what is wrong). | ||
validations: | ||
required: true | ||
name: Documentation | ||
description: "Suggest a topic that is not correctly documented (or not documented at all)" | ||
title: "[docs]: " | ||
labels: ["documentation"] | ||
body: | ||
- type: textarea | ||
id: description | ||
attributes: | ||
label: Describe the missing piece of documentation | ||
description: Describe what you miss in the docs (or what is wrong). | ||
validations: | ||
required: true |
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 |
---|---|---|
@@ -1,26 +1,26 @@ | ||
name: Feature Request | ||
description: "Suggest a new feature for this project." | ||
title: "[feature]: " | ||
labels: ["enhancement"] | ||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Thanks for taking the time to fill out this feature request! | ||
- type: textarea | ||
id: description | ||
attributes: | ||
label: Is your feature request related to a problem? Please describe. | ||
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
- type: textarea | ||
id: solution | ||
attributes: | ||
label: Describe the solution you would like | ||
description: A clear and concise description of what you want to happen. | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: additional | ||
attributes: | ||
label: Additional Context | ||
description: Please add any other infos that could be useful. | ||
name: Feature Request | ||
description: "Suggest a new feature for this project." | ||
title: "[feature]: " | ||
labels: ["enhancement"] | ||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Thanks for taking the time to fill out this feature request! | ||
- type: textarea | ||
id: description | ||
attributes: | ||
label: Is your feature request related to a problem? Please describe. | ||
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
- type: textarea | ||
id: solution | ||
attributes: | ||
label: Describe the solution you would like | ||
description: A clear and concise description of what you want to happen. | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: additional | ||
attributes: | ||
label: Additional Context | ||
description: Please add any other infos that could be useful. |
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 |
---|---|---|
@@ -1,63 +1,63 @@ | ||
# Contributing to KubeOps | ||
|
||
First of all, thank you for considering contributing to KubeOps. | ||
This is an open souce project and shall be driven by the community. | ||
|
||
This document describes how contributions may be done and what is required | ||
to develop on KubeOps. | ||
|
||
## Creating/Reporting Issues | ||
|
||
Feel free to open an issue in the [issues section](https://github.com/buehler/dotnet-operator-sdk/issues). | ||
There are three issue templates: | ||
- Bug: to report an issue/bug that prevents usage or is an inconvenience of KubeOps | ||
- Feature request: to report a new feature that would enhance KubeOps | ||
- Documentation: to report missing / wrong documentation | ||
|
||
Please search through the already created issues to find similarities. | ||
|
||
## Creating Pull Requests | ||
|
||
To directly contribute to the solution, create a fork of the repository | ||
and implement your addition. Please keep in mind that reviewing takes some | ||
time and is not done instantly. | ||
|
||
Please adhere to the linting rules and the general code style in the repository. | ||
Also, add tests for your changes to ensure that the system works well | ||
when other changes happen. | ||
|
||
The PR can have any name, but it would be nice if you adhere to | ||
the repositories standard naming. Please name your PR | ||
with [Convential Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary). | ||
|
||
**NOTE for breaking changes**: please state breaking changes | ||
in the PR description. The review process will be faster when | ||
breaking changes are well documented. | ||
|
||
A few examples: | ||
- "fix: Null exception during watcher process" | ||
- "feat(core): Add new functionality" | ||
- "feat(testing): expose kubernetes client for testing" | ||
- "refactor: changed this and that" | ||
- "docs: Add docs about KubeOps core" | ||
|
||
The PR will be squashed and merged into the default branch. | ||
|
||
## Local Development | ||
|
||
To setup a local development environment, you'll need to perform the follwing steps: | ||
|
||
- Check out the repository (or your fork) | ||
- If you want to run the Operator locally, you'll need some Kubernetes instance. | ||
This can be any Kubernetes instance you'd like: | ||
- Local Kubernetes in Docker for Mac/Windows | ||
- minikube / any other local Kubernetes | ||
- Deployed Kubernetes (e.g. GCP Kubernetes instance) | ||
- You can now code your stuff. | ||
- `tests/KubeOps.TestOperator` is a developed small operator that can be run | ||
locally to test your implementations. | ||
- Write tests for your changes | ||
- Build the whole solution and check for linting errors / warnings. | ||
**NOTE** that any warning will result in an error when building | ||
with `Release` configuration. | ||
- Do not change the linting rules without creating a discussion/issue first. | ||
# Contributing to KubeOps | ||
|
||
First of all, thank you for considering contributing to KubeOps. | ||
This is an open souce project and shall be driven by the community. | ||
|
||
This document describes how contributions may be done and what is required | ||
to develop on KubeOps. | ||
|
||
## Creating/Reporting Issues | ||
|
||
Feel free to open an issue in the [issues section](https://github.com/buehler/dotnet-operator-sdk/issues). | ||
There are three issue templates: | ||
- Bug: to report an issue/bug that prevents usage or is an inconvenience of KubeOps | ||
- Feature request: to report a new feature that would enhance KubeOps | ||
- Documentation: to report missing / wrong documentation | ||
|
||
Please search through the already created issues to find similarities. | ||
|
||
## Creating Pull Requests | ||
|
||
To directly contribute to the solution, create a fork of the repository | ||
and implement your addition. Please keep in mind that reviewing takes some | ||
time and is not done instantly. | ||
|
||
Please adhere to the linting rules and the general code style in the repository. | ||
Also, add tests for your changes to ensure that the system works well | ||
when other changes happen. | ||
|
||
The PR can have any name, but it would be nice if you adhere to | ||
the repositories standard naming. Please name your PR | ||
with [Convential Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary). | ||
|
||
**NOTE for breaking changes**: please state breaking changes | ||
in the PR description. The review process will be faster when | ||
breaking changes are well documented. | ||
|
||
A few examples: | ||
- "fix: Null exception during watcher process" | ||
- "feat(core): Add new functionality" | ||
- "feat(testing): expose kubernetes client for testing" | ||
- "refactor: changed this and that" | ||
- "docs: Add docs about KubeOps core" | ||
|
||
The PR will be squashed and merged into the default branch. | ||
|
||
## Local Development | ||
|
||
To setup a local development environment, you'll need to perform the follwing steps: | ||
|
||
- Check out the repository (or your fork) | ||
- If you want to run the Operator locally, you'll need some Kubernetes instance. | ||
This can be any Kubernetes instance you'd like: | ||
- Local Kubernetes in Docker for Mac/Windows | ||
- minikube / any other local Kubernetes | ||
- Deployed Kubernetes (e.g. GCP Kubernetes instance) | ||
- You can now code your stuff. | ||
- `tests/KubeOps.TestOperator` is a developed small operator that can be run | ||
locally to test your implementations. | ||
- Write tests for your changes | ||
- Build the whole solution and check for linting errors / warnings. | ||
**NOTE** that any warning will result in an error when building | ||
with `Release` configuration. | ||
- Do not change the linting rules without creating a discussion/issue first. |
44 changes: 22 additions & 22 deletions
44
examples/ConversionWebhookOperator/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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
using ConversionWebhookOperator.Entities; | ||
|
||
using KubeOps.Abstractions.Controller; | ||
using KubeOps.Abstractions.Rbac; | ||
|
||
namespace ConversionWebhookOperator.Controller; | ||
|
||
[EntityRbac(typeof(V1TestEntity), Verbs = RbacVerb.All)] | ||
public class V1TestEntityController(ILogger<V1TestEntityController> logger) : IEntityController<V1TestEntity> | ||
{ | ||
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; | ||
} | ||
} | ||
using ConversionWebhookOperator.Entities; | ||
|
||
using KubeOps.Abstractions.Controller; | ||
using KubeOps.Abstractions.Rbac; | ||
|
||
namespace ConversionWebhookOperator.Controller; | ||
|
||
[EntityRbac(typeof(V1TestEntity), Verbs = RbacVerb.All)] | ||
public class V1TestEntityController(ILogger<V1TestEntityController> logger) : IEntityController<V1TestEntity> | ||
{ | ||
public Task ReconcileAsync(V1TestEntity entity, CancellationToken cancellationToken) | ||
{ | ||
logger.LogInformation("Reconciling entity {Entity}.", entity); | ||
return Task.CompletedTask; | ||
} | ||
|
||
public Task DeletedAsync(V1TestEntity entity, CancellationToken cancellationToken) | ||
{ | ||
logger.LogInformation("Deleted entity {Entity}.", entity); | ||
return Task.CompletedTask; | ||
} | ||
} |
32 changes: 16 additions & 16 deletions
32
examples/ConversionWebhookOperator/Entities/V1TestEntity.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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
using k8s.Models; | ||
|
||
using KubeOps.Abstractions.Entities; | ||
|
||
namespace ConversionWebhookOperator.Entities; | ||
|
||
[KubernetesEntity(Group = "conversionwebhook.dev", ApiVersion = "v1", Kind = "TestEntity")] | ||
public partial class V1TestEntity : CustomKubernetesEntity<V1TestEntity.EntitySpec> | ||
{ | ||
public override string ToString() => $"Test Entity v1 ({Metadata.Name}): {Spec.Name}"; | ||
|
||
public class EntitySpec | ||
{ | ||
public string Name { get; set; } = string.Empty; | ||
} | ||
} | ||
using k8s.Models; | ||
|
||
using KubeOps.Abstractions.Entities; | ||
|
||
namespace ConversionWebhookOperator.Entities; | ||
|
||
[KubernetesEntity(Group = "conversionwebhook.dev", ApiVersion = "v1", Kind = "TestEntity")] | ||
public partial class V1TestEntity : CustomKubernetesEntity<V1TestEntity.EntitySpec> | ||
{ | ||
public override string ToString() => $"Test Entity v1 ({Metadata.Name}): {Spec.Name}"; | ||
|
||
public class EntitySpec | ||
{ | ||
public string Name { get; set; } = string.Empty; | ||
} | ||
} |
Oops, something went wrong.