Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency between K8s service and dashboard #109

Merged
merged 1 commit into from
Oct 6, 2023
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
10 changes: 7 additions & 3 deletions src/Aspire.Hosting/Dashboard/DashboardViewModelService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Aspire.Hosting.Dcp;
using Aspire.Hosting.Dcp.Model;
using k8s;
using NamespacedName = Aspire.Dashboard.Model.NamespacedName;

namespace Aspire.Hosting.Dashboard;

Expand Down Expand Up @@ -46,7 +47,8 @@ public async IAsyncEnumerable<ComponentChanged<ContainerViewModel>> WatchContain
IEnumerable<NamespacedName>? existingContainers = null,
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
await foreach (var (watchEventType, container) in _kubernetesService.WatchAsync<Container>(existingObjects: existingContainers, cancellationToken: cancellationToken))
var existingObjects = existingContainers?.Select(ec => new Dcp.Model.NamespacedName(ec.Name, ec.Namespace));
await foreach (var (watchEventType, container) in _kubernetesService.WatchAsync<Container>(existingObjects: existingObjects, cancellationToken: cancellationToken))
{
var objectChangeType = ToObjectChangeType(watchEventType);
if (objectChangeType == ObjectChangeType.Other)
Expand All @@ -64,7 +66,8 @@ public async IAsyncEnumerable<ComponentChanged<ExecutableViewModel>> WatchExecut
IEnumerable<NamespacedName>? existingExecutables = null,
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
await foreach (var (watchEventType, executable) in _kubernetesService.WatchAsync<Executable>(existingObjects: existingExecutables, cancellationToken: cancellationToken))
var existingObjects = existingExecutables?.Select(ec => new Dcp.Model.NamespacedName(ec.Name, ec.Namespace));
await foreach (var (watchEventType, executable) in _kubernetesService.WatchAsync<Executable>(existingObjects: existingObjects, cancellationToken: cancellationToken))
{
var objectChangeType = ToObjectChangeType(watchEventType);
if (objectChangeType == ObjectChangeType.Other)
Expand All @@ -87,7 +90,8 @@ public async IAsyncEnumerable<ComponentChanged<ProjectViewModel>> WatchProjectsA
IEnumerable<NamespacedName>? existingProjects = null,
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
await foreach (var (watchEventType, executable) in _kubernetesService.WatchAsync<Executable>(existingObjects: existingProjects, cancellationToken: cancellationToken))
var existingObjects = existingProjects?.Select(ec => new Dcp.Model.NamespacedName(ec.Name, ec.Namespace));
await foreach (var (watchEventType, executable) in _kubernetesService.WatchAsync<Executable>(existingObjects: existingObjects, cancellationToken: cancellationToken))
{
var objectChangeType = ToObjectChangeType(watchEventType);
if (objectChangeType == ObjectChangeType.Other)
Expand Down
1 change: 0 additions & 1 deletion src/Aspire.Hosting/Dcp/KubernetesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.CompilerServices;
using Aspire.Dashboard.Model;
using Aspire.Hosting.Dcp.Model;
using k8s;
using k8s.Exceptions;
Expand Down
2 changes: 2 additions & 0 deletions src/Aspire.Hosting/Dcp/Model/ModelCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ public override int GetHashCode()
}
}

public sealed record NamespacedName(string Name, string? Namespace);

public static class Rules
{
public static bool IsValidObjectName(string candidate)
Expand Down