diff --git a/integration_platform_clickup_go/__debug_bin3838587151 b/integration_platform_clickup_go/__debug_bin3838587151 deleted file mode 100755 index b1ba1a4..0000000 Binary files a/integration_platform_clickup_go/__debug_bin3838587151 and /dev/null differ diff --git a/integration_platform_clickup_go/__debug_bin882619035 b/integration_platform_clickup_go/__debug_bin882619035 deleted file mode 100755 index 372035f..0000000 Binary files a/integration_platform_clickup_go/__debug_bin882619035 and /dev/null differ diff --git a/integration_platform_clickup_go/main.go b/integration_platform_clickup_go/main.go index 4683917..1e828df 100755 --- a/integration_platform_clickup_go/main.go +++ b/integration_platform_clickup_go/main.go @@ -32,7 +32,7 @@ ____ _ _ __ ____ _ _ _ _ _ ` func LoadProjects() { - config := functions.LoadConfigsByYamlFile() + config := variables_global.Config fmt.Println("------Projets------") // Print the data @@ -547,15 +547,48 @@ func CreateProject() { fmt.Println("Create Task Success!") } +func InitialCheck() bool { + ret := true + + err := error(nil) + + variables_global.Config, err = functions.LoadConfigsByYamlFile() + + if err != nil { + fmt.Println("YAML File Problem", variables_constant.CLICKUP_TOKEN_NAME, " is empty!") + ret = false + } + + if os.Getenv(variables_constant.CLICKUP_TOKEN_NAME) == "" { + fmt.Println("Variable ", variables_constant.CLICKUP_TOKEN_NAME, " is empty!") + ret = false + } + + if os.Getenv(variables_constant.CONVISO_PLATFORM_TOKEN_NAME) == "" { + fmt.Println("Variable ", variables_constant.CONVISO_PLATFORM_TOKEN_NAME, " is empty!") + ret = false + } + + return ret +} + func main() { + if !InitialCheck() { + fmt.Println("You need to correct the above information before rerunning the application") + fmt.Println("Press the Enter Key to finish!") + fmt.Scanln() + os.Exit(0) + } + + // fmt.Println(variables_constant.CLICKUP_TOKEN_NAME + " " + os.Getenv(variables_constant.CLICKUP_TOKEN_NAME)) + // fmt.Println(variables_constant.CONVISO_PLATFORM_TOKEN_NAME + " " + os.Getenv(variables_constant.CONVISO_PLATFORM_TOKEN_NAME)) + integrationJustVerify := flag.Bool("iv", false, "Verify if clickup tasks is ok") integrationUpdateTasks := flag.Bool("iu", false, "Update Conviso Platform and ClickUp Tasks") deploy := flag.Bool("d", false, "See info about deploys") version := flag.Bool("v", false, "Script Version") - variables_global.Config = functions.LoadConfigsByYamlFile() - if variables_global.Config.ConfigGeneral.IntegrationDefault != -1 { variables_global.Customer = variables_global.Config.Integrations[variables_global.Config.ConfigGeneral.IntegrationDefault] } diff --git a/integration_platform_clickup_go/releases/IntegrationPlatformClickup-v01.00.03.tar.xz b/integration_platform_clickup_go/releases/IntegrationPlatformClickup-v01.00.03.tar.xz new file mode 100644 index 0000000..3973c37 Binary files /dev/null and b/integration_platform_clickup_go/releases/IntegrationPlatformClickup-v01.00.03.tar.xz differ diff --git a/integration_platform_clickup_go/services/service_conviso_platform/service_conviso_platform.go b/integration_platform_clickup_go/services/service_conviso_platform/service_conviso_platform.go index 104cc9b..d132847 100755 --- a/integration_platform_clickup_go/services/service_conviso_platform/service_conviso_platform.go +++ b/integration_platform_clickup_go/services/service_conviso_platform/service_conviso_platform.go @@ -381,11 +381,13 @@ func SearchRequimentsPlatform(reqSearch string) { client := &http.Client{Timeout: time.Second * 10} resp, err := client.Do(req) defer req.Body.Close() + if err != nil { fmt.Println("Error SearchRequimentsPlatform ClientDo: ", err.Error()) return } - data, _ := ioutil.ReadAll(resp.Body) + + data, _ := io.ReadAll(resp.Body) json.Unmarshal([]byte(string(data)), &result) diff --git a/integration_platform_clickup_go/utils/functions/functions.go b/integration_platform_clickup_go/utils/functions/functions.go index 147893a..f7f0444 100755 --- a/integration_platform_clickup_go/utils/functions/functions.go +++ b/integration_platform_clickup_go/utils/functions/functions.go @@ -2,6 +2,7 @@ package functions import ( "bufio" + "errors" "fmt" "integration_platform_clickup_go/types/type_config" "integration_platform_clickup_go/utils/variables_global" @@ -13,7 +14,7 @@ import ( "gopkg.in/yaml.v2" ) -func LoadConfigsByYamlFile() type_config.ConfigType { +func LoadConfigsByYamlFile() (type_config.ConfigType, error) { // Create a struct to hold the YAML data var config type_config.ConfigType @@ -22,18 +23,16 @@ func LoadConfigsByYamlFile() type_config.ConfigType { data, err := os.ReadFile("projects.yaml") if err != nil { - fmt.Println("Error ReadFile LoadConfigsByYamlFile: ", err.Error()) - return config + return config, errors.New("Error ReadFile " + err.Error()) } // Unmarshal the YAML data into the struct err = yaml.Unmarshal(data, &config) if err != nil { - fmt.Println("Error DataToStruct LoadConfigsByYamlFile: ", err.Error()) - return config + return config, errors.New("Error DataToStruct " + err.Error()) } - return config + return config, nil } func CustomerExistsYamlFileByClickUpListId(clickUpListId string, customers []type_config.ConfigTypeIntegration) (result bool) { @@ -76,6 +75,7 @@ func ConvertStringToArrayInt(var1 string) []int { // } func GetTextWithSpace(label string) string { + ret := "" EOL := byte('\r') @@ -90,8 +90,11 @@ func GetTextWithSpace(label string) string { if error != nil { fmt.Print("Error function GetTextWithSpace ", error) - return "" + return ret } - return strings.TrimSuffix(ret, string(EOL)) + ret = strings.Replace(ret, "\r", "", -1) + ret = strings.Replace(ret, "\n", "", -1) + + return ret } diff --git a/integration_platform_clickup_go/utils/variables_constant/variables_constant.go b/integration_platform_clickup_go/utils/variables_constant/variables_constant.go index 92f9476..53d3be1 100755 --- a/integration_platform_clickup_go/utils/variables_constant/variables_constant.go +++ b/integration_platform_clickup_go/utils/variables_constant/variables_constant.go @@ -1,6 +1,6 @@ package variables_constant -const VERSION = "1.0.2" +const VERSION = "1.0.3" // const CLICKUP_CUSTOMER_FIELD_ID = "4493a404-3ef7-4d7a-91e4-830ebc666353"