mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 08:18:32 +00:00
Fix bug in update-ldcache hook
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
73cd63e4e5
commit
862f071557
@ -17,6 +17,7 @@
|
|||||||
package ldcache
|
package ldcache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -56,6 +57,9 @@ func (m command) build() *cli.Command {
|
|||||||
c := cli.Command{
|
c := cli.Command{
|
||||||
Name: "update-ldcache",
|
Name: "update-ldcache",
|
||||||
Usage: "Update ldcache in a container by running ldconfig",
|
Usage: "Update ldcache in a container by running ldconfig",
|
||||||
|
Before: func(c *cli.Context) error {
|
||||||
|
return m.validateFlags(c, &cfg)
|
||||||
|
},
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
return m.run(c, &cfg)
|
return m.run(c, &cfg)
|
||||||
},
|
},
|
||||||
@ -71,7 +75,7 @@ func (m command) build() *cli.Command {
|
|||||||
Name: "ldconfig-path",
|
Name: "ldconfig-path",
|
||||||
Usage: "Specify the path to the ldconfig program",
|
Usage: "Specify the path to the ldconfig program",
|
||||||
Destination: &cfg.ldconfigPath,
|
Destination: &cfg.ldconfigPath,
|
||||||
DefaultText: "/sbin/ldconfig",
|
Value: "/sbin/ldconfig",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "container-spec",
|
Name: "container-spec",
|
||||||
@ -83,6 +87,13 @@ func (m command) build() *cli.Command {
|
|||||||
return &c
|
return &c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m command) validateFlags(c *cli.Context, cfg *options) error {
|
||||||
|
if cfg.ldconfigPath == "" {
|
||||||
|
return errors.New("ldconfig-path must be specified")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (m command) run(c *cli.Context, cfg *options) error {
|
func (m command) run(c *cli.Context, cfg *options) error {
|
||||||
s, err := oci.LoadContainerState(cfg.containerSpec)
|
s, err := oci.LoadContainerState(cfg.containerSpec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user