Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
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
172 changes: 171 additions & 1 deletion Package.resolved

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

40 changes: 18 additions & 22 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
// swift-tools-version: 6.0
// swift-tools-version: 6.1
import PackageDescription

let package = Package(
name: "edge-cli",
platforms: [
.macOS(.v15)
],
products: [
.executable(name: "edge", targets: ["edge"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.5.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.3"),
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.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/apache-edge/edge-agent-common.git",
revision: "952035635c630d366dfbcff04af1934c7c051f23"
),
],
targets: [
/// The main executable provided by edge-cli.
.executableTarget(
name: "edge",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.target(name: "EdgeCLI"),
.product(name: "Logging", package: "swift-log"),
.product(name: "_NIOFileSystem", package: "swift-nio"),
.product(name: "GRPCNIOTransportHTTP2", package: "grpc-swift-nio-transport"),
.product(name: "EdgeAgentGRPC", package: "edge-agent-common"),
.target(name: "EdgeCLI"),
],
resources: [
.copy("Resources")
]
),

/// The EdgeAgent executable. It's currently here for development purposes, and will be
/// moved to a separate package in the future.
.executableTarget(
name: "EdgeAgent",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "Logging", package: "swift-log"),
]
),

/// Contains everything EdgeCLI, except for the command line interface.
.target(
name: "EdgeCLI",
dependencies: [
.target(name: "ContainerBuilder"),
.target(name: "Shell"),
.product(name: "Shell", package: "edge-agent-common"),
.product(name: "Logging", package: "swift-log"),
]
),
Expand All @@ -48,15 +51,8 @@ let package = Package(
.target(
name: "ContainerBuilder",
dependencies: [
.target(name: "Shell")
]
),

/// Utility for executing shell commands.
.target(
name: "Shell",
dependencies: [
.product(name: "Logging", package: "swift-log")
.product(name: "Shell", package: "edge-agent-common"),
.product(name: "Crypto", package: "swift-crypto"),
]
),
]
Expand Down
44 changes: 44 additions & 0 deletions Scripts/Generate-Proto.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# This scripts generates the EdgeAgentGRPC Swift code. It requires `protoc` to be available in the PATH.
# It should be run from the root of the project.

# Get the binary path
BIN_PATH=$(swift build --show-bin-path)
PROTOC_GEN_GRPC_PATH="$BIN_PATH/protoc-gen-grpc-swift"
PROTOC_GEN_SWIFT_PATH="$BIN_PATH/protoc-gen-swift"

# Check if protoc-gen-grpc-swift exists, and build it if needed
if [ ! -f "$PROTOC_GEN_GRPC_PATH" ]; then
echo "protoc-gen-grpc-swift not found. Building it now..."
swift build --product protoc-gen-grpc-swift
fi

rm -rf Sources/EdgeAgentGRPC/Proto
mkdir -p Sources/EdgeAgentGRPC/Proto

protoc \
--plugin $PROTOC_GEN_GRPC_PATH \
--grpc-swift_out=Sources/EdgeAgentGRPC/Proto \
--grpc-swift_opt=Visibility=Public \
--grpc-swift_opt=Server=True \
--grpc-swift_opt=Client=True \
--include_imports \
--descriptor_set_out=Sources/EdgeAgentGRPC/Proto/edge_agent.protoset \
--experimental_allow_proto3_optional \
-I=Proto \
Proto/edge/agent/services/v1/*.proto

# Check if protoc-gen-swift exists
if [ ! -f "$PROTOC_GEN_SWIFT_PATH" ]; then
echo "protoc-gen-swift not found. Building it now..."
swift build --product protoc-gen-swift
fi

protoc \
--plugin $PROTOC_GEN_SWIFT_PATH \
--swift_out=Sources/EdgeAgentGRPC/Proto \
--swift_opt=Visibility=Public \
--experimental_allow_proto3_optional \
-I=Proto \
Proto/edge/agent/services/v1/*.proto
4 changes: 2 additions & 2 deletions Sources/ContainerBuilder/ContainerBuilder.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CryptoKit
import Crypto
import Foundation
import Shell

Expand Down Expand Up @@ -136,7 +136,7 @@ public func buildDockerContainerImage(
try FileManager.default.removeItem(at: tempDir)
}

// Calculate SHA256 hash using CryptoKit
// Calculate SHA256 hash using Swift Crypto
private func sha256(data: Data) -> String {
let digest = SHA256.hash(data: data)
return digest.map { String(format: "%02x", $0) }.joined()
Expand Down
12 changes: 0 additions & 12 deletions Sources/EdgeAgent/EdgeAgent.swift

This file was deleted.

Loading