Skip to content
Draft
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
11 changes: 10 additions & 1 deletion Sources/ContainerResource/Container/ContainerSnapshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,25 @@ public struct ContainerSnapshot: Codable, Sendable {
public var networks: [Attachment]
/// When the container was started.
public var startedDate: Date?
/// The most recently observed health of the container.
///
/// At present the daemon does not run a container-level healthcheck
/// observer, so this field is always `nil`. The shape is reserved so that
/// downstream tools (e.g. `compose`) have a stable type to read from once
/// a healthcheck observer is wired into the API server.
public var health: HealthStatus?

public init(
configuration: ContainerConfiguration,
status: RuntimeStatus,
networks: [Attachment],
startedDate: Date? = nil
startedDate: Date? = nil,
health: HealthStatus? = nil
) {
self.configuration = configuration
self.status = status
self.networks = networks
self.startedDate = startedDate
self.health = health
}
}
35 changes: 35 additions & 0 deletions Sources/ContainerResource/Container/HealthStatus.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
// Copyright © 2026 Apple Inc. and the container project authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//===----------------------------------------------------------------------===//

import Foundation

/// The observed health status of a container, as derived from a periodic
/// healthcheck probe.
///
/// At present the daemon does not run a container-level healthcheck observer,
/// so ``ContainerSnapshot/health`` is always `nil`. This type is reserved for
/// downstream tools (e.g. `compose`) that want a stable shape to read from
/// once a healthcheck observer is wired into the API server.
public enum HealthStatus: String, CaseIterable, Sendable, Codable {
/// No healthcheck has been configured or no result is yet available.
case none
/// The healthcheck is running but has not yet produced a successful probe.
case starting
/// The most recent probe(s) reported the container as healthy.
case healthy
/// The most recent probe(s) reported the container as unhealthy.
case unhealthy
}