Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x' # Specify the .NET version you are using
dotnet-version: '10.0.x' # Specify the .NET version you are using

- name: Restore
run: dotnet restore ./cli
Expand Down
12 changes: 6 additions & 6 deletions cli/src/Vdk/Commands/AppCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

namespace Vdk.Commands;

public class AppCommand: RootCommand
public class AppCommand : RootCommand
{
public AppCommand(CreateCommand create, RemoveCommand remove, ListCommand list, InitializeCommand init, UpdateCommand update, IHubClient client) : base("Vega CLI - Manage Vega development environment")
{
AddCommand(create);
AddCommand(remove);
AddCommand(list);
AddCommand(init);
AddCommand(update);
Add(create);
Add(remove);
Add(list);
Add(init);
Add(update);
}
}
2 changes: 1 addition & 1 deletion cli/src/Vdk/Commands/CreateCloudProviderKindCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public CreateCloudProviderKindCommand(IConsole console, IHubClient client): base
{
_console = console;
_client = client;
this.SetHandler(InvokeAsync);
SetAction(_ => InvokeAsync());
}

public Task InvokeAsync()
Expand Down
39 changes: 24 additions & 15 deletions cli/src/Vdk/Commands/CreateClusterCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ namespace Vdk.Commands;

public class CreateClusterCommand : Command
{
private readonly Func<string, IKubernetesClient> _clientFunc;
private readonly GlobalConfiguration _configs;
private readonly IConsole _console;
private readonly IKindVersionInfoService _kindVersionInfo;
private readonly IYamlObjectSerializer _yaml;
private readonly IFileSystem _fileSystem;
private readonly IKindClient _kind;
private readonly IHubClient _hub;
private readonly IFluxClient _flux;
private readonly IHubClient _hub;
private readonly IKindClient _kind;
private readonly IKindVersionInfoService _kindVersionInfo;
private readonly IReverseProxyClient _reverseProxy;
private readonly Func<string, IKubernetesClient> _clientFunc;
private readonly GlobalConfiguration _configs;
private readonly IYamlObjectSerializer _yaml;

public CreateClusterCommand(
IConsole console,
Expand All @@ -45,15 +45,24 @@ public CreateClusterCommand(
_reverseProxy = reverseProxy;
_clientFunc = clientFunc;
_configs = configs;
var nameOption = new Option<string>(new[] { "-n", "--Name" }, () => Defaults.ClusterName, "The name of the kind cluster to create.");
var controlNodes = new Option<int>(new[] { "-c", "--ControlPlaneNodes" }, () => Defaults.ControlPlaneNodes, "The number of control plane nodes in the cluster.");
var workers = new Option<int>(new[] { "-w", "--Workers" }, () => Defaults.WorkerNodes, "The number of worker nodes in the cluster.");
var kubeVersion = new Option<string>(new[] { "-k", "--KubeVersion" }, () => "1.29", "The kubernetes api version.");
AddOption(nameOption);
AddOption(controlNodes);
AddOption(workers);
AddOption(kubeVersion);
this.SetHandler(InvokeAsync, nameOption, controlNodes, workers, kubeVersion);
var nameOption = new Option<string>("--Name") { DefaultValueFactory = _ => Defaults.ClusterName, Description = "The name of the kind cluster to create." };
nameOption.Aliases.Add("-n");
var controlNodes = new Option<int>("--ControlPlaneNodes") { DefaultValueFactory = _ => Defaults.ControlPlaneNodes, Description = "The number of control plane nodes in the cluster." };
controlNodes.Aliases.Add("-c");
var workers = new Option<int>("--Workers") { DefaultValueFactory = _ => Defaults.WorkerNodes, Description = "The number of worker nodes in the cluster." };
workers.Aliases.Add("-w");
var kubeVersion = new Option<string>("--KubeVersion") { DefaultValueFactory = _ => "1.29", Description = "The kubernetes api version." };
kubeVersion.Aliases.Add("-k");

Options.Add(nameOption);
Options.Add(controlNodes);
Options.Add(workers);
Options.Add(kubeVersion);
SetAction(parseResult => InvokeAsync(
parseResult.GetValue(nameOption) ?? Defaults.ClusterName,
parseResult.GetValue(controlNodes),
parseResult.GetValue(workers),
parseResult.GetValue(kubeVersion)));
}

public async Task InvokeAsync(string name = Defaults.ClusterName, int controlPlaneNodes = 1, int workerNodes = 2, string? kubeVersionRequested = null)
Expand Down
10 changes: 5 additions & 5 deletions cli/src/Vdk/Commands/CreateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ namespace Vdk.Commands;

public class CreateCommand: Command
{
public CreateCommand(CreateClusterCommand createCluster, CreateRegistryCommand createRegistry, CreateProxyCommand createProxy, CreateCloudProviderKindCommand createCloudProviderKindCommand)
public CreateCommand(CreateClusterCommand createCluster, CreateRegistryCommand createRegistry, CreateProxyCommand createProxy, CreateCloudProviderKindCommand createCloudProviderKindCommand)
: base("create", "Create vega development resources")
{
AddCommand(createCluster);
AddCommand(createRegistry);
AddCommand(createProxy);
AddCommand(createCloudProviderKindCommand);
Subcommands.Add(createCluster);
Subcommands.Add(createRegistry);
Subcommands.Add(createProxy);
Subcommands.Add(createCloudProviderKindCommand);
}
}
2 changes: 1 addition & 1 deletion cli/src/Vdk/Commands/CreateProxyCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public CreateProxyCommand(IConsole console, IReverseProxyClient client) : base("
{
_console = console;
_client = client;
this.SetHandler(InvokeAsync);
SetAction(_ => InvokeAsync());
}

public Task InvokeAsync()
Expand Down
2 changes: 1 addition & 1 deletion cli/src/Vdk/Commands/CreateRegistryCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public CreateRegistryCommand(IConsole console, IHubClient client): base("registr
{
_console = console;
_client = client;
this.SetHandler(InvokeAsync);
SetAction(_ => InvokeAsync());
}

public Task InvokeAsync()
Expand Down
2 changes: 1 addition & 1 deletion cli/src/Vdk/Commands/InitializeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public InitializeCommand(CreateClusterCommand createCluster, CreateProxyCommand
_kind = kind;
_console = console;
_kindVersionInfo = kindVersionInfo;
this.SetHandler(InvokeAsync);
SetAction(_ => InvokeAsync());
}

public async Task InvokeAsync()
Expand Down
2 changes: 1 addition & 1 deletion cli/src/Vdk/Commands/ListClustersCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public ListClustersCommand(IConsole console, IKindClient client) : base("cluster
{
_console = console;
_client = client;
this.SetHandler(InvokeAsync);
SetAction(_ => InvokeAsync());
}

public Task InvokeAsync()
Expand Down
4 changes: 2 additions & 2 deletions cli/src/Vdk/Commands/ListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class ListCommand: Command
{
public ListCommand(ListClustersCommand clustersCommand, ListKubernetesVersions kubernetesVersions) : base("list", "List Vega development resources")
{
AddCommand(clustersCommand);
AddCommand(kubernetesVersions);
Subcommands.Add(clustersCommand);
Subcommands.Add(kubernetesVersions);
}
}
2 changes: 1 addition & 1 deletion cli/src/Vdk/Commands/ListKubernetesVersions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public ListKubernetesVersions(IConsole console, IKindClient client, IKindVersion
_console = console;
_client = client;
_versionInfo = versionInfo;
this.SetHandler(InvokeAsync);
SetAction(_ => InvokeAsync());
}

public async Task InvokeAsync()
Expand Down
2 changes: 1 addition & 1 deletion cli/src/Vdk/Commands/RemoveCloudProviderKindCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public RemoveCloudProviderKindCommand(IConsole console, IHubClient client) : bas
{
_console = console;
_client = client;
this.SetHandler(InvokeAsync);
SetAction(_ => InvokeAsync());
}

public Task InvokeAsync()
Expand Down
7 changes: 4 additions & 3 deletions cli/src/Vdk/Commands/RemoveClusterCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ public RemoveClusterCommand(IConsole console, IKindClient kind) : base("cluster"
_console = console;
_kind = kind;

var nameOption = new Option<string>(new[] { "-n", "--Name" }, () => Defaults.ClusterName, "The name of the cluster to remove");
AddOption(nameOption);
this.SetHandler(InvokeAsync, nameOption);
var nameOption = new Option<string>("--Name") { DefaultValueFactory = _ => Defaults.ClusterName, Description = "The name of the cluster to remove" };
nameOption.Aliases.Add("-n");
Options.Add(nameOption);
SetAction(parseResult => InvokeAsync(parseResult.GetValue(nameOption) ?? Defaults.ClusterName));
}

public Task InvokeAsync(string name = Defaults.ClusterName)
Expand Down
8 changes: 4 additions & 4 deletions cli/src/Vdk/Commands/RemoveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ public class RemoveCommand: Command
public RemoveCommand(RemoveClusterCommand removeCluster, RemoveRegistryCommand removeRegistry, RemoveProxyCommand removeProxy, RemoveCloudProviderKindCommand removeCloudProviderKindCommand)
: base("remove", "Remove Vega development resources")
{
AddCommand(removeCluster);
AddCommand(removeRegistry);
AddCommand(removeProxy);
AddCommand(removeCloudProviderKindCommand);
Subcommands.Add(removeCluster);
Subcommands.Add(removeRegistry);
Subcommands.Add(removeProxy);
Subcommands.Add(removeCloudProviderKindCommand);
}
}
2 changes: 1 addition & 1 deletion cli/src/Vdk/Commands/RemoveProxyCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public RemoveProxyCommand(IConsole console, IReverseProxyClient client) : base("
{
_console = console;
_client = client;
this.SetHandler(InvokeAsync);
SetAction(_ => InvokeAsync());
}

public Task InvokeAsync()
Expand Down
2 changes: 1 addition & 1 deletion cli/src/Vdk/Commands/RemoveRegistryCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public RemoveRegistryCommand(IConsole console, IHubClient client) : base("regist
{
_console = console;
_client = client;
this.SetHandler(InvokeAsync);
SetAction(_ => InvokeAsync());
}

public Task InvokeAsync()
Expand Down
2 changes: 1 addition & 1 deletion cli/src/Vdk/Commands/UpdateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ public class UpdateCommand: Command
public UpdateCommand(UpdateKindVersionInfoCommand updateKindVersionInfo) : base("update",
"Update resources in vega development environment")
{
AddCommand(updateKindVersionInfo);
Subcommands.Add(updateKindVersionInfo);
}
}
2 changes: 1 addition & 1 deletion cli/src/Vdk/Commands/UpdateKindVersionInfoCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public UpdateKindVersionInfoCommand(IKindVersionInfoService client) : base("kind
"Update kind version info (Maps kind and Kubernetes versions/enables new releases of kubernetes in vega)")
{
_client = client;
this.SetHandler(InvokeAsync);
SetAction(_ => InvokeAsync());
}

public Task InvokeAsync()
Expand Down
4 changes: 2 additions & 2 deletions cli/src/Vdk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class Program
{
private static readonly IServiceProvider Services = ServiceProviderBuilder.Build();

static async Task Main(string[] args)
static async Task<int> Main(string[] args)
{
await Services.GetRequiredService<AppCommand>().InvokeAsync(args);
return await Services.GetRequiredService<AppCommand>().Parse(args).InvokeAsync();
}
}
48 changes: 24 additions & 24 deletions cli/src/Vdk/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"profiles": {
"update-kind": {
"commandName": "Project",
"commandLineArgs": "update kind-version-info"
},
"remove-proxy": {
"commandName": "Project",
"commandLineArgs": "remove proxy"
},
"create-proxy": {
"commandName": "Project",
"commandLineArgs": "create proxy"
},
"create-clutser": {
"commandName": "Project",
"commandLineArgs": "create cloud-provider-kind"
},
"WSL": {
"commandName": "WSL2",
"commandLineArgs": "{OutDir}vega.dll create cluster -n vdk-wsl",
"distributionName": ""
}
}
{
"profiles": {
"update-kind": {
"commandName": "Project",
"commandLineArgs": "update kind-version-info"
},
"remove-proxy": {
"commandName": "Project",
"commandLineArgs": "remove proxy"
},
"create-proxy": {
"commandName": "Project",
"commandLineArgs": "create proxy"
},
"create-clutser": {
"commandName": "Project",
"commandLineArgs": "create cloud-provider-kind"
},
"WSL": {
"commandName": "WSL2",
"commandLineArgs": "{OutDir}vega.dll create cluster -n vdk-wsl",
"distributionName": ""
}
}
}
8 changes: 4 additions & 4 deletions cli/src/Vdk/Services/ReverseProxyClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
if (tuple is { isVdk: true, master: not null } && tuple.master.HttpsHostPort.HasValue)
{
_console.WriteLine($" - Adding cluster {tuple.name} to reverse proxy configuration");
UpsertCluster(tuple.name, tuple.master.HttpsHostPort.Value, tuple.master.HttpHostPort.Value, false);

Check warning on line 63 in cli/src/Vdk/Services/ReverseProxyClient.cs

View workflow job for this annotation

GitHub Actions / build

Nullable value type may be null.
}
});
}
Expand Down Expand Up @@ -196,23 +196,23 @@
do
{
// check up to 10 times , waiting 5 seconds each time
ingressService = _client(clusterName).Get<V1Service>("ingress-nginx-controller", "ingress-nginx");
ingressService = _client(clusterName).Get<V1Service>("kgateway-system-kgateway", "kgateway-system");
if (ingressService == null)
{
_console.WriteLine("Waiting for ingress-nginx-controller service to be available...");
_console.WriteLine("Waiting for kgateway-system-kgateway service to be available...");
Thread.Sleep(5000);
attempts++;
}
else
{
_console.WriteLine("Ingress-nginx-controller service found.");
_console.WriteLine("kgateway-system-kgateway service found.");
break;
}
}
while (ingressService == null && attempts < 6);
if (ingressService == null)
{
_console.WriteError("Ingress-nginx-controller service not found. Please check the configuration and try again.");
_console.WriteError("kgateway-system-kgateway service not found. Please check the configuration and try again.");
return false;
}
var rewriteString = $" rewrite name {clusterName}.dev-k8s.cloud {ingressService.Name()}.{ingressService.Namespace()}.svc.cluster.local";
Expand Down
15 changes: 8 additions & 7 deletions cli/src/Vdk/Vdk.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>vega</AssemblyName>
Expand All @@ -19,14 +19,14 @@

<ItemGroup>
<PackageReference Include="Docker.DotNet" Version="3.125.15" />
<PackageReference Include="KubeOps.KubernetesClient" Version="9.10.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.7" />
<PackageReference Include="KubeOps.KubernetesClient" Version="10.2.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.2" />
<PackageReference Include="Octokit" Version="14.0.0" />
<PackageReference Include="SemanticVersion" Version="2.1.0" />
<PackageReference Include="Shell.NET" Version="0.2.2" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.IO.Abstractions" Version="22.0.15" />
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="22.0.15" />
<PackageReference Include="System.CommandLine" Version="2.0.2" />
<PackageReference Include="System.IO.Abstractions" Version="22.1.0" />
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="22.1.0" />
<PackageReference Include="YamlDotNet" Version="16.3.0" />
</ItemGroup>

Expand All @@ -43,3 +43,4 @@
</ItemGroup>

</Project>

Loading
Loading