Skip to content

containertool: Move ELF architecture translation extension to Extensions #73

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

Merged
merged 1 commit into from
Mar 18, 2025
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
25 changes: 25 additions & 0 deletions Sources/containertool/Extensions/ELF+containerArchitecture.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftContainerPlugin open source project
//
// Copyright (c) 2024 Apple Inc. and the SwiftContainerPlugin project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftContainerPlugin project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

extension ELF.ISA {
/// Converts the ELF architecture to the GOARCH string representation understood by the container runtime.
/// Unsupported architectures are mapped to nil.
var containerArchitecture: String? {
switch self {
case .x86_64: "amd64"
case .aarch64: "arm64"
default: nil
}
}
}
10 changes: 0 additions & 10 deletions Sources/containertool/containertool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,3 @@ enum AllowHTTP: String, ExpressibleByArgument, CaseIterable { case source, desti
print(destination_image)
}
}

extension ELF.ISA {
var containerArchitecture: String? {
switch self {
case .x86_64: "amd64"
case .aarch64: "arm64"
default: nil
}
}
}