From a0662e9066cf0a6385276914346b18c02ebf2b1e Mon Sep 17 00:00:00 2001 From: DataHearth Date: Tue, 14 Jun 2022 11:31:35 +0200 Subject: [PATCH] fix(config): don't throw error when file not available on OS --- internal/configuration/ssh.go | 4 ++++ internal/items.go | 4 ++++ internal/misc/tools.go | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/internal/configuration/ssh.go b/internal/configuration/ssh.go index cbefab0..7e10deb 100644 --- a/internal/configuration/ssh.go +++ b/internal/configuration/ssh.go @@ -88,6 +88,10 @@ func getSSHConfig(uriFlag string) (*ssh.ClientConfig, string, string, error) { var currentUser *osUser.User currentUser, err = osUser.Current() + if err != nil { + return nil, "", "", err + } + user = currentUser.Username } diff --git a/internal/items.go b/internal/items.go index 9dbe21e..fc6acd0 100644 --- a/internal/items.go +++ b/internal/items.go @@ -51,6 +51,10 @@ func (e *Items) Action(action string) { PrintError("[%d] failed to resolve item paths \"%v\": %v", i, l, err) continue } + if storagePath == "" && systemPath == "" { + color.Blue("[%d] file doesn't have configuration path for current OS. Skipping...") + continue + } if action == "save" { src = systemPath diff --git a/internal/misc/tools.go b/internal/misc/tools.go index d60cb16..25fac7e 100644 --- a/internal/misc/tools.go +++ b/internal/misc/tools.go @@ -97,11 +97,17 @@ func ConfigPaths(os configuration.OSLocation, location string) (string, string, switch runtime.GOOS { case "linux": + if os.Linux == "" { + return "", "", nil + } src, dst, err = getPaths(os.Linux, location) if err != nil { return "", "", err } case "darwin": + if os.Darwin == "" { + return "", "", nil + } src, dst, err = getPaths(os.Darwin, location) if err != nil { return "", "", err