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

[release/8.0-preview1] Make DCP internal. (#639) #651

Merged
merged 1 commit into from
Nov 2, 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
5 changes: 1 addition & 4 deletions samples/eShopLite/AppHost/aspire-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@
}
},
"messaging": {
"type": "azure.servicebus.v1",
"queues": [
"orders"
]
"type": "rabbitmq.server.v1"
},
"basketservice": {
"type": "project.v1",
Expand Down
11 changes: 0 additions & 11 deletions src/Aspire.Hosting/ApplicationModel/DcpResourceAnnotation.cs

This file was deleted.

8 changes: 2 additions & 6 deletions src/Aspire.Hosting/Dcp/ApplicationExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,7 @@ private async Task CreateExecutablesAsync(IEnumerable<AppResource> executableRes
spec.Env.Add(new EnvVar { Name = c.Key, Value = c.Value });
}

var createdExecutable = await createResource().ConfigureAwait(false);
var dcpResourceAnnotation = new DcpResourceAnnotation(createdExecutable.Metadata.NamespaceProperty, createdExecutable.Metadata.Name, createdExecutable.Kind);
er.ModelResource.Annotations.Add(dcpResourceAnnotation);
await createResource().ConfigureAwait(false);
}

}
Expand Down Expand Up @@ -552,9 +550,7 @@ private async Task CreateContainersAsync(IEnumerable<AppResource> containerResou
}
}

var createdContainer = await kubernetesService.CreateAsync(dcpContainerResource, cancellationToken).ConfigureAwait(false);
var dcpResourceAnnotation = new DcpResourceAnnotation(createdContainer.Metadata.NamespaceProperty, createdContainer.Metadata.Name, createdContainer.Kind);
cr.ModelResource.Annotations.Add(dcpResourceAnnotation);
await kubernetesService.CreateAsync(dcpContainerResource, cancellationToken).ConfigureAwait(false);
}
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Aspire.Hosting.Dcp;

public sealed class DcpDistributedApplicationLifecycleHook(IOptions<PublishingOptions> publishingOptions) : IDistributedApplicationLifecycleHook
internal sealed class DcpDistributedApplicationLifecycleHook(IOptions<PublishingOptions> publishingOptions) : IDistributedApplicationLifecycleHook
{
private readonly IOptions<PublishingOptions> _publishingOptions = publishingOptions;

Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Hosting/Dcp/DcpOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Aspire.Hosting.Dcp;

public sealed class DcpOptions
internal sealed class DcpOptions
{
private const string DcpCliPathMetadataKey = "DcpCliPath";
private const string DcpExtensionsPathMetadataKey = "DcpExtensionsPath";
Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Hosting/Dcp/KubernetesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Aspire.Hosting.Dcp;

public enum DcpApiOperationType
internal enum DcpApiOperationType
{
Create = 1,
List = 2,
Expand Down
44 changes: 22 additions & 22 deletions src/Aspire.Hosting/Dcp/Model/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Aspire.Hosting.Dcp.Model;

public class ContainerSpec
internal sealed class ContainerSpec
{
// Image to be used to create the container
[JsonPropertyName("image")]
Expand Down Expand Up @@ -42,16 +42,16 @@ public class ContainerSpec
public List<string>? Args { get; set; }
}

public static class VolumeMountType
internal static class VolumeMountType
{
// A volume mount to a host directory
public static readonly string Bind = "bind";
public const string Bind = "bind";

// A volume mount to a named volume managed by the container orchestrator
public static readonly string Named = "volume";
public const string Named = "volume";
}

public class VolumeMount
internal sealed class VolumeMount
{
[JsonPropertyName("type")]
public string Type { get; set; } = VolumeMountType.Bind;
Expand All @@ -70,22 +70,22 @@ public class VolumeMount
public bool IsReadOnly { get; set; } = false;
}

public static class ContainerRestartPolicy
internal static class ContainerRestartPolicy
{
// Do not automatically restart the container when it exits (default)
public static readonly string None = "no";
public const string None = "no";

// Restart only if the container exits with non-zero status
public static readonly string OnFailure = "on-failure";
public const string OnFailure = "on-failure";

// Restart container, except if container is explicitly stopped (or container daemon is stopped/restarted)
public static readonly string UnlessStopped = "unless-stopped";
public const string UnlessStopped = "unless-stopped";

// Always try to restart the container
public static readonly string Always = "always";
public const string Always = "always";
}

public static class PortProtocol
internal static class PortProtocol
{
public const string TCP = "TCP";

Expand Down Expand Up @@ -132,7 +132,7 @@ public static string FromProtocolType(ProtocolType protocolType)
}
}

public class ContainerPortSpec
internal sealed class ContainerPortSpec
{
// Optional: If specified, this must be a valid port number, 0 < x < 65536.
[JsonPropertyName("hostPort")]
Expand All @@ -151,7 +151,7 @@ public class ContainerPortSpec
public string? HostIP { get; set; }
}

public class ContainerStatus : V1Status
internal sealed class ContainerStatus : V1Status
{
// Current state of the Container.
[JsonPropertyName("state")]
Expand All @@ -178,31 +178,31 @@ public class ContainerStatus : V1Status
// It is provided by V1Status base class.
}

public static class ContainerState
internal static class ContainerState
{
// Pending is the initial Container state. No attempt has been made to run the container yet.
public static readonly string Pending = "Pending";
public const string Pending = "Pending";

// A start attempt was made, but it failed
public static readonly string FailedToStart = "FailedToStart";
public const string FailedToStart = "FailedToStart";

// Container has been started and is executing
public static readonly string Running = "Running";
public const string Running = "Running";

// Container is paused
public static readonly string Paused = "Paused";
public const string Paused = "Paused";

// Container finished execution
public static readonly string Exited = "Exited";
public const string Exited = "Exited";

// Container was running at some point, but has been removed.
public static readonly string Removed = "Removed";
public const string Removed = "Removed";

// Unknown means for some reason container state is unavailable.
public static readonly string Unknown = "Unknown";
public const string Unknown = "Unknown";
}

public class Container : CustomResource<ContainerSpec, ContainerStatus>
internal sealed class Container : CustomResource<ContainerSpec, ContainerStatus>
{
[JsonConstructor]
public Container(ContainerSpec spec) : base(spec) { }
Expand Down
6 changes: 3 additions & 3 deletions src/Aspire.Hosting/Dcp/Model/Endpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Aspire.Hosting.Dcp.Model;

public class EndpointSpec
internal sealed class EndpointSpec
{
// Namespace of the service the endpoint implements
[JsonPropertyName("serviceNamespace")]
Expand All @@ -25,12 +25,12 @@ public class EndpointSpec
public int? Port { get; set; }
}

public class EndpointStatus : V1Status
internal sealed class EndpointStatus : V1Status
{
// Currently Endpoint has no status properties, but that may change in future.
}

public class Endpoint : CustomResource<EndpointSpec, EndpointStatus>
internal sealed class Endpoint : CustomResource<EndpointSpec, EndpointStatus>
{
[JsonConstructor]
public Endpoint(EndpointSpec spec) : base(spec) { }
Expand Down
28 changes: 14 additions & 14 deletions src/Aspire.Hosting/Dcp/Model/Executable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Aspire.Hosting.Dcp.Model;
using System.Text.Json.Serialization;
using k8s.Models;

public class ExecutableSpec
internal sealed class ExecutableSpec
{
// Path to Executable binary
[JsonPropertyName("executablePath")]
Expand All @@ -33,16 +33,16 @@ public class ExecutableSpec
public string? ExecutionType { get; set; }
}

public static class ExecutionType
internal static class ExecutionType
{
// Executable will be run directly by the controller, as a child process
public static readonly string Process = "Process";
public const string Process = "Process";

// Executable will be run via an IDE such as Visual Studio or Visual Studio Code.
public static readonly string IDE = "IDE";
public const string IDE = "IDE";
}

public class ExecutableStatus : V1Status
internal sealed class ExecutableStatus : V1Status
{
// The execution ID is the identifier for the actual-state counterpart of the Executable.
// For ExecutionType == Process it is the process ID. Process IDs will be eventually reused by OS,
Expand Down Expand Up @@ -85,32 +85,32 @@ public class ExecutableStatus : V1Status

}

public static class ExecutableStates
internal static class ExecutableStates
{
// Executable was successfully started and was running last time we checked.
public static readonly string Running = "Running";
public const string Running = "Running";

// Terminated means the Executable was killed by the controller (e.g. as a result of scale-down, or object deletion).
public static readonly string Terminated = "Terminated";
public const string Terminated = "Terminated";

// Failed to start means the Executable could not be started (e.g. because of invalid path to program file).
public static readonly string FailedToStart = "FailedToStart";
public const string FailedToStart = "FailedToStart";

// Finished means the Executable ran to completion.
public static readonly string Finished = "Finished";
public const string Finished = "Finished";

// Unknown means we are not tracking the actual-state counterpart of the Executable (process or IDE run session).
// As a result, we do not know whether it already finished, and what is the exit code, if any.
// This can happen if a controller launches a process and then terminates.
// When a new controller instance comes online, it may see non-zero ExecutionID Status,
// but it does not track the corresponding process or IDE session.
public static readonly string Unknown = "Unknown";
public const string Unknown = "Unknown";
}

public class Executable : CustomResource<ExecutableSpec, ExecutableStatus>
internal sealed class Executable : CustomResource<ExecutableSpec, ExecutableStatus>
{
public static readonly string CSharpProjectPathAnnotation = "csharp-project-path";
public static readonly string LaunchProfileNameAnnotation = "launch-profile-name";
public const string CSharpProjectPathAnnotation = "csharp-project-path";
public const string LaunchProfileNameAnnotation = "launch-profile-name";

[JsonConstructor]
public Executable(ExecutableSpec spec) : base(spec) { }
Expand Down
8 changes: 4 additions & 4 deletions src/Aspire.Hosting/Dcp/Model/ExecutableReplicaSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Aspire.Hosting.Dcp.Model;
using System.Text.Json.Serialization;
using k8s.Models;

public class ExecutableTemplate : IAnnotationHolder
internal sealed class ExecutableTemplate : IAnnotationHolder
{
// Labels to apply to child Executable objects
[JsonPropertyName("labels")]
Expand Down Expand Up @@ -41,7 +41,7 @@ public void AnnotateAsObjectList<TValue>(string annotationName, TValue value)
}
}

public class ExecutableReplicaSetSpec
internal sealed class ExecutableReplicaSetSpec
{
// Number of desired child Executable objects
[JsonPropertyName("replicas")]
Expand All @@ -52,7 +52,7 @@ public class ExecutableReplicaSetSpec
public ExecutableTemplate Template { get; set; } = new ExecutableTemplate();
}

public class ExecutableReplicaSetStatus : V1Status
internal sealed class ExecutableReplicaSetStatus : V1Status
{
// Total number of observed child executables
[JsonPropertyName("observedReplicas")]
Expand All @@ -75,7 +75,7 @@ public class ExecutableReplicaSetStatus : V1Status
public DateTimeOffset? LastScaleTime { get; set; }
}

public class ExecutableReplicaSet : CustomResource<ExecutableReplicaSetSpec, ExecutableReplicaSetStatus>
internal sealed class ExecutableReplicaSet : CustomResource<ExecutableReplicaSetSpec, ExecutableReplicaSetStatus>
{
[JsonConstructor]
public ExecutableReplicaSet(ExecutableReplicaSetSpec spec) : base(spec) { }
Expand Down
4 changes: 2 additions & 2 deletions src/Aspire.Hosting/Dcp/Model/GroupVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

namespace Aspire.Hosting.Dcp.Model;

public struct GroupVersion
internal struct GroupVersion
{
public string Group { get; set; }
public string Version { get; set; }

public override string ToString() => $"{Group}/{Version}";
}

public static class Dcp
internal static class Dcp
{
public static GroupVersion GroupVersion { get; } = new GroupVersion
{
Expand Down
Loading