Minor JSON fixes for SDK

This commit is contained in:
frikky
2023-05-11 11:39:01 +02:00
parent 30ba687d60
commit 70edb366a9
10 changed files with 521 additions and 306 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
#FROM python:3.9.1-alpine as base
FROM python:3.10.0-alpine as base
#FROM python:3.10.0-alpine as base
FROM python:3.11.3-alpine as base
FROM base as builder
RUN apk --no-cache add --update alpine-sdk libffi libffi-dev musl-dev openssl-dev tzdata coreutils
+11 -3
View File
@@ -2279,6 +2279,13 @@ class AppBase:
# Can't handle self yet (?)
ret = run.render(**globals())
# Load output as JSON
try:
ret = json.loads(ret)
except:
pass
return ret
except jinja2.exceptions.TemplateNotFound as e:
self.logger.info(f"[ERROR] Liquid Template error: {e}")
@@ -3064,7 +3071,6 @@ class AppBase:
#self.logger.info(action["parameters"])
# This seems redundant now
self.logger.info("[DEBUG] Pre parameters")
for parameter in newparams:
action["parameters"].append(parameter)
@@ -3086,7 +3092,6 @@ class AppBase:
# Multi_parameter has the data for each. variable
minlength = 0
self.logger.info("[DEBUG] Pre-loading parameters")
multi_parameters = json.loads(json.dumps(params))
multiexecution = False
multi_execution_lists = []
@@ -3513,8 +3518,11 @@ class AppBase:
try:
del params[field]
self.logger.info("[WARNING] Removed field invalid field %s" % field)
except KeyError:
except KeyError as e:
self.logger.info("[WARNING] Tried to remove field %s but it didn't exist" % field)
break
else:
self.logger.info("[ERROR] Couldn't find fieldsplit in error. Raw error: %s" % errorstring)
else:
newres = json.dumps({
"success": False,
+7 -7
View File
@@ -1923,7 +1923,7 @@ func loadGithubWorkflows(url, username, password, userId, branch, orgId string)
storer := memory.NewStorage()
r, err := git.Clone(storer, fs, cloneOptions)
if err != nil {
log.Printf("Failed loading repo %s into memory (github workflows): %s", url, err)
log.Printf("[INFO] Failed loading repo %s into memory (github workflows): %s", url, err)
return err
}
@@ -3107,8 +3107,8 @@ func LoadSpecificApps(resp http.ResponseWriter, request *http.Request) {
var tmpBody tmpStruct
err = json.Unmarshal(body, &tmpBody)
if err != nil {
log.Printf("Error with unmarshal tmpBody: %s", err)
resp.WriteHeader(401)
log.Printf("[WARNING] Error with unmarshal app git clone: %s", err)
resp.WriteHeader(500)
resp.Write([]byte(`{"success": false}`))
return
}
@@ -3135,20 +3135,20 @@ func LoadSpecificApps(resp http.ResponseWriter, request *http.Request) {
storer := memory.NewStorage()
r, err := git.Clone(storer, fs, cloneOptions)
if err != nil {
log.Printf("Failed loading repo %s into memory (github workflows 2): %s", tmpBody.URL, err)
resp.WriteHeader(401)
log.Printf("[WARNING] Failed loading repo %s into memory (github apps 2): %s", tmpBody.URL, err)
resp.WriteHeader(500)
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "%s"}`, err)))
return
}
dir, err := fs.ReadDir("/")
if err != nil {
log.Printf("FAiled reading folder: %s", err)
log.Printf("[WARNING] FAiled reading folder: %s", err)
}
_ = r
if tmpBody.ForceUpdate {
log.Printf("[AUDIT] Running with force update from user %s (%s) for %s!", user.Username, user.Id, tmpBody.URL)
log.Printf("[AUDIT] Running app get with force update from user %s (%s) for %s!", user.Username, user.Id, tmpBody.URL)
} else {
log.Printf("[AUDIT] Updating apps with updates for user %s (%s) for %s (no force)", user.Username, user.Id, tmpBody.URL)
}