ctr: honor rootfs argument value when generating spec
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
parent
615f748e77
commit
ac5563a809
@ -27,7 +27,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
rwm = "rwm"
|
rwm = "rwm"
|
||||||
rootfsPath = "rootfs"
|
defaultRootfsPath = "rootfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
var capabilities = []string{
|
var capabilities = []string{
|
||||||
@ -47,7 +47,7 @@ var capabilities = []string{
|
|||||||
"CAP_AUDIT_WRITE",
|
"CAP_AUDIT_WRITE",
|
||||||
}
|
}
|
||||||
|
|
||||||
func spec(id string, config *ocispec.ImageConfig, context *cli.Context) (*specs.Spec, error) {
|
func spec(id string, config *ocispec.ImageConfig, context *cli.Context, rootfs string) (*specs.Spec, error) {
|
||||||
env := []string{
|
env := []string{
|
||||||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||||
}
|
}
|
||||||
@ -92,6 +92,9 @@ func spec(id string, config *ocispec.ImageConfig, context *cli.Context) (*specs.
|
|||||||
if cwd == "" {
|
if cwd == "" {
|
||||||
cwd = "/"
|
cwd = "/"
|
||||||
}
|
}
|
||||||
|
if rootfs == "" {
|
||||||
|
rootfs = defaultRootfsPath
|
||||||
|
}
|
||||||
s := &specs.Spec{
|
s := &specs.Spec{
|
||||||
Version: specs.Version,
|
Version: specs.Version,
|
||||||
Platform: specs.Platform{
|
Platform: specs.Platform{
|
||||||
@ -99,7 +102,7 @@ func spec(id string, config *ocispec.ImageConfig, context *cli.Context) (*specs.
|
|||||||
Arch: runtime.GOARCH,
|
Arch: runtime.GOARCH,
|
||||||
},
|
},
|
||||||
Root: specs.Root{
|
Root: specs.Root{
|
||||||
Path: rootfsPath,
|
Path: rootfs,
|
||||||
Readonly: context.Bool("readonly"),
|
Readonly: context.Bool("readonly"),
|
||||||
},
|
},
|
||||||
Process: specs.Process{
|
Process: specs.Process{
|
||||||
@ -232,9 +235,9 @@ func customSpec(configPath string, rootfs string) (*specs.Spec, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if rootfs == "" {
|
if rootfs == "" {
|
||||||
if s.Root.Path != rootfsPath {
|
if s.Root.Path != defaultRootfsPath {
|
||||||
logrus.Warnf("ignoring Root.Path %q, setting %q forcibly", s.Root.Path, rootfsPath)
|
logrus.Warnf("ignoring Root.Path %q, setting %q forcibly", s.Root.Path, defaultRootfsPath)
|
||||||
s.Root.Path = rootfsPath
|
s.Root.Path = defaultRootfsPath
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s.Root.Path = rootfs
|
s.Root.Path = rootfs
|
||||||
@ -245,7 +248,7 @@ func customSpec(configPath string, rootfs string) (*specs.Spec, error) {
|
|||||||
func getConfig(context *cli.Context, imageConfig *ocispec.ImageConfig, rootfs string) (*specs.Spec, error) {
|
func getConfig(context *cli.Context, imageConfig *ocispec.ImageConfig, rootfs string) (*specs.Spec, error) {
|
||||||
config := context.String("runtime-config")
|
config := context.String("runtime-config")
|
||||||
if config == "" {
|
if config == "" {
|
||||||
return spec(context.String("id"), imageConfig, context)
|
return spec(context.String("id"), imageConfig, context, rootfs)
|
||||||
}
|
}
|
||||||
|
|
||||||
return customSpec(config, rootfs)
|
return customSpec(config, rootfs)
|
||||||
|
Loading…
Reference in New Issue
Block a user