From 3c933dcc64301afb6125b662cbcca74f15e3516a Mon Sep 17 00:00:00 2001 From: karolos lykos Date: Thu, 21 Oct 2021 16:23:12 +0300 Subject: [PATCH 1/3] refactor: print nicer error to load config error --- .idea/modules.xml | 8 ++++++++ .idea/workspace.xml | 7 +++++++ .idea/zero.iml | 9 +++++++++ go.sum | 2 -- internal/config/projectconfig/project_config.go | 11 ++++++----- 5 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 .idea/modules.xml create mode 100644 .idea/workspace.xml create mode 100644 .idea/zero.iml diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..81ffd4c9 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 00000000..d12cdb62 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/zero.iml b/.idea/zero.iml new file mode 100644 index 00000000..5e764c4f --- /dev/null +++ b/.idea/zero.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/go.sum b/go.sum index 047239ad..5445a641 100644 --- a/go.sum +++ b/go.sum @@ -262,13 +262,11 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/kyokomi/emoji v2.1.0+incompatible h1:+DYU2RgpI6OHG4oQkM5KlqD3Wd3UPEsX8jamTo1Mp6o= github.com/kyokomi/emoji v2.1.0+incompatible/go.mod h1:mZ6aGCD7yk8j6QY6KICwnZ2pxoszVseX1DNoGtU2tBA= diff --git a/internal/config/projectconfig/project_config.go b/internal/config/projectconfig/project_config.go index 3300011d..acd07328 100644 --- a/internal/config/projectconfig/project_config.go +++ b/internal/config/projectconfig/project_config.go @@ -3,12 +3,13 @@ package projectconfig import ( "errors" "io/ioutil" - "log" - "github.com/commitdev/zero/pkg/util/flog" "github.com/hashicorp/terraform/dag" "github.com/k0kubun/pp" - yaml "gopkg.in/yaml.v2" + "gopkg.in/yaml.v2" + + "github.com/commitdev/zero/pkg/util/exit" + "github.com/commitdev/zero/pkg/util/flog" ) // GraphRootName represents the root of the graph of modules in a project @@ -67,11 +68,11 @@ func LoadConfig(filePath string) *ZeroProjectConfig { config := &ZeroProjectConfig{} data, err := ioutil.ReadFile(filePath) if err != nil { - log.Panicf("failed to read config: %v", err) + exit.Fatal("failed to read config: %v", err) } err = yaml.Unmarshal(data, &config) if err != nil { - log.Panicf("failed to parse config: %v", err) + exit.Fatal("failed to parse config: %v", err) } flog.Debugf("Loaded project config: %s from %s", config.Name, filePath) return config From a26c4e1320bff22b88e472a3f94245697c662efd Mon Sep 17 00:00:00 2001 From: karolos lykos Date: Sun, 24 Oct 2021 17:42:43 +0300 Subject: [PATCH 2/3] refactor: print nicer error to load config error --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6c0d49ee..451598f0 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ tmp example/ test-reports/ .circleci/config-compiled.yml +.idea/ \ No newline at end of file From 8946fcae81dac72c13d1f38893191e23132a9ab3 Mon Sep 17 00:00:00 2001 From: karolos lykos Date: Mon, 25 Oct 2021 14:10:17 +0300 Subject: [PATCH 3/3] refactor: print nicer error to load config error --- .idea/modules.xml | 8 -------- .idea/workspace.xml | 7 ------- .idea/zero.iml | 9 --------- 3 files changed, 24 deletions(-) delete mode 100644 .idea/modules.xml delete mode 100644 .idea/workspace.xml delete mode 100644 .idea/zero.iml diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 81ffd4c9..00000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index d12cdb62..00000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/zero.iml b/.idea/zero.iml deleted file mode 100644 index 5e764c4f..00000000 --- a/.idea/zero.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file