Skip to content

Commit b05b43b

Browse files
author
Christoph Bühler
committed
test: add testing operator to run with entities
1 parent 9456c74 commit b05b43b

File tree

5 files changed

+63
-0
lines changed

5 files changed

+63
-0
lines changed

DotnetOperatorSdk.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.cspr
1212
EndProject
1313
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{9AF95FE4-DA1F-4BB0-B60E-23FCFA6AAAA2}"
1414
EndProject
15+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KubeOps.TestOperator", "tests\KubeOps.TestOperator\KubeOps.TestOperator.csproj", "{751BDC14-D75F-4DDE-9C45-2432041FBCAC}"
16+
EndProject
1517
Global
1618
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1719
Debug|Any CPU = Debug|Any CPU
@@ -28,10 +30,15 @@ Global
2830
{A33D30D0-AC1B-48F8-8A5A-36E569981793}.Debug|Any CPU.Build.0 = Debug|Any CPU
2931
{A33D30D0-AC1B-48F8-8A5A-36E569981793}.Release|Any CPU.ActiveCfg = Release|Any CPU
3032
{A33D30D0-AC1B-48F8-8A5A-36E569981793}.Release|Any CPU.Build.0 = Release|Any CPU
33+
{751BDC14-D75F-4DDE-9C45-2432041FBCAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34+
{751BDC14-D75F-4DDE-9C45-2432041FBCAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
35+
{751BDC14-D75F-4DDE-9C45-2432041FBCAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
36+
{751BDC14-D75F-4DDE-9C45-2432041FBCAC}.Release|Any CPU.Build.0 = Release|Any CPU
3137
EndGlobalSection
3238
GlobalSection(NestedProjects) = preSolution
3339
{D7AB6CB9-94B6-4FEB-B7D8-D8AA793BD2A4} = {95F3A6DD-B421-441D-B263-1B34A1465FF5}
3440
{A33D30D0-AC1B-48F8-8A5A-36E569981793} = {50E9B964-68F7-4B9F-BEA8-165CE45BC5C6}
3541
{D47717CB-A02E-4B12-BAA8-1D7F8BAE9BBD} = {9AF95FE4-DA1F-4BB0-B60E-23FCFA6AAAA2}
42+
{751BDC14-D75F-4DDE-9C45-2432041FBCAC} = {50E9B964-68F7-4B9F-BEA8-165CE45BC5C6}
3643
EndGlobalSection
3744
EndGlobal
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using KubeOps.Operator.Controller;
2+
using KubeOps.Operator.Rbac;
3+
using KubeOps.TestOperator.Entities;
4+
5+
namespace KubeOps.TestOperator.Controller
6+
{
7+
[EntityRbac(typeof(TestEntity), Verbs = RbacVerb.All)]
8+
public class TestController : ResourceControllerBase<TestEntity>
9+
{
10+
}
11+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using k8s.Models;
2+
using KubeOps.Operator.Entities;
3+
4+
namespace KubeOps.TestOperator.Entities
5+
{
6+
public class TestEntitySpec
7+
{
8+
public string Spec { get; set; } = string.Empty;
9+
}
10+
11+
public class TestEntityStatus
12+
{
13+
public string Status { get; set; } = string.Empty;
14+
}
15+
16+
[KubernetesEntity(Group = "testing", ApiVersion = "v1")]
17+
public class TestEntity : CustomKubernetesEntity<TestEntitySpec, TestEntityStatus>
18+
{
19+
}
20+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<ProjectReference Include="..\..\src\KubeOps\KubeOps.csproj" />
10+
</ItemGroup>
11+
12+
</Project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using KubeOps.Operator;
2+
using KubeOps.TestOperator.Controller;
3+
using KubeOps.TestOperator.Entities;
4+
5+
namespace KubeOps.TestOperator
6+
{
7+
public static class Program
8+
{
9+
public static void Main(string[] args) => new KubernetesOperator()
10+
.ConfigureServices(services => { services.AddResourceController<TestController, TestEntity>(); })
11+
.Run(args);
12+
}
13+
}

0 commit comments

Comments
 (0)