Files
warewulf/internal/pkg/container/pull.go
Ian Kaneshiro 846b45524c Tidy up
- Ran goimports to format code and imports
- Removed unused module from go.mod
- Added .editorconfig to keep formatting standard across contributors
2021-02-16 11:54:12 -08:00

47 lines
858 B
Go

package container
import (
"context"
"os"
"github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/oci"
)
func PullURI(uri string, name string) error {
OciBlobCacheDir := config.LocalStateDir + "/oci/blobs"
err := os.MkdirAll(OciBlobCacheDir, 0755)
if err != nil {
return err
}
if ValidName(name) == false {
return errors.New("VNFS name contains illegal characters: " + name)
}
fullPath := RootFsDir(name)
err = os.MkdirAll(fullPath, 0755)
if err != nil {
return err
}
p, err := oci.NewPuller(
oci.OptSetBlobCachePath(OciBlobCacheDir),
oci.OptSetSystemContext(nil),
)
if err != nil {
return err
}
p.GenerateID(context.Background(), uri)
if err := p.Pull(context.Background(), uri, fullPath); err != nil {
return err
}
return nil
}