Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
18 changes: 9 additions & 9 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ let package = Package(
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.3"),
.package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0"),
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-protobuf.git", from: "1.30.0"),
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0"),
.package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.7.0"),
.package(url: "https://github.com/grpc/grpc-swift-extras.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.81.0"),
.package(url: "https://github.com/apple/swift-crypto.git", from: "3.12.2"),
.package(url: "https://github.com/swiftlang/swift-subprocess.git", branch: "main"),
.package(url: "https://github.com/swiftlang/swift-subprocess.git", revision: "0.1"),
.package(url: "https://github.com/apple/swift-http-types.git", from: "1.4.0"),
.package(url: "https://github.com/apple/swift-async-dns-resolver.git", from: "0.4.0"),
.package(url: "https://github.com/edgeengineer/dbus.git", from: "0.2.1"),
.package(url: "https://github.com/edgeengineer/dbus.git", from: "0.2.2"),
.package(url: "https://github.com/apple/swift-system.git", from: "1.4.2"),
],
targets: [
Expand Down
17 changes: 13 additions & 4 deletions Proto/edge/agent/services/v1/edge_agent_v1_container_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ syntax = "proto3";

package edge.agent.services.v1;

import "edge/agent/services/v1/shared.proto";

service EdgeContainerService {
rpc ListLayers(ListLayersRequest) returns (stream LayerHeader);
rpc WriteLayer(stream WriteLayerRequest) returns (stream WriteLayerResponse);
rpc RunContainer(RunContainerLayersRequest) returns (RunContainerLayersResponse);
rpc StopContainer(StopContainerRequest) returns (StopContainerResponse);
}

message ListLayersRequest {}
Expand Down Expand Up @@ -39,9 +42,9 @@ message RunContainerLayersRequest {

/// The `edge.json` file as found in the project
bytes app_config = 5;

// If true, the container will be automatically restarted on crash or device reboot.
bool auto_restart = 6;
// Optional restart policy override for Docker runtime.
optional RestartPolicy restart_policy = 6;
}

message RunContainerLayerHeader {
Expand All @@ -56,4 +59,10 @@ message RunContainerLayerHeader {
bool gzip = 4;
}

message RunContainerLayersResponse {}
message RunContainerLayersResponse {}

message StopContainerRequest {
string app_name = 1;
}

message StopContainerResponse {}
17 changes: 16 additions & 1 deletion Proto/edge/agent/services/v1/edge_agent_v1_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package edge.agent.services.v1;

import "edge/agent/services/v1/shared.proto";

service EdgeAgentService {
// Upload a container image to the agent, and run it.
// The first message in the stream MUST be the header.
Expand Down Expand Up @@ -59,24 +61,37 @@ message RunContainerRequest {
message ControlCommand {
oneof command {
Run run = 1;
Stop stop = 2;
}

message Run {
// Whether to run the container with a debugger
bool debug = 1;

// Optional restart policy override for Docker runtime.
optional RestartPolicy restart_policy = 2;
}

message Stop {
// No fields needed; acts on the current container in this stream
}
}

message RunContainerResponse {
oneof response_type {
Started started = 1;
Stopped stopped = 2;
}

message Started {
// The port that the debugger is listening on.
// If this is 0, the container is not running with a debugger.
uint32 debug_port = 1;
}

message Stopped {
// No fields; indicates container has been stopped
}
}

message UpdateAgentRequest {
Expand Down Expand Up @@ -213,4 +228,4 @@ message ListHardwareCapabilitiesResponse {
// Additional properties as key-value pairs
map<string, string> properties = 4;
}
}
}
15 changes: 15 additions & 0 deletions Proto/edge/agent/services/v1/shared.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
syntax = "proto3";

enum RestartPolicyMode {
DEFAULT = 0; // Agent chooses default (unless-stopped for normal runs)
UNLESS_STOPPED = 1; // --restart unless-stopped
NO = 2; // --restart no
ON_FAILURE = 3; // --restart on-failure:N (see on_failure_max_retries)
}

message RestartPolicy {
RestartPolicyMode mode = 1;

// Only used when mode==ON_FAILURE
int32 on_failure_max_retries = 2;
}
3 changes: 2 additions & 1 deletion Sources/ContainerBuilder/ContainerBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ private func createTarball(from sourceDir: URL, to destinationURL: URL) async th
Subprocess.Executable.path("/usr/bin/env"),
arguments: Subprocess.Arguments([
"tar", "-cf", destinationURL.path, "-C", sourceDir.path, ".",
])
]),
output: .discarded
)
}

Expand Down
Binary file modified Sources/ContainerdGRPC/Proto/containerd.protoset
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -373,19 +373,7 @@ fileprivate let _protobuf_package = "containerd.services.containers.v1"

extension Containerd_Services_Containers_V1_Container: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".Container"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "id"),
2: .same(proto: "labels"),
3: .same(proto: "image"),
4: .same(proto: "runtime"),
5: .same(proto: "spec"),
6: .same(proto: "snapshotter"),
7: .standard(proto: "snapshot_key"),
8: .standard(proto: "created_at"),
9: .standard(proto: "updated_at"),
10: .same(proto: "extensions"),
11: .same(proto: "sandbox"),
]
public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}id\0\u{1}labels\0\u{1}image\0\u{1}runtime\0\u{1}spec\0\u{1}snapshotter\0\u{3}snapshot_key\0\u{3}created_at\0\u{3}updated_at\0\u{1}extensions\0\u{1}sandbox\0")

public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
Expand Down Expand Up @@ -469,10 +457,7 @@ extension Containerd_Services_Containers_V1_Container: SwiftProtobuf.Message, Sw

extension Containerd_Services_Containers_V1_Container.Runtime: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = Containerd_Services_Containers_V1_Container.protoMessageName + ".Runtime"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "name"),
2: .same(proto: "options"),
]
public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}name\0\u{1}options\0")

public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
Expand Down Expand Up @@ -511,9 +496,7 @@ extension Containerd_Services_Containers_V1_Container.Runtime: SwiftProtobuf.Mes

extension Containerd_Services_Containers_V1_GetContainerRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".GetContainerRequest"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "id"),
]
public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}id\0")

public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
Expand Down Expand Up @@ -543,9 +526,7 @@ extension Containerd_Services_Containers_V1_GetContainerRequest: SwiftProtobuf.M

extension Containerd_Services_Containers_V1_GetContainerResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".GetContainerResponse"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "container"),
]
public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}container\0")

public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
Expand Down Expand Up @@ -579,9 +560,7 @@ extension Containerd_Services_Containers_V1_GetContainerResponse: SwiftProtobuf.

extension Containerd_Services_Containers_V1_ListContainersRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".ListContainersRequest"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "filters"),
]
public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}filters\0")

public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
Expand Down Expand Up @@ -611,9 +590,7 @@ extension Containerd_Services_Containers_V1_ListContainersRequest: SwiftProtobuf

extension Containerd_Services_Containers_V1_ListContainersResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".ListContainersResponse"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "containers"),
]
public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}containers\0")

public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
Expand Down Expand Up @@ -643,9 +620,7 @@ extension Containerd_Services_Containers_V1_ListContainersResponse: SwiftProtobu

extension Containerd_Services_Containers_V1_CreateContainerRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".CreateContainerRequest"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "container"),
]
public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}container\0")

public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
Expand Down Expand Up @@ -679,9 +654,7 @@ extension Containerd_Services_Containers_V1_CreateContainerRequest: SwiftProtobu

extension Containerd_Services_Containers_V1_CreateContainerResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".CreateContainerResponse"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "container"),
]
public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}container\0")

public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
Expand Down Expand Up @@ -715,10 +688,7 @@ extension Containerd_Services_Containers_V1_CreateContainerResponse: SwiftProtob

extension Containerd_Services_Containers_V1_UpdateContainerRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".UpdateContainerRequest"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "container"),
2: .standard(proto: "update_mask"),
]
public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}container\0\u{3}update_mask\0")

public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
Expand Down Expand Up @@ -757,9 +727,7 @@ extension Containerd_Services_Containers_V1_UpdateContainerRequest: SwiftProtobu

extension Containerd_Services_Containers_V1_UpdateContainerResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".UpdateContainerResponse"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "container"),
]
public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}container\0")

public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
Expand Down Expand Up @@ -793,9 +761,7 @@ extension Containerd_Services_Containers_V1_UpdateContainerResponse: SwiftProtob

extension Containerd_Services_Containers_V1_DeleteContainerRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".DeleteContainerRequest"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "id"),
]
public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}id\0")

public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
Expand Down Expand Up @@ -825,9 +791,7 @@ extension Containerd_Services_Containers_V1_DeleteContainerRequest: SwiftProtobu

extension Containerd_Services_Containers_V1_ListContainerMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".ListContainerMessage"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "container"),
]
public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}container\0")

public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
Expand Down
Loading