github.com/apptainer/singularity@v3.1.1+incompatible/internal/pkg/libexec/pull.go (about) 1 // Copyright (c) 2018, Sylabs Inc. All rights reserved. 2 // This software is licensed under a 3-clause BSD license. Please consult the 3 // LICENSE.md file distributed with the sources of this project regarding your 4 // rights to use or distribute this software. 5 6 package libexec 7 8 import ( 9 "github.com/sylabs/singularity/internal/pkg/build" 10 "github.com/sylabs/singularity/internal/pkg/sylog" 11 "github.com/sylabs/singularity/pkg/build/types" 12 library "github.com/sylabs/singularity/pkg/client/library" 13 net "github.com/sylabs/singularity/pkg/client/net" 14 shub "github.com/sylabs/singularity/pkg/client/shub" 15 ) 16 17 // PullNetImage is the function that is responsible for pulling an image from http remote url. 18 func PullNetImage(image, libraryURL string, force bool) { 19 err := net.DownloadImage(image, libraryURL, force) 20 if err != nil { 21 sylog.Fatalf("%v\n", err) 22 } 23 } 24 25 // PullLibraryImage is the function that is responsible for pulling an image from a Sylabs library. 26 func PullLibraryImage(image, libraryRef, libraryURL string, force bool, authToken string) { 27 err := library.DownloadImage(image, libraryRef, libraryURL, force, authToken) 28 if err != nil { 29 sylog.Fatalf("%v\n", err) 30 } 31 } 32 33 // PullShubImage is the function that is responsible for pulling an image from a Singularity Hub. 34 func PullShubImage(filePath, shubRef string, force, noHTTPS bool) { 35 err := shub.DownloadImage(filePath, shubRef, force, noHTTPS) 36 if err != nil { 37 sylog.Fatalf("%v\n", err) 38 } 39 } 40 41 // PullOciImage pulls an OCI image to a sif 42 func PullOciImage(path, uri string, opts types.Options) { 43 b, err := build.NewBuild(uri, path, "sif", "", "", opts) 44 if err != nil { 45 sylog.Fatalf("Unable to pull %v: %v", uri, err) 46 } 47 48 if err := b.Full(); err != nil { 49 sylog.Fatalf("Unable to pull %v: %v", uri, err) 50 } 51 }