Skip to content

Commit 14c35ad

Browse files
committed
containertool: Allow destination repository to be set by an environment variable
1 parent 49f92be commit 14c35ad

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Sources/containertool/containertool.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ enum AllowHTTP: String, ExpressibleByArgument, CaseIterable { case source, desti
3232
private var defaultRegistry: String?
3333

3434
@Option(help: "Repository path")
35-
private var repository: String
35+
private var repository: String?
3636

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

116116
let env = ProcessInfo.processInfo.environment
117+
117118
let defaultRegistry = defaultRegistry ?? env["CONTAINERTOOL_DEFAULT_REGISTRY"] ?? "docker.io"
119+
guard let repository = repository ?? env["CONTAINERTOOL_REPOSITORY"] else {
120+
throw ValidationError(
121+
"Please specify the destination repository using --repository or CONTAINERTOOL_REPOSITORY"
122+
)
123+
}
124+
118125
let username = defaultUsername ?? env["CONTAINERTOOL_DEFAULT_USERNAME"]
119126
let password = defaultPassword ?? env["CONTAINERTOOL_DEFAULT_PASSWORD"]
120127
let from = from ?? env["CONTAINERTOOL_BASE_IMAGE"] ?? "swift:slim"

0 commit comments

Comments
 (0)