-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathContainerServiceCreateAdapter.swift
More file actions
154 lines (146 loc) · 5.5 KB
/
Copy pathContainerServiceCreateAdapter.swift
File metadata and controls
154 lines (146 loc) · 5.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//===----------------------------------------------------------------------===//
// Copyright © 2026 container-compose 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.
//===----------------------------------------------------------------------===//
/// User-visible service identity fields for create planning.
public struct ContainerServiceCreateIdentity: Sendable {
public var name: String
public var imageReference: String
public var oneOff: Bool
public var autoRemove: Bool
public var labels: [String: String]
public var annotations: [String: String]
public var exposedPorts: [String]
public init(
name: String,
imageReference: String,
oneOff: Bool = false,
autoRemove: Bool = false,
labels: [String: String] = [:],
annotations: [String: String] = [:],
exposedPorts: [String] = [],
) {
self.name = name
self.imageReference = imageReference
self.oneOff = oneOff
self.autoRemove = autoRemove
self.labels = labels
self.annotations = annotations
self.exposedPorts = exposedPorts
}
}
/// Runtime-specific service create fields.
public struct ContainerServiceCreateRuntime: Sendable {
public var initProcess: ComposeProcessConfiguration
public var logging: ComposeLogConfiguration
public var healthCheck: ComposeHealthCheck?
public var restartPolicy: ComposeRestartPolicy
public var hostname: String?
public var domainname: String?
public var hosts: [ComposeHostEntry]
public var sysctls: [String: String]
public var blockIO: ComposeLinuxBlockIO?
public var cpuShares: UInt64?
public var cgroupParent: String?
public var memoryReservationInBytes: Int64?
public var memorySwapLimitInBytes: Int64?
public init() {
initProcess = ComposeRuntimeDefaults.shellProcess()
logging = ComposeLogConfiguration.standard
healthCheck = nil
restartPolicy = ComposeRestartPolicy.no
hostname = nil
domainname = nil
hosts = []
sysctls = [:]
blockIO = nil
cpuShares = nil
cgroupParent = nil
memoryReservationInBytes = nil
memorySwapLimitInBytes = nil
}
}
/// Compose-owned typed create-time values for a service container.
///
/// This is the boundary that lets Docker/Compose syntax stay in
/// `container-compose` while later execution code can create containers through
/// apple/container typed APIs instead of Docker-shaped CLI flags.
public struct ContainerServiceCreatePlan: Sendable {
public var name: String
public var imageReference: String
public var oneOff: Bool
public var autoRemove: Bool
public var labels: [String: String]
public var annotations: [String: String]
public var exposedPorts: [String]
public var initProcess: ComposeProcessConfiguration
public var logging: ComposeLogConfiguration
public var healthCheck: ComposeHealthCheck?
public var restartPolicy: ComposeRestartPolicy
public var hostname: String?
public var domainname: String?
public var hosts: [ComposeHostEntry]
public var sysctls: [String: String]
public var blockIO: ComposeLinuxBlockIO?
public var cpuShares: UInt64?
public var cgroupParent: String?
public var memoryReservationInBytes: Int64?
public var memorySwapLimitInBytes: Int64?
public init(
identity: ContainerServiceCreateIdentity,
runtime: ContainerServiceCreateRuntime = ContainerServiceCreateRuntime(),
) {
name = identity.name
imageReference = identity.imageReference
oneOff = identity.oneOff
autoRemove = identity.autoRemove
labels = identity.labels
annotations = identity.annotations
exposedPorts = identity.exposedPorts
initProcess = runtime.initProcess
logging = runtime.logging
healthCheck = runtime.healthCheck
restartPolicy = runtime.restartPolicy
hostname = runtime.hostname
domainname = runtime.domainname
hosts = runtime.hosts
sysctls = runtime.sysctls
blockIO = runtime.blockIO
cpuShares = runtime.cpuShares
cgroupParent = runtime.cgroupParent
memoryReservationInBytes = runtime.memoryReservationInBytes
memorySwapLimitInBytes = runtime.memorySwapLimitInBytes
}
}
/// Public planning options for service-container create projections.
public struct ContainerServiceCreatePlanOptions: Sendable {
public var name: String?
public var oneOff: Bool
public var autoRemove: Bool
public var includeRestartPolicy: Bool
public var resolveHealthCheck: Bool
public init(
name: String? = nil,
oneOff: Bool = false,
autoRemove: Bool = false,
includeRestartPolicy: Bool = true,
resolveHealthCheck: Bool = true,
) {
self.name = name
self.oneOff = oneOff
self.autoRemove = autoRemove
self.includeRestartPolicy = includeRestartPolicy
self.resolveHealthCheck = resolveHealthCheck
}
}