Skip to content

Commit 21ed60b

Browse files
Merge pull request #313 from elezar/fix-update-ldconfig
Fix bug in update-ldcache hook
2 parents 73cd63e + 862f071 commit 21ed60b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

cmd/nvidia-ctk/hook/update-ldcache/update-ldcache.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package ldcache
1818

1919
import (
20+
"errors"
2021
"fmt"
2122
"os"
2223
"path/filepath"
@@ -56,6 +57,9 @@ func (m command) build() *cli.Command {
5657
c := cli.Command{
5758
Name: "update-ldcache",
5859
Usage: "Update ldcache in a container by running ldconfig",
60+
Before: func(c *cli.Context) error {
61+
return m.validateFlags(c, &cfg)
62+
},
5963
Action: func(c *cli.Context) error {
6064
return m.run(c, &cfg)
6165
},
@@ -71,7 +75,7 @@ func (m command) build() *cli.Command {
7175
Name: "ldconfig-path",
7276
Usage: "Specify the path to the ldconfig program",
7377
Destination: &cfg.ldconfigPath,
74-
DefaultText: "/sbin/ldconfig",
78+
Value: "/sbin/ldconfig",
7579
},
7680
&cli.StringFlag{
7781
Name: "container-spec",
@@ -83,6 +87,13 @@ func (m command) build() *cli.Command {
8387
return &c
8488
}
8589

90+
func (m command) validateFlags(c *cli.Context, cfg *options) error {
91+
if cfg.ldconfigPath == "" {
92+
return errors.New("ldconfig-path must be specified")
93+
}
94+
return nil
95+
}
96+
8697
func (m command) run(c *cli.Context, cfg *options) error {
8798
s, err := oci.LoadContainerState(cfg.containerSpec)
8899
if err != nil {

0 commit comments

Comments
 (0)