From 14059a1d6f4f08517f3914c65ada1854c6ef841f Mon Sep 17 00:00:00 2001 From: Nikolay Edigaryev Date: Wed, 17 Aug 2022 01:31:19 +0400 Subject: [PATCH] tart {pull,clone}: add missing --insecure support (#181) Co-authored-by: Nikolay Edigaryev --- Sources/tart/Commands/Clone.swift | 5 ++++- Sources/tart/Commands/Pull.swift | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Sources/tart/Commands/Clone.swift b/Sources/tart/Commands/Clone.swift index 02d965cf..887dbac3 100644 --- a/Sources/tart/Commands/Clone.swift +++ b/Sources/tart/Commands/Clone.swift @@ -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(" should be a local name") @@ -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) } diff --git a/Sources/tart/Commands/Pull.swift b/Sources/tart/Commands/Pull.swift index b19e3deb..af30de1b 100644 --- a/Sources/tart/Commands/Pull.swift +++ b/Sources/tart/Commands/Pull.swift @@ -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, @@ -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)...")