Skip to content

Commit 46299d1

Browse files
authored
Merge pull request #38 from ArchetypicalSoftware/feat/add_cloud_provider_kind
fix: add command to create cloud provider kind
2 parents 5e68fcb + d8b431d commit 46299d1

15 files changed

Lines changed: 145 additions & 18 deletions
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.CommandLine;
2+
using Vdk.Services;
3+
using IConsole = Vdk.Services.IConsole;
4+
5+
namespace Vdk.Commands;
6+
7+
public class CreateCloudProviderKindCommand: Command
8+
{
9+
private readonly IConsole _console;
10+
private readonly IHubClient _client;
11+
12+
public CreateCloudProviderKindCommand(IConsole console, IHubClient client): base("cloud-provider-kind", "Create Vega VDK Cloud Provider kind container registry")
13+
{
14+
_console = console;
15+
_client = client;
16+
this.SetHandler(InvokeAsync);
17+
}
18+
19+
public Task InvokeAsync()
20+
{
21+
_client.CreateCloudProviderKind();
22+
return Task.CompletedTask;
23+
}
24+
}

cli/src/Vdk/Commands/CreateClusterCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public async Task InvokeAsync(string name = Defaults.ClusterName, int controlPla
6161
// check if the hub and proxy are there
6262
if (!_reverseProxy.Exists())
6363
_reverseProxy.Create();
64-
if (!_hub.Exists())
65-
_hub.Create();
64+
if (!_hub.ExistRegistry())
65+
_hub.CreateRegistry();
6666

6767
var map = await _kindVersionInfo.GetVersionInfoAsync();
6868
string? kindVersion = null;

cli/src/Vdk/Commands/CreateCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ namespace Vdk.Commands;
44

55
public class CreateCommand: Command
66
{
7-
public CreateCommand(CreateClusterCommand createCluster, CreateRegistryCommand createRegistry, CreateProxyCommand createProxy)
7+
public CreateCommand(CreateClusterCommand createCluster, CreateRegistryCommand createRegistry, CreateProxyCommand createProxy, CreateCloudProviderKindCommand createCloudProviderKindCommand)
88
: base("create", "Create vega development resources")
99
{
1010
AddCommand(createCluster);
1111
AddCommand(createRegistry);
1212
AddCommand(createProxy);
13+
AddCommand(createCloudProviderKindCommand);
1314
}
1415
}

cli/src/Vdk/Commands/CreateRegistryCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public CreateRegistryCommand(IConsole console, IHubClient client): base("registr
1818

1919
public Task InvokeAsync()
2020
{
21-
_client.Create();
21+
_client.CreateRegistry();
2222
return Task.CompletedTask;
2323
}
2424
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.CommandLine;
2+
using Vdk.Services;
3+
using IConsole = Vdk.Services.IConsole;
4+
5+
namespace Vdk.Commands;
6+
7+
public class RemoveCloudProviderKindCommand: Command
8+
{
9+
private readonly IConsole _console;
10+
private readonly IHubClient _client;
11+
12+
public RemoveCloudProviderKindCommand(IConsole console, IHubClient client) : base("cloud-provider-kind", "Remove Vega VDK Cloud Provider Kind")
13+
{
14+
_console = console;
15+
_client = client;
16+
this.SetHandler(InvokeAsync);
17+
}
18+
19+
public Task InvokeAsync()
20+
{
21+
_client.DestroyCloudProviderKind();
22+
return Task.CompletedTask;
23+
}
24+
}

cli/src/Vdk/Commands/RemoveCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ namespace Vdk.Commands;
44

55
public class RemoveCommand: Command
66
{
7-
public RemoveCommand(RemoveClusterCommand removeCluster, RemoveRegistryCommand removeRegistry, RemoveProxyCommand removeProxy)
7+
public RemoveCommand(RemoveClusterCommand removeCluster, RemoveRegistryCommand removeRegistry, RemoveProxyCommand removeProxy, RemoveCloudProviderKindCommand removeCloudProviderKindCommand)
88
: base("remove", "Remove Vega development resources")
99
{
1010
AddCommand(removeCluster);
1111
AddCommand(removeRegistry);
1212
AddCommand(removeProxy);
13+
AddCommand(removeCloudProviderKindCommand);
1314
}
1415
}

cli/src/Vdk/Commands/RemoveRegistryCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public RemoveRegistryCommand(IConsole console, IHubClient client) : base("regist
1818

1919
public Task InvokeAsync()
2020
{
21-
_client.Destroy();
21+
_client.DestroyRegistry();
2222
return Task.CompletedTask;
2323
}
2424
}

cli/src/Vdk/Constants/Containers.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ public static class Containers
88
public const int RegistryHostPort = 5000;
99
public const string ProxyName = "vega-proxy";
1010
public const string ProxyImage = "nginx:latest";
11+
public const string CloudProviderKindName = "cloud-provider-kind";
12+
public const string CloudProviderKindImage = "registry.k8s.io/cloud-provider-kind/cloud-controller-manager:v0.6.0";
1113
}

cli/src/Vdk/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"create-clutser": {
1616
"commandName": "Project",
17-
"commandLineArgs": "create cluster"
17+
"commandLineArgs": "create cloud-provider-kind"
1818
},
1919
"WSL": {
2020
"commandName": "WSL2",

cli/src/Vdk/ServiceProviderBuilder.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ public static IServiceProvider Build()
4444
.AddSingleton<CreateProxyCommand>()
4545
.AddSingleton<RemoveProxyCommand>()
4646
.AddSingleton<CreateRegistryCommand>()
47+
.AddSingleton<CreateCloudProviderKindCommand>()
4748
.AddSingleton<RemoveRegistryCommand>()
49+
.AddSingleton<RemoveCloudProviderKindCommand>()
4850
.AddSingleton<UpdateCommand>()
4951
.AddSingleton<UpdateKindVersionInfoCommand>()
5052
.AddSingleton<IKindVersionInfoService, KindVersionInfoService>()

0 commit comments

Comments
 (0)