Skip to content

Commit

Permalink
tart {pull,clone}: add missing --insecure support (#181)
Browse files Browse the repository at this point in the history
Co-authored-by: Nikolay Edigaryev <[email protected]>
  • Loading branch information
edigaryev and Nikolay Edigaryev authored Aug 16, 2022
1 parent 4406813 commit 14059a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Sources/tart/Commands/Clone.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ struct Clone: AsyncParsableCommand {
@Argument(help: "new VM name")
var newName: String

@Flag(help: "connect to the OCI registry via insecure HTTP protocol")
var insecure: Bool = false

func validate() throws {
if newName.contains("/") {
throw ValidationError("<new-name> should be a local name")
Expand All @@ -24,7 +27,7 @@ struct Clone: AsyncParsableCommand {

if let remoteName = try? RemoteName(sourceName), !ociStorage.exists(remoteName) {
// Pull the VM in case it's OCI-based and doesn't exist locally yet
let registry = try Registry(host: remoteName.host, namespace: remoteName.namespace)
let registry = try Registry(host: remoteName.host, namespace: remoteName.namespace, insecure: insecure)
try await ociStorage.pull(remoteName, registry: registry)
}

Expand Down
5 changes: 4 additions & 1 deletion Sources/tart/Commands/Pull.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ struct Pull: AsyncParsableCommand {
@Argument(help: "remote VM name")
var remoteName: String

@Flag(help: "connect to the OCI registry via insecure HTTP protocol")
var insecure: Bool = false

func run() async throws {
do {
// Be more liberal when accepting local image as argument,
Expand All @@ -19,7 +22,7 @@ struct Pull: AsyncParsableCommand {
}

let remoteName = try RemoteName(remoteName)
let registry = try Registry(host: remoteName.host, namespace: remoteName.namespace)
let registry = try Registry(host: remoteName.host, namespace: remoteName.namespace, insecure: insecure)

defaultLogger.appendNewLine("pulling \(remoteName)...")

Expand Down

0 comments on commit 14059a1

Please sign in to comment.