Documentation ¶
Index ¶
- Constants
- func CleanPath(path string) string
- func GenerateLayer(path string, deltas []mtree.InodeDelta, opt *MapOptions) (io.ReadCloser, error)
- func ToRootless(spec *rspec.Spec)
- func UnpackLayer(root string, layer io.Reader, opt *MapOptions) error
- func UnpackManifest(ctx context.Context, engine cas.Engine, bundle string, manifest ispec.Manifest, ...) error
- func UnpackRuntimeJSON(ctx context.Context, engine cas.Engine, configFile io.Writer, rootfs string, ...) error
- type MapOptions
Constants ¶
const RootfsName = "rootfs"
RootfsName is the name of the rootfs directory inside the bundle path when generated.
Variables ¶
This section is empty.
Functions ¶
func CleanPath ¶
CleanPath makes a path safe for use with filepath.Join. This is done by not only cleaning the path, but also (if the path is relative) adding a leading '/' and cleaning it (then removing the leading '/'). This ensures that a path resulting from prepending another path will always resolve to lexically be a subdirectory of the prefixed path. This is all done lexically, so paths that include symlinks won't be safe as a result of using CleanPath.
This function comes from runC (libcontainer/utils/utils.go).
func GenerateLayer ¶
func GenerateLayer(path string, deltas []mtree.InodeDelta, opt *MapOptions) (io.ReadCloser, error)
GenerateLayer creates a new OCI diff layer based on the mtree diff provided. All of the mtree.Modified and mtree.Extra blobs are read relative to the provided path (which should be the rootfs of the layer that was diffed). The returned reader is for the *raw* tar data, it is the caller's responsibility to gzip it.
func ToRootless ¶
ToRootless converts a specification to a version that works with rootless containers. This is done by removing options and other settings that clash with unprivileged user namespaces.
func UnpackLayer ¶
func UnpackLayer(root string, layer io.Reader, opt *MapOptions) error
UnpackLayer unpacks the tar stream representing an OCI layer at the given root. It ensures that the state of the root is as close as possible to the state used to create the layer. If an error is returned, the state of root is undefined (unpacking is not guaranteed to be atomic).
func UnpackManifest ¶
func UnpackManifest(ctx context.Context, engine cas.Engine, bundle string, manifest ispec.Manifest, opt *MapOptions) error
UnpackManifest extracts all of the layers in the given manifest, as well as generating a runtime bundle and configuration. The rootfs is extracted to <bundle>/<layer.RootfsName>. Some verification is done during image extraction.
FIXME: This interface is ugly.
func UnpackRuntimeJSON ¶ added in v0.2.0
func UnpackRuntimeJSON(ctx context.Context, engine cas.Engine, configFile io.Writer, rootfs string, manifest ispec.Manifest, opt *MapOptions) error
UnpackRuntimeJSON converts a given manifest's configuration to a runtime configuration and writes it to the given writer. If rootfs is specified, it is sourced during the configuration generation (for conversion of Config.User and other similar jobs -- which will error out if the user could not be parsed). If rootfs is not specified (is an empty string) then all conversions that require sourcing the rootfs will be set to their default values.
XXX: I don't like this API. It has way too many arguments.
Types ¶
type MapOptions ¶
type MapOptions struct { // UIDMappings and GIDMappings are the UID and GID mappings to apply when // packing and unpacking image rootfs layers. UIDMappings []rspec.LinuxIDMapping `json:"uid_mappings"` GIDMappings []rspec.LinuxIDMapping `json:"gid_mappings"` // Rootless specifies whether any to error out if chown fails. Rootless bool `json:"rootless"` }
MapOptions specifies the UID and GID mappings used when unpacking and repacking images.