diff --git a/Package.swift b/Package.swift index 195c639..aef81bc 100644 --- a/Package.swift +++ b/Package.swift @@ -40,7 +40,9 @@ let package = Package( .executableTarget( name: "containertool", dependencies: [ - .target(name: "ContainerRegistry"), .target(name: "VendorCNIOExtrasZlib"), .target(name: "Tar"), + .target(name: "ContainerRegistry"), + .target(name: "VendorCNIOExtrasZlib"), + .target(name: "Tar"), .product(name: "ArgumentParser", package: "swift-argument-parser"), ], swiftSettings: [.swiftLanguageMode(.v5)] @@ -51,7 +53,8 @@ let package = Package( dependencies: [], path: "Vendor/github.com/apple/swift-nio-extras/Sources/CNIOExtrasZlib", linkerSettings: [.linkedLibrary("z")] - ), .target(name: "Tar"), + ), + .target(name: "Tar"), .target( // Vendored from https://github.com/apple/swift-package-manager with modifications name: "Basics", @@ -86,7 +89,8 @@ let package = Package( name: "ContainerRegistryTests", dependencies: [.target(name: "ContainerRegistry")], resources: [.process("Resources")] - ), .testTarget(name: "containertoolTests", dependencies: [.target(name: "containertool")]), + ), + .testTarget(name: "containertoolTests", dependencies: [.target(name: "containertool")]), .testTarget(name: "TarTests", dependencies: [.target(name: "Tar")]), ], swiftLanguageModes: [.v6] diff --git a/Sources/containertool/containertool.swift b/Sources/containertool/containertool.swift index 5559e88..618c20d 100644 --- a/Sources/containertool/containertool.swift +++ b/Sources/containertool/containertool.swift @@ -28,36 +28,45 @@ enum AllowHTTP: String, ExpressibleByArgument, CaseIterable { case source, desti abstract: "Build and upload a container image" ) - @Option(help: "Default registry for references which do not specify a registry") private var defaultRegistry: - String = ProcessInfo.processInfo.environment["CONTAINERTOOL_DEFAULT_REGISTRY"] ?? "docker.io" + @Option(help: "Default registry for references which do not specify a registry") + private var defaultRegistry: String = + ProcessInfo.processInfo.environment["CONTAINERTOOL_DEFAULT_REGISTRY"] ?? "docker.io" - @Option(help: "Repository path") private var repository: String + @Option(help: "Repository path") + private var repository: String - @Argument(help: "Executable to package") private var executable: String + @Argument(help: "Executable to package") + private var executable: String - @Option(help: "Username") private var username: String? + @Option(help: "Username") + private var username: String? - @Option(help: "Password") private var password: String? + @Option(help: "Password") + private var password: String? - @Flag(name: .shortAndLong, help: "Verbose output") private var verbose: Bool = false + @Flag(name: .shortAndLong, help: "Verbose output") + private var verbose: Bool = false - @Option(help: "Connect to the container registry using plaintext HTTP") var allowInsecureHttp: AllowHTTP? + @Option(help: "Connect to the container registry using plaintext HTTP") + var allowInsecureHttp: AllowHTTP? - @Option(help: "CPU architecture") private var architecture: String = - ProcessInfo.processInfo.environment["CONTAINERTOOL_ARCHITECTURE"] ?? "amd64" + @Option(help: "CPU architecture") + private var architecture: String = ProcessInfo.processInfo.environment["CONTAINERTOOL_ARCHITECTURE"] ?? "amd64" - @Option(help: "Base image reference") private var from: String = - ProcessInfo.processInfo.environment["CONTAINERTOOL_BASE_IMAGE"] ?? "swift:slim" + @Option(help: "Base image reference") + private var from: String = ProcessInfo.processInfo.environment["CONTAINERTOOL_BASE_IMAGE"] ?? "swift:slim" - @Option(help: "Operating system") private var os: String = - ProcessInfo.processInfo.environment["CONTAINERTOOL_OS"] ?? "linux" + @Option(help: "Operating system") + private var os: String = ProcessInfo.processInfo.environment["CONTAINERTOOL_OS"] ?? "linux" - @Option(help: "Tag for this manifest") private var tag: String? + @Option(help: "Tag for this manifest") + private var tag: String? @Flag(inversion: .prefixedEnableDisable, exclusivity: .exclusive, help: "Load credentials from a netrc file") private var netrc: Bool = true - @Option(help: "Specify the netrc file path") private var netrcFile: String? + @Option(help: "Specify the netrc file path") + private var netrcFile: String? func run() async throws { let baseimage = try ImageReference(fromString: from, defaultRegistry: defaultRegistry)