Got for loops and action references working
This commit is contained in:
+4
-41
@@ -170,6 +170,7 @@ type User struct {
|
|||||||
CreationTime int64 `datastore:"creation_time" json:"creation_time"`
|
CreationTime int64 `datastore:"creation_time" json:"creation_time"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// timeout maybe? idk
|
||||||
type session struct {
|
type session struct {
|
||||||
Username string `datastore:"Username,noindex"`
|
Username string `datastore:"Username,noindex"`
|
||||||
Session string `datastore:"session,noindex"`
|
Session string `datastore:"session,noindex"`
|
||||||
@@ -1399,19 +1400,6 @@ func handleInfo(resp http.ResponseWriter, request *http.Request) {
|
|||||||
// FIXME - check memcache here
|
// FIXME - check memcache here
|
||||||
// Get the item from the memcache
|
// Get the item from the memcache
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
//if item, err := memcache.Get(ctx, c.Value); err == memcache.ErrCacheMiss {
|
|
||||||
// // Not in cache
|
|
||||||
//} else if err != nil {
|
|
||||||
// log.Printf("Error getting item: %v", err)
|
|
||||||
//} else {
|
|
||||||
// var Userdata User
|
|
||||||
// err = json.Unmarshal(item.Value, &Userdata)
|
|
||||||
// if err == nil {
|
|
||||||
// resp.WriteHeader(200)
|
|
||||||
// resp.Write([]byte(`{"success": true, "reason": "OK"}`))
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
sessionToken := c.Value
|
sessionToken := c.Value
|
||||||
session, err := getSession(ctx, sessionToken)
|
session, err := getSession(ctx, sessionToken)
|
||||||
@@ -1440,7 +1428,7 @@ func handleInfo(resp http.ResponseWriter, request *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
expiration := time.Now().Add(1200 * time.Second)
|
expiration := time.Now().Add(3600 * time.Second)
|
||||||
http.SetCookie(resp, &http.Cookie{
|
http.SetCookie(resp, &http.Cookie{
|
||||||
Name: "session_token",
|
Name: "session_token",
|
||||||
Value: UserInfo.Session,
|
Value: UserInfo.Session,
|
||||||
@@ -1449,31 +1437,6 @@ func handleInfo(resp http.ResponseWriter, request *http.Request) {
|
|||||||
|
|
||||||
returnData := fmt.Sprintf(`{"success": true, "cookies": [{"key": "session_token", "value": "%s", "expiration": %d}]}`, UserInfo.Session, expiration.Unix())
|
returnData := fmt.Sprintf(`{"success": true, "cookies": [{"key": "session_token", "value": "%s", "expiration": %d}]}`, UserInfo.Session, expiration.Unix())
|
||||||
|
|
||||||
//b, err := json.Marshal(UserInfo)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Printf("Failed marshalling: %s", err)
|
|
||||||
// resp.WriteHeader(401)
|
|
||||||
// resp.Write([]byte(`{"success": false}`))
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
|
|
||||||
// Adding to cache here
|
|
||||||
// Only keeping it in for 24 hours
|
|
||||||
//item := &memcache.Item{
|
|
||||||
// Key: c.Value,
|
|
||||||
// Value: b,
|
|
||||||
// Expiration: time.Hour * 24,
|
|
||||||
//}
|
|
||||||
//if err := memcache.Add(ctx, item); err == memcache.ErrNotStored {
|
|
||||||
// if err := memcache.Set(ctx, item); err != nil {
|
|
||||||
// log.Printf("Error setting item: %v", err)
|
|
||||||
// }
|
|
||||||
//} else if err != nil {
|
|
||||||
// log.Printf("error adding item: %v", err)
|
|
||||||
//} else {
|
|
||||||
// log.Printf("Set cache for %s", item.Key)
|
|
||||||
//}
|
|
||||||
|
|
||||||
resp.WriteHeader(200)
|
resp.WriteHeader(200)
|
||||||
resp.Write([]byte(returnData))
|
resp.Write([]byte(returnData))
|
||||||
}
|
}
|
||||||
@@ -2008,7 +1971,7 @@ func handleLogin(resp http.ResponseWriter, request *http.Request) {
|
|||||||
// FIXME - have timeout here
|
// FIXME - have timeout here
|
||||||
if len(Userdata.Session) != 0 {
|
if len(Userdata.Session) != 0 {
|
||||||
//log.Println("Nonexisting session")
|
//log.Println("Nonexisting session")
|
||||||
expiration := time.Now().Add(1200 * time.Second)
|
expiration := time.Now().Add(3600 * time.Second)
|
||||||
|
|
||||||
http.SetCookie(resp, &http.Cookie{
|
http.SetCookie(resp, &http.Cookie{
|
||||||
Name: "session_token",
|
Name: "session_token",
|
||||||
@@ -2034,7 +1997,7 @@ func handleLogin(resp http.ResponseWriter, request *http.Request) {
|
|||||||
http.SetCookie(resp, &http.Cookie{
|
http.SetCookie(resp, &http.Cookie{
|
||||||
Name: "session_token",
|
Name: "session_token",
|
||||||
Value: sessionToken.String(),
|
Value: sessionToken.String(),
|
||||||
Expires: time.Now().Add(1200 * time.Second),
|
Expires: time.Now().Add(3600 * time.Second),
|
||||||
})
|
})
|
||||||
|
|
||||||
// ADD TO DATABASE
|
// ADD TO DATABASE
|
||||||
|
|||||||
@@ -737,11 +737,11 @@ const AngularWorkflow = (props) => {
|
|||||||
.then((responseJson) => {
|
.then((responseJson) => {
|
||||||
// FIXME - handle versions on left bar
|
// FIXME - handle versions on left bar
|
||||||
//handleAppVersioning(responseJson)
|
//handleAppVersioning(responseJson)
|
||||||
var tmpapps = []
|
//var tmpapps = []
|
||||||
tmpapps = tmpapps.concat(getExtraApps())
|
//tmpapps = tmpapps.concat(getExtraApps())
|
||||||
tmpapps = tmpapps.concat(responseJson)
|
//tmpapps = tmpapps.concat(responseJson)
|
||||||
setApps(tmpapps)
|
setApps(responseJson)
|
||||||
setFilteredApps(tmpapps)
|
setFilteredApps(responseJson)
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
alert.error(error.toString())
|
alert.error(error.toString())
|
||||||
|
|||||||
@@ -92,11 +92,13 @@ const App = (message, props) => {
|
|||||||
})
|
})
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(responseJson => {
|
.then(responseJson => {
|
||||||
|
console.log(responseJson)
|
||||||
if (responseJson.success === true) {
|
if (responseJson.success === true) {
|
||||||
setUserData(responseJson)
|
setUserData(responseJson)
|
||||||
setIsLoggedIn(true)
|
setIsLoggedIn(true)
|
||||||
|
|
||||||
// Updating cookie every request
|
// Updating cookie every request
|
||||||
|
console.log("COOKIES: ", cookies)
|
||||||
for (var key in responseJson["cookies"]) {
|
for (var key in responseJson["cookies"]) {
|
||||||
setCookie(responseJson["cookies"][key].key, responseJson["cookies"][key].value, {path: "/"})
|
setCookie(responseJson["cookies"][key].key, responseJson["cookies"][key].value, {path: "/"})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,8 +86,6 @@ class AppBase:
|
|||||||
"execution_id": self.current_execution_id
|
"execution_id": self.current_execution_id
|
||||||
}
|
}
|
||||||
|
|
||||||
self.logger.info("Auth: %s", tmpdata)
|
|
||||||
|
|
||||||
self.logger.info("Before FULLEXEC stream result")
|
self.logger.info("Before FULLEXEC stream result")
|
||||||
ret = requests.post(
|
ret = requests.post(
|
||||||
"%s/api/v1/streams/results" % (self.url),
|
"%s/api/v1/streams/results" % (self.url),
|
||||||
@@ -202,6 +200,13 @@ class AppBase:
|
|||||||
parameter["value"] = parameter["value"].replace(to_be_replaced, value)
|
parameter["value"] = parameter["value"].replace(to_be_replaced, value)
|
||||||
elif isinstance(value, dict):
|
elif isinstance(value, dict):
|
||||||
parameter["value"] = parameter["value"].replace(to_be_replaced, json.dumps(value))
|
parameter["value"] = parameter["value"].replace(to_be_replaced, json.dumps(value))
|
||||||
|
else:
|
||||||
|
print("Unknown type %s" % type(value))
|
||||||
|
try:
|
||||||
|
parameter["value"] = parameter["value"].replace(to_be_replaced, json.dumps(value))
|
||||||
|
except json.decoder.JSONDecodeError as e:
|
||||||
|
parameter["value"] = parameter["value"].replace(to_be_replaced, value)
|
||||||
|
|
||||||
|
|
||||||
if parameter["variant"] == "WORKFLOW_VARIABLE":
|
if parameter["variant"] == "WORKFLOW_VARIABLE":
|
||||||
for item in fullexecution["workflow"]["workflow_variables"]:
|
for item in fullexecution["workflow"]["workflow_variables"]:
|
||||||
@@ -228,6 +233,8 @@ class AppBase:
|
|||||||
|
|
||||||
if parameter["value"].startswith(jsonparsevalue):
|
if parameter["value"].startswith(jsonparsevalue):
|
||||||
fullname += parameter["value"][2:]
|
fullname += parameter["value"][2:]
|
||||||
|
else:
|
||||||
|
fullname = "$%s" % parameter["action_field"]
|
||||||
|
|
||||||
self.logger.info("Fullname: %s" % fullname)
|
self.logger.info("Fullname: %s" % fullname)
|
||||||
actualitem = re.findall(match, fullname, re.MULTILINE)
|
actualitem = re.findall(match, fullname, re.MULTILINE)
|
||||||
@@ -237,13 +244,23 @@ class AppBase:
|
|||||||
try:
|
try:
|
||||||
to_be_replaced = replace[0]
|
to_be_replaced = replace[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
print("Nothing to replace?: " % e)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# This will never be a loop aka multi argument
|
||||||
|
parameter["value"] = to_be_replaced
|
||||||
|
|
||||||
value = get_json_value(fullexecution, to_be_replaced)
|
value = get_json_value(fullexecution, to_be_replaced)
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
parameter["value"] = parameter["value"].replace(to_be_replaced, value)
|
parameter["value"] = parameter["value"].replace(to_be_replaced, value)
|
||||||
elif isinstance(value, dict):
|
elif isinstance(value, dict):
|
||||||
parameter["value"] = parameter["value"].replace(to_be_replaced, json.dumps(value))
|
parameter["value"] = parameter["value"].replace(to_be_replaced, json.dumps(value))
|
||||||
|
else:
|
||||||
|
print("Unknown type %s" % type(value))
|
||||||
|
try:
|
||||||
|
parameter["value"] = parameter["value"].replace(to_be_replaced, json.dumps(value))
|
||||||
|
except json.decoder.JSONDecodeError as e:
|
||||||
|
parameter["value"] = parameter["value"].replace(to_be_replaced, value)
|
||||||
|
|
||||||
return "", parameter["value"]
|
return "", parameter["value"]
|
||||||
|
|
||||||
@@ -459,12 +476,14 @@ class AppBase:
|
|||||||
# With this parameter ready, add it to... a greater list of parameters. Rofl
|
# With this parameter ready, add it to... a greater list of parameters. Rofl
|
||||||
multi_parameters[parameter["name"]] = resultarray
|
multi_parameters[parameter["name"]] = resultarray
|
||||||
else:
|
else:
|
||||||
|
print("Hello, in here?: %s" % value)
|
||||||
params[parameter["name"]] = value
|
params[parameter["name"]] = value
|
||||||
multi_parameters[parameter["name"]] = value
|
multi_parameters[parameter["name"]] = value
|
||||||
|
|
||||||
# FIXME - this is horrible, but works for now
|
# FIXME - this is horrible, but works for now
|
||||||
#for i in range(calltimes):
|
#for i in range(calltimes):
|
||||||
if not multiexecution:
|
if not multiexecution:
|
||||||
|
print("Params: %s" % params)
|
||||||
print("RUNNING NORMAL EXECUTION")
|
print("RUNNING NORMAL EXECUTION")
|
||||||
result += await func(**params)
|
result += await func(**params)
|
||||||
else:
|
else:
|
||||||
@@ -473,6 +492,7 @@ class AppBase:
|
|||||||
# 2. Find the right value from the parsed multi_params
|
# 2. Find the right value from the parsed multi_params
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
|
json_object = False
|
||||||
for i in range(0, minlength):
|
for i in range(0, minlength):
|
||||||
# To be able to use the results as a list:
|
# To be able to use the results as a list:
|
||||||
baseparams = json.loads(json.dumps(multi_parameters))
|
baseparams = json.loads(json.dumps(multi_parameters))
|
||||||
@@ -489,11 +509,28 @@ class AppBase:
|
|||||||
baseparams[key] = "KeyError: %s" % e
|
baseparams[key] = "KeyError: %s" % e
|
||||||
|
|
||||||
#print("Running with params %s" % baseparams)
|
#print("Running with params %s" % baseparams)
|
||||||
results.append(await func(**baseparams))
|
ret = await func(**baseparams)
|
||||||
|
print("Inner ret: %s" % ret)
|
||||||
|
|
||||||
|
try:
|
||||||
|
results.append(json.loads(ret))
|
||||||
|
json_object = True
|
||||||
|
except json.decoder.JSONDecodeError as e:
|
||||||
|
results.append(ret)
|
||||||
|
|
||||||
# Dump the result as a string of a list
|
# Dump the result as a string of a list
|
||||||
result = json.dumps(", ".join(results))
|
print("RESULTS: %s" % results)
|
||||||
|
if isinstance(results, list):
|
||||||
|
print("JSON OBJECT? ", json_object)
|
||||||
|
if json_object:
|
||||||
|
result = json.dumps(results)
|
||||||
|
else:
|
||||||
|
result = "[\""+"\", \"".join(results)+"\"]"
|
||||||
|
else:
|
||||||
|
print("Normal result?")
|
||||||
|
result = results
|
||||||
|
|
||||||
|
print("RESULT: %s" % result)
|
||||||
|
|
||||||
action_result["status"] = "SUCCESS"
|
action_result["status"] = "SUCCESS"
|
||||||
action_result["result"] = str(result)
|
action_result["result"] = str(result)
|
||||||
@@ -520,7 +557,7 @@ class AppBase:
|
|||||||
action_result["completed_at"] = int(time.time())
|
action_result["completed_at"] = int(time.time())
|
||||||
|
|
||||||
# I wonder if this actually works
|
# I wonder if this actually works
|
||||||
#self.logger.info("Before last stream result")
|
self.logger.info("Before last stream result")
|
||||||
try:
|
try:
|
||||||
ret = requests.post("%s%s" % (self.url, stream_path), headers=headers, json=action_result)
|
ret = requests.post("%s%s" % (self.url, stream_path), headers=headers, json=action_result)
|
||||||
self.logger.info("Result: %d" % ret.status_code)
|
self.logger.info("Result: %d" % ret.status_code)
|
||||||
|
|||||||
Binary file not shown.
@@ -343,6 +343,7 @@ func runFilter(workflowExecution WorkflowExecution, action Action) {
|
|||||||
if action.Parameters[0].Variant == "ACTION_RESULT" {
|
if action.Parameters[0].Variant == "ACTION_RESULT" {
|
||||||
param := action.Parameters[0]
|
param := action.Parameters[0]
|
||||||
value := param.Value
|
value := param.Value
|
||||||
|
_ = value
|
||||||
|
|
||||||
// Loop cases.. Hmm, that's tricky
|
// Loop cases.. Hmm, that's tricky
|
||||||
}
|
}
|
||||||
@@ -398,21 +399,25 @@ func handleExecution(client *http.Client, req *http.Request, workflowExecution W
|
|||||||
}
|
}
|
||||||
|
|
||||||
pullOptions := types.ImagePullOptions{}
|
pullOptions := types.ImagePullOptions{}
|
||||||
|
_ = pullOptions
|
||||||
for _, image := range onpremApps {
|
for _, image := range onpremApps {
|
||||||
log.Printf("Image: %s", image)
|
log.Printf("Image: %s", image)
|
||||||
|
// Kind of gambling that the image exists.
|
||||||
if strings.Contains(image, " ") {
|
if strings.Contains(image, " ") {
|
||||||
image = strings.ReplaceAll(image, " ", "-")
|
image = strings.ReplaceAll(image, " ", "-")
|
||||||
}
|
}
|
||||||
|
|
||||||
reader, err := dockercli.ImagePull(context.Background(), image, pullOptions)
|
// FIXME: Reimplement for speed later
|
||||||
if err != nil {
|
// Skip to make it faster
|
||||||
log.Printf("Failed getting %s. The app is missing or some other issue", image)
|
//reader, err := dockercli.ImagePull(context.Background(), image, pullOptions)
|
||||||
//shutdown(workflowExecution.ExecutionId)
|
//if err != nil {
|
||||||
}
|
// log.Printf("Failed getting %s. The app is missing or some other issue", image)
|
||||||
|
// shutdown(workflowExecution.ExecutionId)
|
||||||
|
//}
|
||||||
|
|
||||||
//io.Copy(os.Stdout, reader)
|
////io.Copy(os.Stdout, reader)
|
||||||
_ = reader
|
//_ = reader
|
||||||
log.Printf("Successfully downloaded and built %s", image)
|
//log.Printf("Successfully downloaded and built %s", image)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process the parents etc. How?
|
// Process the parents etc. How?
|
||||||
|
|||||||
Reference in New Issue
Block a user