From 66897114910b93b54138cae0d93cb48192c6080b Mon Sep 17 00:00:00 2001 From: lovestaco Date: Wed, 16 Aug 2023 20:18:00 +0530 Subject: [PATCH] Renaming packeges, functions, coderefactor --- controller/controller.go | 2 +- Env/env.go => l2env/l2env.go | 1 + tests/utils/test_utils.go | 12 ++++++------ utils/utils.go | 1 - 4 files changed, 8 insertions(+), 8 deletions(-) rename Env/env.go => l2env/l2env.go (98%) diff --git a/controller/controller.go b/controller/controller.go index d215fdc1..404c47db 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -9,10 +9,10 @@ import ( "github.com/HexmosTech/gabs/v2" "github.com/HexmosTech/httpie-go" - env "github.com/HexmosTech/lama2/Env" "github.com/HexmosTech/lama2/cmdexec" "github.com/HexmosTech/lama2/cmdgen" "github.com/HexmosTech/lama2/codegen" + env "github.com/HexmosTech/lama2/l2env" "github.com/HexmosTech/lama2/lama2cmd" outputmanager "github.com/HexmosTech/lama2/outputManager" "github.com/HexmosTech/lama2/parser" diff --git a/Env/env.go b/l2env/l2env.go similarity index 98% rename from Env/env.go rename to l2env/l2env.go index 981034c7..a781ea63 100644 --- a/Env/env.go +++ b/l2env/l2env.go @@ -26,6 +26,7 @@ func ProcessEnvironmentVariables(o *lama2cmd.Opts, directory string) { relevantEnvs := GetRelevantEnvs(envMap, o) utils.MarshalAndPrintJSON(relevantEnvs) } + os.Exit(0) } // If not an -e invocation, the function just continues. } diff --git a/tests/utils/test_utils.go b/tests/utils/test_utils.go index 65607390..5321dc14 100644 --- a/tests/utils/test_utils.go +++ b/tests/utils/test_utils.go @@ -15,16 +15,16 @@ type EnvData struct { Val string `json:"val"` } -func checkL2BinaryExists(l2BinPath string) error { +func checkLocalL2BinaryExists(l2BinPath string) error { if _, err := os.Stat(l2BinPath); os.IsNotExist(err) { return fmt.Errorf("l2 binary not found in the build folder %s, please change the path", l2BinPath) } return nil } -func getL2BinaryPath() (string, error) { +func getLocalL2BinaryPath() (string, error) { l2BinPath := "../build/l2" - err := checkL2BinaryExists(l2BinPath) + err := checkLocalL2BinaryExists(l2BinPath) if err != nil { return "", err } @@ -50,7 +50,7 @@ func runCommand(binPath string, cmdArgs ...string) (string, error) { } func RunL2CommandAndGetOutput(cmdArgs ...string) (string, error) { - l2BinPath, err := getL2BinaryPath() + l2BinPath, err := getLocalL2BinaryPath() if err != nil { return "", err } @@ -59,7 +59,7 @@ func RunL2CommandAndGetOutput(cmdArgs ...string) (string, error) { } func RunL2CommandAndParseJSON(cmdArgs ...string) (map[string]EnvData, error) { - l2BinPath, err := getL2BinaryPath() + l2BinPath, err := getLocalL2BinaryPath() if err != nil { return nil, err } @@ -72,7 +72,7 @@ func RunL2CommandAndParseJSON(cmdArgs ...string) (map[string]EnvData, error) { envMap := make(map[string]EnvData) err = json.Unmarshal([]byte(output), &envMap) if err != nil { - return nil, fmt.Errorf("Error unmarshaling JSON env: %v\nOutput:\n%s", err, output) + return nil, fmt.Errorf("error unmarshaling JSON env: %v\nOutput:\n%s", err, output) } return envMap, nil diff --git a/utils/utils.go b/utils/utils.go index 1704eab9..9a1d7a24 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -146,5 +146,4 @@ func MarshalAndPrintJSON(data interface{}) { os.Exit(0) } fmt.Println(string(filteredJSON)) - os.Exit(0) }