Skip to content

Commit 2d17bff

Browse files
authored
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.
1 parent 8a6cfe1 commit 2d17bff

File tree

197 files changed

+12222
-11602
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+12222
-11602
lines changed

.editorconfig

Lines changed: 401 additions & 401 deletions
Large diffs are not rendered by default.

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Normalize line endings in Git: https://www.aleksandrhovhannisyan.com/blog/crlf-vs-lf-normalizing-line-endings-in-git/
2+
* text=auto
3+
*.cs text eol=crlf
Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
name: Bug Report
2-
description: "Create a report to help fix a problem."
3-
title: "[bug]: "
4-
labels: ["bug"]
5-
body:
6-
- type: markdown
7-
attributes:
8-
value: |
9-
Thanks for taking the time to fill out this bug report!
10-
- type: textarea
11-
id: description
12-
attributes:
13-
label: Describe the bug
14-
description: A clear and concise description of what the bug is.
15-
validations:
16-
required: true
17-
- type: textarea
18-
id: reproduce
19-
attributes:
20-
label: To reproduce
21-
description: Steps to reproduce the behaviour
22-
placeholder: |
23-
Steps to reproduce the behavior:
24-
1. Go to '...'
25-
2. Click on '....'
26-
3. Scroll down to '....'
27-
4. See error
28-
validations:
29-
required: true
30-
- type: textarea
31-
id: expected
32-
attributes:
33-
label: Expected behavior
34-
description: A clear and concise description of what you expected to happen.
35-
- type: textarea
36-
id: screenshots
37-
attributes:
38-
label: Screenshots
39-
description: If applicable, add screenshots to help explain your problem.
40-
- type: textarea
41-
id: additional
42-
attributes:
43-
label: Additional Context
44-
description: Please add any other infos that could be useful.
1+
name: Bug Report
2+
description: "Create a report to help fix a problem."
3+
title: "[bug]: "
4+
labels: ["bug"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Thanks for taking the time to fill out this bug report!
10+
- type: textarea
11+
id: description
12+
attributes:
13+
label: Describe the bug
14+
description: A clear and concise description of what the bug is.
15+
validations:
16+
required: true
17+
- type: textarea
18+
id: reproduce
19+
attributes:
20+
label: To reproduce
21+
description: Steps to reproduce the behaviour
22+
placeholder: |
23+
Steps to reproduce the behavior:
24+
1. Go to '...'
25+
2. Click on '....'
26+
3. Scroll down to '....'
27+
4. See error
28+
validations:
29+
required: true
30+
- type: textarea
31+
id: expected
32+
attributes:
33+
label: Expected behavior
34+
description: A clear and concise description of what you expected to happen.
35+
- type: textarea
36+
id: screenshots
37+
attributes:
38+
label: Screenshots
39+
description: If applicable, add screenshots to help explain your problem.
40+
- type: textarea
41+
id: additional
42+
attributes:
43+
label: Additional Context
44+
description: Please add any other infos that could be useful.
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: Documentation
2-
description: "Suggest a topic that is not correctly documented (or not documented at all)"
3-
title: "[docs]: "
4-
labels: ["documentation"]
5-
body:
6-
- type: textarea
7-
id: description
8-
attributes:
9-
label: Describe the missing piece of documentation
10-
description: Describe what you miss in the docs (or what is wrong).
11-
validations:
12-
required: true
1+
name: Documentation
2+
description: "Suggest a topic that is not correctly documented (or not documented at all)"
3+
title: "[docs]: "
4+
labels: ["documentation"]
5+
body:
6+
- type: textarea
7+
id: description
8+
attributes:
9+
label: Describe the missing piece of documentation
10+
description: Describe what you miss in the docs (or what is wrong).
11+
validations:
12+
required: true
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
name: Feature Request
2-
description: "Suggest a new feature for this project."
3-
title: "[feature]: "
4-
labels: ["enhancement"]
5-
body:
6-
- type: markdown
7-
attributes:
8-
value: |
9-
Thanks for taking the time to fill out this feature request!
10-
- type: textarea
11-
id: description
12-
attributes:
13-
label: Is your feature request related to a problem? Please describe.
14-
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
15-
- type: textarea
16-
id: solution
17-
attributes:
18-
label: Describe the solution you would like
19-
description: A clear and concise description of what you want to happen.
20-
validations:
21-
required: true
22-
- type: textarea
23-
id: additional
24-
attributes:
25-
label: Additional Context
26-
description: Please add any other infos that could be useful.
1+
name: Feature Request
2+
description: "Suggest a new feature for this project."
3+
title: "[feature]: "
4+
labels: ["enhancement"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Thanks for taking the time to fill out this feature request!
10+
- type: textarea
11+
id: description
12+
attributes:
13+
label: Is your feature request related to a problem? Please describe.
14+
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
15+
- type: textarea
16+
id: solution
17+
attributes:
18+
label: Describe the solution you would like
19+
description: A clear and concise description of what you want to happen.
20+
validations:
21+
required: true
22+
- type: textarea
23+
id: additional
24+
attributes:
25+
label: Additional Context
26+
description: Please add any other infos that could be useful.

CONTRIBUTING.md

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
1-
# Contributing to KubeOps
2-
3-
First of all, thank you for considering contributing to KubeOps.
4-
This is an open souce project and shall be driven by the community.
5-
6-
This document describes how contributions may be done and what is required
7-
to develop on KubeOps.
8-
9-
## Creating/Reporting Issues
10-
11-
Feel free to open an issue in the [issues section](https://github.com/buehler/dotnet-operator-sdk/issues).
12-
There are three issue templates:
13-
- Bug: to report an issue/bug that prevents usage or is an inconvenience of KubeOps
14-
- Feature request: to report a new feature that would enhance KubeOps
15-
- Documentation: to report missing / wrong documentation
16-
17-
Please search through the already created issues to find similarities.
18-
19-
## Creating Pull Requests
20-
21-
To directly contribute to the solution, create a fork of the repository
22-
and implement your addition. Please keep in mind that reviewing takes some
23-
time and is not done instantly.
24-
25-
Please adhere to the linting rules and the general code style in the repository.
26-
Also, add tests for your changes to ensure that the system works well
27-
when other changes happen.
28-
29-
The PR can have any name, but it would be nice if you adhere to
30-
the repositories standard naming. Please name your PR
31-
with [Convential Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary).
32-
33-
**NOTE for breaking changes**: please state breaking changes
34-
in the PR description. The review process will be faster when
35-
breaking changes are well documented.
36-
37-
A few examples:
38-
- "fix: Null exception during watcher process"
39-
- "feat(core): Add new functionality"
40-
- "feat(testing): expose kubernetes client for testing"
41-
- "refactor: changed this and that"
42-
- "docs: Add docs about KubeOps core"
43-
44-
The PR will be squashed and merged into the default branch.
45-
46-
## Local Development
47-
48-
To setup a local development environment, you'll need to perform the follwing steps:
49-
50-
- Check out the repository (or your fork)
51-
- If you want to run the Operator locally, you'll need some Kubernetes instance.
52-
This can be any Kubernetes instance you'd like:
53-
- Local Kubernetes in Docker for Mac/Windows
54-
- minikube / any other local Kubernetes
55-
- Deployed Kubernetes (e.g. GCP Kubernetes instance)
56-
- You can now code your stuff.
57-
- `tests/KubeOps.TestOperator` is a developed small operator that can be run
58-
locally to test your implementations.
59-
- Write tests for your changes
60-
- Build the whole solution and check for linting errors / warnings.
61-
**NOTE** that any warning will result in an error when building
62-
with `Release` configuration.
63-
- Do not change the linting rules without creating a discussion/issue first.
1+
# Contributing to KubeOps
2+
3+
First of all, thank you for considering contributing to KubeOps.
4+
This is an open souce project and shall be driven by the community.
5+
6+
This document describes how contributions may be done and what is required
7+
to develop on KubeOps.
8+
9+
## Creating/Reporting Issues
10+
11+
Feel free to open an issue in the [issues section](https://github.com/buehler/dotnet-operator-sdk/issues).
12+
There are three issue templates:
13+
- Bug: to report an issue/bug that prevents usage or is an inconvenience of KubeOps
14+
- Feature request: to report a new feature that would enhance KubeOps
15+
- Documentation: to report missing / wrong documentation
16+
17+
Please search through the already created issues to find similarities.
18+
19+
## Creating Pull Requests
20+
21+
To directly contribute to the solution, create a fork of the repository
22+
and implement your addition. Please keep in mind that reviewing takes some
23+
time and is not done instantly.
24+
25+
Please adhere to the linting rules and the general code style in the repository.
26+
Also, add tests for your changes to ensure that the system works well
27+
when other changes happen.
28+
29+
The PR can have any name, but it would be nice if you adhere to
30+
the repositories standard naming. Please name your PR
31+
with [Convential Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary).
32+
33+
**NOTE for breaking changes**: please state breaking changes
34+
in the PR description. The review process will be faster when
35+
breaking changes are well documented.
36+
37+
A few examples:
38+
- "fix: Null exception during watcher process"
39+
- "feat(core): Add new functionality"
40+
- "feat(testing): expose kubernetes client for testing"
41+
- "refactor: changed this and that"
42+
- "docs: Add docs about KubeOps core"
43+
44+
The PR will be squashed and merged into the default branch.
45+
46+
## Local Development
47+
48+
To setup a local development environment, you'll need to perform the follwing steps:
49+
50+
- Check out the repository (or your fork)
51+
- If you want to run the Operator locally, you'll need some Kubernetes instance.
52+
This can be any Kubernetes instance you'd like:
53+
- Local Kubernetes in Docker for Mac/Windows
54+
- minikube / any other local Kubernetes
55+
- Deployed Kubernetes (e.g. GCP Kubernetes instance)
56+
- You can now code your stuff.
57+
- `tests/KubeOps.TestOperator` is a developed small operator that can be run
58+
locally to test your implementations.
59+
- Write tests for your changes
60+
- Build the whole solution and check for linting errors / warnings.
61+
**NOTE** that any warning will result in an error when building
62+
with `Release` configuration.
63+
- Do not change the linting rules without creating a discussion/issue first.
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
using ConversionWebhookOperator.Entities;
2-
3-
using KubeOps.Abstractions.Controller;
4-
using KubeOps.Abstractions.Rbac;
5-
6-
namespace ConversionWebhookOperator.Controller;
7-
8-
[EntityRbac(typeof(V1TestEntity), Verbs = RbacVerb.All)]
9-
public class V1TestEntityController(ILogger<V1TestEntityController> logger) : IEntityController<V1TestEntity>
10-
{
11-
public Task ReconcileAsync(V1TestEntity entity)
12-
{
13-
logger.LogInformation("Reconciling entity {Entity}.", entity);
14-
return Task.CompletedTask;
15-
}
16-
17-
public Task DeletedAsync(V1TestEntity entity)
18-
{
19-
logger.LogInformation("Deleted entity {Entity}.", entity);
20-
return Task.CompletedTask;
21-
}
22-
}
1+
using ConversionWebhookOperator.Entities;
2+
3+
using KubeOps.Abstractions.Controller;
4+
using KubeOps.Abstractions.Rbac;
5+
6+
namespace ConversionWebhookOperator.Controller;
7+
8+
[EntityRbac(typeof(V1TestEntity), Verbs = RbacVerb.All)]
9+
public class V1TestEntityController(ILogger<V1TestEntityController> logger) : IEntityController<V1TestEntity>
10+
{
11+
public Task ReconcileAsync(V1TestEntity entity, CancellationToken cancellationToken)
12+
{
13+
logger.LogInformation("Reconciling entity {Entity}.", entity);
14+
return Task.CompletedTask;
15+
}
16+
17+
public Task DeletedAsync(V1TestEntity entity, CancellationToken cancellationToken)
18+
{
19+
logger.LogInformation("Deleted entity {Entity}.", entity);
20+
return Task.CompletedTask;
21+
}
22+
}
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
using k8s.Models;
2-
3-
using KubeOps.Abstractions.Entities;
4-
5-
namespace ConversionWebhookOperator.Entities;
6-
7-
[KubernetesEntity(Group = "conversionwebhook.dev", ApiVersion = "v1", Kind = "TestEntity")]
8-
public partial class V1TestEntity : CustomKubernetesEntity<V1TestEntity.EntitySpec>
9-
{
10-
public override string ToString() => $"Test Entity v1 ({Metadata.Name}): {Spec.Name}";
11-
12-
public class EntitySpec
13-
{
14-
public string Name { get; set; } = string.Empty;
15-
}
16-
}
1+
using k8s.Models;
2+
3+
using KubeOps.Abstractions.Entities;
4+
5+
namespace ConversionWebhookOperator.Entities;
6+
7+
[KubernetesEntity(Group = "conversionwebhook.dev", ApiVersion = "v1", Kind = "TestEntity")]
8+
public partial class V1TestEntity : CustomKubernetesEntity<V1TestEntity.EntitySpec>
9+
{
10+
public override string ToString() => $"Test Entity v1 ({Metadata.Name}): {Spec.Name}";
11+
12+
public class EntitySpec
13+
{
14+
public string Name { get; set; } = string.Empty;
15+
}
16+
}

0 commit comments

Comments
 (0)