diff --git a/internal/app/wwctl/container/imprt/main.go b/internal/app/wwctl/container/imprt/main.go index 06a25d93..0f6f47af 100644 --- a/internal/app/wwctl/container/imprt/main.go +++ b/internal/app/wwctl/container/imprt/main.go @@ -99,7 +99,8 @@ 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://") || strings.HasPrefix(uri, "file://") { + } else if strings.HasPrefix(uri, "docker://") || strings.HasPrefix(uri, "docker-daemon://") || + strings.HasPrefix(uri, "file://") || util.IsFile(uri) { sCtx, err := getSystemContext() if err != nil { wwlog.Printf(wwlog.ERROR, "%s\n", err) diff --git a/internal/app/wwctl/container/imprt/root.go b/internal/app/wwctl/container/imprt/root.go index ee9c960b..ccbd8cde 100644 --- a/internal/app/wwctl/container/imprt/root.go +++ b/internal/app/wwctl/container/imprt/root.go @@ -8,7 +8,13 @@ var ( Use: "import [OPTIONS] SOURCE [NAME]", Short: "Import a container into Warewulf", Long: `This command will pull and import a container into Warewulf from SOURCE, -optionally renaming it to NAME. The SOURCE must be in a supported URI format. +optionally renaming it to NAME. The SOURCE must be in a supported URI format. Formats +are: + * docker://registry.example.org/example:latest + * docker-daemon://example:latest + * file://path/to/archive/tar/ball + * /path/to/archive/tar/ball + * /path/to/chroot/ Imported containers are used to create bootable VNFS images.`, Example: "wwctl container import docker://warewulf/centos-8 my_container", RunE: CobraRunE, diff --git a/internal/pkg/oci/puller.go b/internal/pkg/oci/puller.go index 8058addf..9acae792 100644 --- a/internal/pkg/oci/puller.go +++ b/internal/pkg/oci/puller.go @@ -17,6 +17,7 @@ import ( "github.com/containers/image/v5/oci/layout" "github.com/containers/image/v5/signature" "github.com/containers/image/v5/types" + "github.com/hpcng/warewulf/internal/pkg/util" imgSpecs "github.com/opencontainers/image-spec/specs-go/v1" "github.com/opencontainers/umoci" "github.com/opencontainers/umoci/oci/layer" @@ -69,6 +70,9 @@ func NewPuller(opts ...pullerOpt) (*puller, error) { // getReference parsed the uri scheme to determine func getReference(uri string) (types.ImageReference, error) { + if util.IsFile(uri) { + uri = "file://" + uri + } s := strings.SplitN(uri, ":", 2) if len(s) != 2 { return nil, fmt.Errorf("invalid uri: %q", uri)