summaryrefslogtreecommitdiff
path: root/vendor/github.com/Microsoft/hcsshim/computestorage/setup.go
diff options
context:
space:
mode:
authordependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>2020-12-23 09:17:35 +0000
committerDaniel J Walsh <dwalsh@redhat.com>2020-12-23 04:29:57 -0500
commit057faea5c185d24cda40d310b0a80763ee46f4cc (patch)
tree148844953c6a27c11313175c7c9cd6625152a371 /vendor/github.com/Microsoft/hcsshim/computestorage/setup.go
parent07663f74c48d11732a3330248f837d5abf86fe9c (diff)
downloadpodman-057faea5c185d24cda40d310b0a80763ee46f4cc.tar.gz
podman-057faea5c185d24cda40d310b0a80763ee46f4cc.tar.bz2
podman-057faea5c185d24cda40d310b0a80763ee46f4cc.zip
Bump github.com/containers/storage from 1.24.3 to 1.24.4
Bumps [github.com/containers/storage](https://github.com/containers/storage) from 1.24.3 to 1.24.4. - [Release notes](https://github.com/containers/storage/releases) - [Changelog](https://github.com/containers/storage/blob/master/docs/containers-storage-changes.md) - [Commits](https://github.com/containers/storage/compare/v1.24.3...v1.24.4) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/github.com/Microsoft/hcsshim/computestorage/setup.go')
-rw-r--r--vendor/github.com/Microsoft/hcsshim/computestorage/setup.go75
1 files changed, 75 insertions, 0 deletions
diff --git a/vendor/github.com/Microsoft/hcsshim/computestorage/setup.go b/vendor/github.com/Microsoft/hcsshim/computestorage/setup.go
new file mode 100644
index 000000000..13ce0cd60
--- /dev/null
+++ b/vendor/github.com/Microsoft/hcsshim/computestorage/setup.go
@@ -0,0 +1,75 @@
+package computestorage
+
+import (
+ "context"
+ "encoding/json"
+ "errors"
+ "fmt"
+
+ "github.com/Microsoft/hcsshim/internal/oc"
+ "github.com/Microsoft/hcsshim/osversion"
+ "go.opencensus.io/trace"
+ "golang.org/x/sys/windows"
+)
+
+// SetupBaseOSLayer sets up a layer that contains a base OS for a container.
+//
+// `layerPath` is a path to a directory containing the layer.
+//
+// `vhdHandle` is an empty file handle of `options.Type == OsLayerTypeContainer`
+// or else it is a file handle to the 'SystemTemplateBase.vhdx' if `options.Type
+// == OsLayerTypeVm`.
+//
+// `options` are the options applied while processing the layer.
+func SetupBaseOSLayer(ctx context.Context, layerPath string, vhdHandle windows.Handle, options OsLayerOptions) (err error) {
+ title := "hcsshim.SetupBaseOSLayer"
+ ctx, span := trace.StartSpan(ctx, title)
+ defer span.End()
+ defer func() { oc.SetSpanStatus(span, err) }()
+ span.AddAttributes(
+ trace.StringAttribute("layerPath", layerPath),
+ )
+
+ bytes, err := json.Marshal(options)
+ if err != nil {
+ return err
+ }
+
+ err = hcsSetupBaseOSLayer(layerPath, vhdHandle, string(bytes))
+ if err != nil {
+ return fmt.Errorf("failed to setup base OS layer: %s", err)
+ }
+ return nil
+}
+
+// SetupBaseOSVolume sets up a volume that contains a base OS for a container.
+//
+// `layerPath` is a path to a directory containing the layer.
+//
+// `volumePath` is the path to the volume to be used for setup.
+//
+// `options` are the options applied while processing the layer.
+func SetupBaseOSVolume(ctx context.Context, layerPath, volumePath string, options OsLayerOptions) (err error) {
+ if osversion.Get().Build < 19645 {
+ return errors.New("SetupBaseOSVolume is not present on builds older than 19645")
+ }
+ title := "hcsshim.SetupBaseOSVolume"
+ ctx, span := trace.StartSpan(ctx, title)
+ defer span.End()
+ defer func() { oc.SetSpanStatus(span, err) }()
+ span.AddAttributes(
+ trace.StringAttribute("layerPath", layerPath),
+ trace.StringAttribute("volumePath", volumePath),
+ )
+
+ bytes, err := json.Marshal(options)
+ if err != nil {
+ return err
+ }
+
+ err = hcsSetupBaseOSVolume(layerPath, volumePath, string(bytes))
+ if err != nil {
+ return fmt.Errorf("failed to setup base OS layer: %s", err)
+ }
+ return nil
+}