提交 8e7da385 编写于 作者: F Felix Abecassis

Use Panicln instead of Fatalln

It gives the opportunity to perform cleanup in the main function.
上级 8b97295b
......@@ -41,12 +41,12 @@ func getCLIConfig() (config *CLIConfig) {
config = getDefaultCLIConfig()
_, err := toml.DecodeFile(configPath, &config)
if err != nil && !os.IsNotExist(err) {
log.Fatalln("couldn't open configuration file:", err)
log.Panicln("couldn't open configuration file:", err)
}
if len(config.Path) == 0 {
config.Path, err = exec.LookPath("nvidia-container-cli")
if err != nil {
log.Fatalln("couldn't find binary nvidia-container-cli:", err)
log.Panicln("couldn't find binary nvidia-container-cli:", err)
}
}
......
......@@ -63,7 +63,7 @@ func getEnvMap(e []string) (m map[string]string) {
for _, s := range e {
p := strings.SplitN(s, "=", 2)
if len(p) != 2 {
log.Fatalln("environment error")
log.Panicln("environment error")
}
m[p[0]] = p[1]
}
......@@ -73,18 +73,18 @@ func getEnvMap(e []string) (m map[string]string) {
func loadSpec(path string) (spec *Spec) {
f, err := os.Open(path)
if err != nil {
log.Fatalln("could not open OCI spec:", err)
log.Panicln("could not open OCI spec:", err)
}
defer f.Close()
if err = json.NewDecoder(f).Decode(&spec); err != nil {
log.Fatalln("could not decode OCI spec:", err)
log.Panicln("could not decode OCI spec:", err)
}
if spec.Process == nil {
log.Fatalln("Process is empty in OCI spec")
log.Panicln("Process is empty in OCI spec")
}
if spec.Root == nil {
log.Fatalln("Root is empty in OCI spec")
log.Panicln("Root is empty in OCI spec")
}
return
}
......@@ -145,7 +145,7 @@ func getContainerConfig() (config *containerConfig) {
var h HookState
d := json.NewDecoder(os.Stdin)
if err := d.Decode(&h); err != nil {
log.Fatalln("could not decode container state:", err)
log.Panicln("could not decode container state:", err)
}
b := h.Bundle
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册