From 18e21479536fbaa34bac16604dd82c5c7d066be8 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Thu, 14 Apr 2022 13:58:00 +0200 Subject: [PATCH] added file uri pattern for container import --- CHANGELOG.md | 1 + internal/app/wwctl/container/imprt/main.go | 2 +- internal/pkg/oci/puller.go | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7620053d..233686a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - uids and gids of a container now get synced at import time, so that at least users with the same name have the same uid. This is not necessarily needed for warewulf, but services like munge. +- oci container tar balls can be imported with the 'file://$PATH' scheme ## [4.1.0] - 2021-07-29 diff --git a/internal/app/wwctl/container/imprt/main.go b/internal/app/wwctl/container/imprt/main.go index f93c439a..06a25d93 100644 --- a/internal/app/wwctl/container/imprt/main.go +++ b/internal/app/wwctl/container/imprt/main.go @@ -99,7 +99,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error { wwlog.Printf(wwlog.ERROR, "VNFS Name exists, specify --force, --update, or choose a different name: %s\n", name) os.Exit(1) } - } else if strings.HasPrefix(uri, "docker://") || strings.HasPrefix(uri, "docker-daemon://") { + } else if strings.HasPrefix(uri, "docker://") || strings.HasPrefix(uri, "docker-daemon://") || strings.HasPrefix(uri, "file://") { sCtx, err := getSystemContext() if err != nil { wwlog.Printf(wwlog.ERROR, "%s\n", err) diff --git a/internal/pkg/oci/puller.go b/internal/pkg/oci/puller.go index 135967a2..8058addf 100644 --- a/internal/pkg/oci/puller.go +++ b/internal/pkg/oci/puller.go @@ -12,6 +12,7 @@ import ( "github.com/containers/image/v5/copy" "github.com/containers/image/v5/docker" + dockerarchive "github.com/containers/image/v5/docker/archive" "github.com/containers/image/v5/docker/daemon" "github.com/containers/image/v5/oci/layout" "github.com/containers/image/v5/signature" @@ -78,8 +79,10 @@ func getReference(uri string) (types.ImageReference, error) { return docker.ParseReference(s[1]) case "docker-daemon": return daemon.ParseReference(strings.TrimPrefix(s[1], "//")) + case "file": + return dockerarchive.ParseReference(strings.TrimPrefix(s[1], "/")) default: - return nil, fmt.Errorf("unknown uri sceme: %q", uri) + return nil, fmt.Errorf("unknown uri scheme: %q", uri) } }