Skip to content
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
2 changes: 1 addition & 1 deletion Examples/HelloWorldHummingbird/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let package = Package(
platforms: [.macOS(.v14)],
dependencies: [
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.1.0"),
.package(url: "https://github.com/apple/swift-container-plugin", from: "1.0.0"),
.package(path: "../.."),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.0"),
],
targets: [
Expand Down
9 changes: 8 additions & 1 deletion Sources/containertool/containertool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ enum AllowHTTP: String, ExpressibleByArgument, CaseIterable { case source, desti
private var defaultRegistry: String?

@Option(help: "Repository path")
private var repository: String
private var repository: String?

@Argument(help: "Executable to package")
private var executable: String
Expand Down Expand Up @@ -114,7 +114,14 @@ enum AllowHTTP: String, ExpressibleByArgument, CaseIterable { case source, desti
// MARK: Apply defaults for unspecified configuration flags

let env = ProcessInfo.processInfo.environment

let defaultRegistry = defaultRegistry ?? env["CONTAINERTOOL_DEFAULT_REGISTRY"] ?? "docker.io"
guard let repository = repository ?? env["CONTAINERTOOL_REPOSITORY"] else {
throw ValidationError(
"Please specify the destination repository using --repository or CONTAINERTOOL_REPOSITORY"
)
}

let username = defaultUsername ?? env["CONTAINERTOOL_DEFAULT_USERNAME"]
let password = defaultPassword ?? env["CONTAINERTOOL_DEFAULT_PASSWORD"]
let from = from ?? env["CONTAINERTOOL_BASE_IMAGE"] ?? "swift:slim"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Wrap a binary in a container image and publish it.
- term `--default-registry <default-registry>`:
The default registry hostname. (default: `docker.io`)

If the value of the `--repository` argument does not contain a registry hostname, the default registry will be prepended to the repository path.
If the repository path does not contain a registry hostname, the default registry will be prepended to it.

- term `--repository <repository>`:
The repository path.
Expand Down Expand Up @@ -79,9 +79,14 @@ Wrap a binary in a container image and publish it.
### Environment

- term `CONTAINERTOOL_DEFAULT_REGISTRY`:
Default image registry hostname, used when the `--repository` argument does not contain a registry hostname.
Default image registry hostname, used when the repository path does not contain a registry hostname.
(default: `docker.io`)

- term `CONTAINERTOOL_REPOSITORY`:
The repository path.

If the path does not begin with a registry hostname, the default registry will be prepended to the path.

- term `CONTAINERTOOL_BASE_IMAGE`:
Base image on which to layer the application.
(default: `swift:slim`)
Expand Down
5 changes: 2 additions & 3 deletions scripts/test-plugin-output-streaming.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ swift package --package-path "$PKGPATH" --allow-network-connections all build-co
set -o pipefail

# This checks that the output lines are not broken, but not that they appear in the correct order
grep -F -x -e "error: Missing expected argument '--repository <repository>'" \
-e "error: Help: --repository <repository> Repository path" \
-e "error: Usage: containertool [<options>] --repository <repository> <executable>" \
grep -F -x -e "error: Please specify the destination repository using --repository or CONTAINERTOOL_REPOSITORY" \
-e "error: Usage: containertool [<options>] <executable>" \
-e "error: See 'containertool --help' for more information." "$PKGPATH/output"

log Plugin error output: PASSED
Expand Down