Skip to content
Snippets Groups Projects
Commit d13ae7f2 authored by Recolic K's avatar Recolic K
Browse files

allow debug output

parent 2722074e
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
"strconv"
"strings" "strings"
"sync" "sync"
) )
...@@ -176,7 +177,7 @@ func decidePackageVersionRange(packageName, frameworkVersion string, indexJsons ...@@ -176,7 +177,7 @@ func decidePackageVersionRange(packageName, frameworkVersion string, indexJsons
// If frameworkVersion != "", then I find the latest available package for this framework. // If frameworkVersion != "", then I find the latest available package for this framework.
// If packageVersion != "", then I find the url for this version. // If packageVersion != "", then I find the url for this version.
// You must only set ONE OF THEM! If you set both, the `frameworkVersion` would be ignored. // You must only set ONE OF THEM! If you set both, the `frameworkVersion` would be ignored.
func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, indexJsons_Login []string) (maxAvailableVersion, maxAvailableVersionUrl, maxAvailableVersionUrlLogin string) { func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, indexJsons_Login []string, debugOutput bool) (maxAvailableVersion, maxAvailableVersionUrl, maxAvailableVersionUrlLogin string) {
// The golang json parse library sucks. Prevent it from crashing // The golang json parse library sucks. Prevent it from crashing
// on a json syntax error. // on a json syntax error.
// //
...@@ -204,7 +205,9 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i ...@@ -204,7 +205,9 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i
jCatalogEntry := jPkgVersionItem["catalogEntry"].(map[string]interface{}) jCatalogEntry := jPkgVersionItem["catalogEntry"].(map[string]interface{})
myVersionText := jCatalogEntry["version"].(string) myVersionText := jCatalogEntry["version"].(string)
myVersionUrl := jPkgVersionItem["packageContent"].(string) myVersionUrl := jPkgVersionItem["packageContent"].(string)
// log.Println("DEBUG: reaching " + myVersionText) if debugOutput {
log.Println("DEBUG: reaching " + myVersionText)
}
// Let's check if this version is ok // Let's check if this version is ok
thisPkgVersionIsOk, thisPkgVersionIsPossibleOk := false, false thisPkgVersionIsOk, thisPkgVersionIsPossibleOk := false, false
...@@ -214,7 +217,9 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i ...@@ -214,7 +217,9 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i
for _, j6 := range j5.([]interface{}) { for _, j6 := range j5.([]interface{}) {
j7 := j6.(map[string]interface{}) j7 := j6.(map[string]interface{})
if j8, ok := j7["targetFramework"]; ok { if j8, ok := j7["targetFramework"]; ok {
// log.Println("DEBUG: " + frameworkVersion +" vs "+ netVersionNugetFormatToStandardFormat(j8.(string))) if debugOutput {
log.Println("DEBUG: " + frameworkVersion +" vs "+ netVersionNugetFormatToStandardFormat(j8.(string)))
}
if frameworkVersion == netVersionNugetFormatToStandardFormat(j8.(string)) { if frameworkVersion == netVersionNugetFormatToStandardFormat(j8.(string)) {
thisPkgVersionIsOk = true thisPkgVersionIsOk = true
break break
...@@ -231,6 +236,9 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i ...@@ -231,6 +236,9 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i
} }
if packageVersion != "" { if packageVersion != "" {
if debugOutput {
log.Println("DEBUG: " + packageVersion + " vs " + myVersionText)
}
// It should be a percise match here. However, someone in ControlPlane using PkgNewtonsoft_json_12. // It should be a percise match here. However, someone in ControlPlane using PkgNewtonsoft_json_12.
// They only provide parts of the version number. It sucks. // They only provide parts of the version number. It sucks.
thisPkgVersionIsOk = packageVersion == myVersionText thisPkgVersionIsOk = packageVersion == myVersionText
...@@ -261,7 +269,9 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i ...@@ -261,7 +269,9 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i
PossibleAvailableVersionUrlLogin = indexJsons_Login[indexJson_currIndex] PossibleAvailableVersionUrlLogin = indexJsons_Login[indexJson_currIndex]
} }
} }
// log.Println("DEBUG: leaving " + myVersionText) if(debugOutput) {
log.Println("DEBUG: leaving " + myVersionText + ". IsOk=" + strconv.FormatBool(thisPkgVersionIsOk) + ", IsPossibleOk=" + strconv.FormatBool(thisPkgVersionIsPossibleOk))
}
}() // catch exception and continue }() // catch exception and continue
} }
} }
...@@ -299,9 +309,9 @@ func main() { ...@@ -299,9 +309,9 @@ func main() {
pkgVer, targetUrl, targetUrlLogin := "", "", "" pkgVer, targetUrl, targetUrlLogin := "", "", ""
if strings.HasPrefix(pkgVerOrNetVer, "net") { if strings.HasPrefix(pkgVerOrNetVer, "net") {
pkgVer, targetUrl, targetUrlLogin = decidePackageVersion(pkgVerOrNetVer, "", indexJsons, indexJsons_Login) pkgVer, targetUrl, targetUrlLogin = decidePackageVersion(pkgVerOrNetVer, "", indexJsons, indexJsons_Login, os.Getenv("OPENXT_DEBUG") == "1")
} else { } else {
pkgVer, targetUrl, targetUrlLogin = decidePackageVersion("", pkgVerOrNetVer, indexJsons, indexJsons_Login) pkgVer, targetUrl, targetUrlLogin = decidePackageVersion("", pkgVerOrNetVer, indexJsons, indexJsons_Login, os.Getenv("OPENXT_DEBUG") == "1")
} }
if pkgVer == "" { if pkgVer == "" {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment