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 (
"net/http"
"os"
"path/filepath"
"strconv"
"strings"
"sync"
)
......@@ -176,7 +177,7 @@ func decidePackageVersionRange(packageName, frameworkVersion string, indexJsons
// If frameworkVersion != "", then I find the latest available package for this framework.
// 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.
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
// on a json syntax error.
//
......@@ -204,7 +205,9 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i
jCatalogEntry := jPkgVersionItem["catalogEntry"].(map[string]interface{})
myVersionText := jCatalogEntry["version"].(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
thisPkgVersionIsOk, thisPkgVersionIsPossibleOk := false, false
......@@ -214,7 +217,9 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i
for _, j6 := range j5.([]interface{}) {
j7 := j6.(map[string]interface{})
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)) {
thisPkgVersionIsOk = true
break
......@@ -231,6 +236,9 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i
}
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.
// They only provide parts of the version number. It sucks.
thisPkgVersionIsOk = packageVersion == myVersionText
......@@ -261,7 +269,9 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i
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
}
}
......@@ -299,9 +309,9 @@ func main() {
pkgVer, targetUrl, targetUrlLogin := "", "", ""
if strings.HasPrefix(pkgVerOrNetVer, "net") {
pkgVer, targetUrl, targetUrlLogin = decidePackageVersion(pkgVerOrNetVer, "", indexJsons, indexJsons_Login)
} else {
pkgVer, targetUrl, targetUrlLogin = decidePackageVersion("", pkgVerOrNetVer, indexJsons, indexJsons_Login)
pkgVer, targetUrl, targetUrlLogin = decidePackageVersion(pkgVerOrNetVer, "", indexJsons, indexJsons_Login, os.Getenv("OPENXT_DEBUG") == "1")
} else {
pkgVer, targetUrl, targetUrlLogin = decidePackageVersion("", pkgVerOrNetVer, indexJsons, indexJsons_Login, os.Getenv("OPENXT_DEBUG") == "1")
}
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