Closed guumaster closed 4 years ago
Describe the bug If you try to add a profile from a file that doesn't exists, it panic.
Expected behavior
Check for the source file and fail more gracefully on missing file.
Additional context Error:
hostctl add -p test --from .etchosts Using hosts file: /etc/hosts panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x556854311397] goroutine 1 [running]: github.com/guumaster/hostctl/pkg/host.add(0x0, 0xc000133ca0, 0x0, 0x5568543c8ae0) github.com/guumaster/hostctl/pkg/host/add.go:75 +0xb7 github.com/guumaster/hostctl/pkg/host.AddFromFile(0xc000133d50, 0x55685431bb29, 0x7) github.com/guumaster/hostctl/pkg/host/add.go:39 +0xc3 github.com/guumaster/hostctl/cmd.glob..func1(0x5568544f7cc0, 0xc000068300, 0x0, 0x4, 0x0, 0x0) github.com/guumaster/hostctl/cmd/add.go:21 +0x17c github.com/spf13/cobra.(*Command).execute(0x5568544f7cc0, 0xc0000682c0, 0x4, 0x4, 0x5568544f7cc0, 0xc0000682c0) github.com/spf13/cobra@v0.0.6/command.go:840 +0x455 github.com/spf13/cobra.(*Command).ExecuteC(0x5568544f99a0, 0x0, 0x0, 0x556800000000) github.com/spf13/cobra@v0.0.6/command.go:945 +0x319 github.com/spf13/cobra.(*Command).Execute(...) github.com/spf13/cobra@v0.0.6/command.go:885 github.com/guumaster/hostctl/cmd.Execute() github.com/guumaster/hostctl/cmd/root.go:35 +0x2f main.main() github.com/guumaster/hostctl/main.go:10 +0x22
Describe the bug If you try to add a profile from a file that doesn't exists, it panic.
Expected behavior
Check for the source file and fail more gracefully on missing file.
Additional context Error: