Improve execution speed from app side
This commit is contained in:
+84
-55
@@ -21,25 +21,36 @@ class AppBase:
|
|||||||
# authorization is for the specific workflow
|
# authorization is for the specific workflow
|
||||||
self.url = os.getenv("CALLBACK_URL", "https://shuffler.io")
|
self.url = os.getenv("CALLBACK_URL", "https://shuffler.io")
|
||||||
self.action = os.getenv("ACTION", "")
|
self.action = os.getenv("ACTION", "")
|
||||||
self.apikey = os.getenv("FUNCTION_APIKEY", "")
|
|
||||||
self.authorization = os.getenv("AUTHORIZATION", "")
|
self.authorization = os.getenv("AUTHORIZATION", "")
|
||||||
self.current_execution_id = os.getenv("EXECUTIONID", "")
|
self.current_execution_id = os.getenv("EXECUTIONID", "")
|
||||||
|
self.full_execution = os.getenv("FULL_EXECUTION", "")
|
||||||
if len(self.action) == 0:
|
|
||||||
print("ACTION env not defined")
|
|
||||||
sys.exit(0)
|
|
||||||
if len(self.apikey) == 0:
|
|
||||||
print("FUNCTION_APIKEY env not defined")
|
|
||||||
sys.exit(0)
|
|
||||||
if len(self.authorization) == 0:
|
|
||||||
print("AUTHORIZATION env not defined")
|
|
||||||
sys.exit(0)
|
|
||||||
if len(self.current_execution_id) == 0:
|
|
||||||
print("EXECUTIONID env not defined")
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
if isinstance(self.action, str):
|
if isinstance(self.action, str):
|
||||||
self.action = json.loads(self.action)
|
self.action = json.loads(self.action)
|
||||||
|
|
||||||
|
def send_result(self, action_result, headers, stream_path):
|
||||||
|
if action_result["status"] == "EXECUTING":
|
||||||
|
action_result["status"] = "FAILURE"
|
||||||
|
|
||||||
|
# I wonder if this actually works
|
||||||
|
self.logger.info("Before last stream result")
|
||||||
|
try:
|
||||||
|
ret = requests.post("%s%s" % (self.url, stream_path), headers=headers, json=action_result)
|
||||||
|
self.logger.info("Result: %d" % ret.status_code)
|
||||||
|
if ret.status_code != 200:
|
||||||
|
self.logger.info(ret.text)
|
||||||
|
except requests.exceptions.ConnectionError as e:
|
||||||
|
self.logger.exception(e)
|
||||||
|
return
|
||||||
|
except TypeError as e:
|
||||||
|
self.logger.exception(e)
|
||||||
|
action_result["status"] = "FAILURE"
|
||||||
|
action_result["result"] = "POST error: %s" % e
|
||||||
|
self.logger.info("Before typeerror stream result")
|
||||||
|
ret = requests.post("%s%s" % (self.url, stream_path), headers=headers, json=action_result)
|
||||||
|
self.logger.info("Result: %d" % ret.status_code)
|
||||||
|
if ret.status_code != 200:
|
||||||
|
self.logger.info(ret.text)
|
||||||
|
|
||||||
async def execute_action(self, action):
|
async def execute_action(self, action):
|
||||||
# FIXME - add request for the function STARTING here. Use "results stream" or something
|
# FIXME - add request for the function STARTING here. Use "results stream" or something
|
||||||
@@ -58,9 +69,25 @@ class AppBase:
|
|||||||
}
|
}
|
||||||
self.logger.info("ACTION RESULT: %s", action_result)
|
self.logger.info("ACTION RESULT: %s", action_result)
|
||||||
|
|
||||||
|
if len(self.action) == 0:
|
||||||
|
print("ACTION env not defined")
|
||||||
|
action_result["result"] = "Error in setup ENV: ACTION not defined"
|
||||||
|
self.send_result(action_result, headers, stream_path)
|
||||||
|
return
|
||||||
|
if len(self.authorization) == 0:
|
||||||
|
print("AUTHORIZATION env not defined")
|
||||||
|
action_result["result"] = "Error in setup ENV: AUTHORIZATION not defined"
|
||||||
|
self.send_result(action_result, headers, stream_path)
|
||||||
|
return
|
||||||
|
if len(self.current_execution_id) == 0:
|
||||||
|
print("EXECUTIONID env not defined")
|
||||||
|
action_result["result"] = "Error in setup ENV: EXECUTIONID not defined"
|
||||||
|
self.send_result(action_result, headers, stream_path)
|
||||||
|
return
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"Authorization": "Bearer %s" % self.apikey
|
"Authorization": "Bearer %s" % self.authorization
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add async logger
|
# Add async logger
|
||||||
@@ -73,33 +100,53 @@ class AppBase:
|
|||||||
self.logger.info(ret.text)
|
self.logger.info(ret.text)
|
||||||
except requests.exceptions.ConnectionError as e:
|
except requests.exceptions.ConnectionError as e:
|
||||||
print("Connectionerror: %s" % e)
|
print("Connectionerror: %s" % e)
|
||||||
|
|
||||||
|
action_result["result"] = "Bad setup during startup: %d" % e
|
||||||
|
self.send_result(action_result, headers, stream_path)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Verify whether there are any parameters with ACTION_RESULT required
|
# Verify whether there are any parameters with ACTION_RESULT required
|
||||||
# If found, we get the full results list from backend
|
# If found, we get the full results list from backend
|
||||||
fullexecution = {}
|
fullexecution = {}
|
||||||
try:
|
if len(self.full_execution) == 0:
|
||||||
tmpdata = {
|
print("NO EXECUTION - LOADING!")
|
||||||
"authorization": self.authorization,
|
try:
|
||||||
"execution_id": self.current_execution_id
|
tmpdata = {
|
||||||
}
|
"authorization": self.authorization,
|
||||||
|
"execution_id": self.current_execution_id
|
||||||
|
}
|
||||||
|
|
||||||
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),
|
||||||
headers=headers,
|
headers=headers,
|
||||||
json=tmpdata
|
json=tmpdata
|
||||||
)
|
)
|
||||||
|
|
||||||
if ret.status_code == 200:
|
if ret.status_code == 200:
|
||||||
fullexecution = ret.json()
|
fullexecution = ret.json()
|
||||||
else:
|
else:
|
||||||
self.logger.info("Error: Data: ", ret.json())
|
self.logger.info("Error: Data: ", ret.json())
|
||||||
self.logger.info("Error with status code for results. Crashing because ACTION_RESULTS or WORKFLOW_VARIABLE can't be handled. Status: %d" % ret.status_code)
|
self.logger.info("Error with status code for results. Crashing because ACTION_RESULTS or WORKFLOW_VARIABLE can't be handled. Status: %d" % ret.status_code)
|
||||||
|
action_result["result"] = "Bad result from backend: %d" % ret.status_code
|
||||||
|
self.send_result(action_result, headers, stream_path)
|
||||||
|
return
|
||||||
|
except requests.exceptions.ConnectionError as e:
|
||||||
|
self.logger.info("Connectionerror: %s" % e)
|
||||||
|
action_result["result"] = "Connection error during startup: %s" % e
|
||||||
|
self.send_result(action_result, headers, stream_path)
|
||||||
return
|
return
|
||||||
except requests.exceptions.ConnectionError as e:
|
else:
|
||||||
self.logger.info("Connectionerror: %s" % e)
|
try:
|
||||||
return
|
fullexecution = json.loads(self.full_execution)
|
||||||
|
except json.decoder.JSONDecodeError as e:
|
||||||
|
print("Json decode execution error: %s" % e)
|
||||||
|
action_result["result"] = "Json error during startup: %s" % e
|
||||||
|
self.send_result(action_result, headers, stream_path)
|
||||||
|
return
|
||||||
|
|
||||||
|
print("")
|
||||||
|
|
||||||
|
|
||||||
self.logger.info("AFTER FULLEXEC stream result")
|
self.logger.info("AFTER FULLEXEC stream result")
|
||||||
|
|
||||||
@@ -886,27 +933,9 @@ class AppBase:
|
|||||||
|
|
||||||
action_result["completed_at"] = int(time.time())
|
action_result["completed_at"] = int(time.time())
|
||||||
|
|
||||||
# I wonder if this actually works
|
# Send the result :)
|
||||||
self.logger.info("Before last stream result")
|
self.send_result(action_result, headers, stream_path)
|
||||||
try:
|
return
|
||||||
ret = requests.post("%s%s" % (self.url, stream_path), headers=headers, json=action_result)
|
|
||||||
self.logger.info("Result: %d" % ret.status_code)
|
|
||||||
if ret.status_code != 200:
|
|
||||||
self.logger.info(ret.text)
|
|
||||||
except requests.exceptions.ConnectionError as e:
|
|
||||||
self.logger.exception(e)
|
|
||||||
return
|
|
||||||
except TypeError as e:
|
|
||||||
self.logger.exception(e)
|
|
||||||
action_result["status"] = "FAILURE"
|
|
||||||
action_result["result"] = "POST error: %s" % e
|
|
||||||
self.logger.info("Before typeerror stream result")
|
|
||||||
ret = requests.post("%s%s" % (self.url, stream_path), headers=headers, json=action_result)
|
|
||||||
self.logger.info("Result: %d" % ret.status_code)
|
|
||||||
if ret.status_code != 200:
|
|
||||||
self.logger.info(ret.text)
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
#STOPCOPY
|
#STOPCOPY
|
||||||
|
|||||||
@@ -4644,7 +4644,7 @@ func iterateAppGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra strin
|
|||||||
found = true
|
found = true
|
||||||
|
|
||||||
action.Parameters[index].Configuration = true
|
action.Parameters[index].Configuration = true
|
||||||
log.Printf("Set config to true for field %s!", param.Name)
|
//log.Printf("Set config to true for field %s!", param.Name)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ COPY --from=builder /usr/src/app/certs/privkey.pem /etc/nginx/privkey.pem
|
|||||||
|
|
||||||
# install CONFD
|
# install CONFD
|
||||||
ENV CONFD_VERSION 0.16.0
|
ENV CONFD_VERSION 0.16.0
|
||||||
|
RUN apt-get update && apt-get install -y curl && apt-get clean
|
||||||
RUN curl -sSL https://github.com/kelseyhightower/confd/releases/download/v${CONFD_VERSION}/confd-${CONFD_VERSION}-linux-amd64 -o /usr/local/bin/confd && \
|
RUN curl -sSL https://github.com/kelseyhightower/confd/releases/download/v${CONFD_VERSION}/confd-${CONFD_VERSION}-linux-amd64 -o /usr/local/bin/confd && \
|
||||||
chmod +x /usr/local/bin/confd
|
chmod +x /usr/local/bin/confd
|
||||||
COPY ./confd /etc/confd
|
COPY ./confd /etc/confd
|
||||||
|
|||||||
@@ -2633,7 +2633,7 @@ const AngularWorkflow = (props) => {
|
|||||||
},
|
},
|
||||||
endAdornment: (
|
endAdornment: (
|
||||||
<InputAdornment position="end">
|
<InputAdornment position="end">
|
||||||
<Tooltip color="primary" title="Autocomplete text" placement="top">
|
<Tooltip title="Autocomplete text" placement="top">
|
||||||
<AddCircleOutlineIcon style={{cursor: "pointer"}} onClick={() => {
|
<AddCircleOutlineIcon style={{cursor: "pointer"}} onClick={() => {
|
||||||
setShowDropdownNumber(count)
|
setShowDropdownNumber(count)
|
||||||
setShowDropdown(true)
|
setShowDropdown(true)
|
||||||
@@ -2998,6 +2998,8 @@ const AngularWorkflow = (props) => {
|
|||||||
paddingLeft: 10,
|
paddingLeft: 10,
|
||||||
minHeight: "100%",
|
minHeight: "100%",
|
||||||
zIndex: 1000,
|
zIndex: 1000,
|
||||||
|
resize: "horizontal",
|
||||||
|
overflow: "auto",
|
||||||
}
|
}
|
||||||
|
|
||||||
const defineStartnode = () => {
|
const defineStartnode = () => {
|
||||||
|
|||||||
@@ -954,9 +954,9 @@ const Workflows = (props) => {
|
|||||||
<Divider style={{marginBottom: "10px", height: "1px", width: "100%", backgroundColor: dividerColor}}/>
|
<Divider style={{marginBottom: "10px", height: "1px", width: "100%", backgroundColor: dividerColor}}/>
|
||||||
|
|
||||||
<div style={scrollStyle}>
|
<div style={scrollStyle}>
|
||||||
{workflows.map(data => {
|
{workflows.map((data, index) => {
|
||||||
return (
|
return (
|
||||||
<WorkflowPaper data={data} />
|
<WorkflowPaper key={index} data={data} />
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+211
-122
@@ -25,29 +25,34 @@ var baseUrl = os.Getenv("BASE_URL")
|
|||||||
var baseimagename = "frikky/shuffle"
|
var baseimagename = "frikky/shuffle"
|
||||||
var sleepTime = 2
|
var sleepTime = 2
|
||||||
|
|
||||||
type Condition struct {
|
type User struct {
|
||||||
AppName string `json:"app_name"`
|
Username string `datastore:"Username" json:"username"`
|
||||||
AppVersion string `json:"app_version"`
|
Password string `datastore:"password,noindex" password:"password,omitempty"`
|
||||||
Conditional string `json:"conditional"`
|
Session string `datastore:"session,noindex" json:"session"`
|
||||||
Errors []string `json:"errors"`
|
Verified bool `datastore:"verified,noindex" json:"verified"`
|
||||||
ID string `json:"id"`
|
PrivateApps []WorkflowApp `datastore:"privateapps" json:"privateapps":`
|
||||||
IsValid bool `json:"is_valid"`
|
Role string `datastore:"role" json:"role"`
|
||||||
Label string `json:"label"`
|
Roles []string `datastore:"roles" json:"roles"`
|
||||||
Name string `json:"name"`
|
VerificationToken string `datastore:"verification_token" json:"verification_token"`
|
||||||
Position struct {
|
ApiKey string `datastore:"apikey" json:"apikey"`
|
||||||
X float64 `json:"x"`
|
ResetReference string `datastore:"reset_reference" json:"reset_reference"`
|
||||||
Y float64 `json:"y"`
|
ResetTimeout int64 `datastore:"reset_timeout,noindex" json:"reset_timeout"`
|
||||||
} `json:"position"`
|
Id string `datastore:"id" json:"id"`
|
||||||
|
Orgs []string `datastore:"orgs" json:"orgs"`
|
||||||
|
CreationTime int64 `datastore:"creation_time" json:"creation_time"`
|
||||||
|
Active bool `datastore:"active" json:"active"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type User struct {
|
type ExecutionRequest struct {
|
||||||
Username string `datastore:"Username"`
|
ExecutionId string `json:"execution_id"`
|
||||||
Password string `datastore:"password,noindex"`
|
ExecutionArgument string `json:"execution_argument"`
|
||||||
Session string `datastore:"session,noindex"`
|
ExecutionSource string `json:"execution_source"`
|
||||||
Verified bool `datastore:"verified,noindex"`
|
WorkflowId string `json:"workflow_id"`
|
||||||
ApiKey string `datastore:"apikey,noindex"`
|
Environments []string `json:"environments"`
|
||||||
Id string `datastore:"id" json:"id"`
|
Authorization string `json:"authorization"`
|
||||||
Orgs string `datastore:"orgs" json:"orgs"`
|
Status string `json:"status"`
|
||||||
|
Start string `json:"start"`
|
||||||
|
Type string `json:"type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Org struct {
|
type Org struct {
|
||||||
@@ -57,12 +62,106 @@ type Org struct {
|
|||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AppAuthenticationStorage struct {
|
||||||
|
Active bool `json:"active" datastore:"active"`
|
||||||
|
Label string `json:"label" datastore:"label"`
|
||||||
|
Id string `json:"id" datastore:"id"`
|
||||||
|
App WorkflowApp `json:"app" datastore:"app"`
|
||||||
|
Fields []AuthenticationStore `json:"fields" datastore:"fields"`
|
||||||
|
Usage []AuthenticationUsage `json:"usage" datastore:"usage"`
|
||||||
|
WorkflowCount int64 `json:"workflow_count" datastore:"workflow_count"`
|
||||||
|
NodeCount int64 `json:"node_count" datastore:"node_count"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AuthenticationUsage struct {
|
||||||
|
WorkflowId string `json:"workflow_id" datastore:"workflow_id"`
|
||||||
|
Nodes []string `json:"nodes" datastore:"nodes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// An app inside Shuffle
|
||||||
|
type WorkflowApp struct {
|
||||||
|
Name string `json:"name" yaml:"name" required:true datastore:"name"`
|
||||||
|
IsValid bool `json:"is_valid" yaml:"is_valid" required:true datastore:"is_valid"`
|
||||||
|
ID string `json:"id" yaml:"id,omitempty" required:false datastore:"id"`
|
||||||
|
Link string `json:"link" yaml:"link" required:false datastore:"link,noindex"`
|
||||||
|
AppVersion string `json:"app_version" yaml:"app_version" required:true datastore:"app_version"`
|
||||||
|
Generated bool `json:"generated" yaml:"generated" required:false datastore:"generated"`
|
||||||
|
Downloaded bool `json:"downloaded" yaml:"downloaded" required:false datastore:"downloaded"`
|
||||||
|
Sharing bool `json:"sharing" yaml:"sharing" required:false datastore:"sharing"`
|
||||||
|
Verified bool `json:"verified" yaml:"verified" required:false datastore:"verified"`
|
||||||
|
Activated bool `json:"activated" yaml:"activated" required:false datastore:"activated"`
|
||||||
|
Tested bool `json:"tested" yaml:"tested" required:false datastore:"tested"`
|
||||||
|
Owner string `json:"owner" datastore:"owner" yaml:"owner"`
|
||||||
|
Hash string `json:"hash" datastore:"hash" yaml:"hash"` // api.yaml+dockerfile+src/app.py for apps
|
||||||
|
PrivateID string `json:"private_id" yaml:"private_id" required:false datastore:"private_id"`
|
||||||
|
Description string `json:"description" datastore:"description,noindex" required:false yaml:"description"`
|
||||||
|
Environment string `json:"environment" datastore:"environment" required:true yaml:"environment"`
|
||||||
|
SmallImage string `json:"small_image" datastore:"small_image,noindex" required:false yaml:"small_image"`
|
||||||
|
LargeImage string `json:"large_image" datastore:"large_image,noindex" yaml:"large_image" required:false`
|
||||||
|
ContactInfo struct {
|
||||||
|
Name string `json:"name" datastore:"name" yaml:"name"`
|
||||||
|
Url string `json:"url" datastore:"url" yaml:"url"`
|
||||||
|
} `json:"contact_info" datastore:"contact_info" yaml:"contact_info" required:false`
|
||||||
|
Actions []WorkflowAppAction `json:"actions" yaml:"actions" required:true datastore:"actions"`
|
||||||
|
Authentication Authentication `json:"authentication" yaml:"authentication" required:false datastore:"authentication"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WorkflowAppActionParameter struct {
|
||||||
|
Description string `json:"description" datastore:"description" yaml:"description"`
|
||||||
|
ID string `json:"id" datastore:"id" yaml:"id,omitempty"`
|
||||||
|
Name string `json:"name" datastore:"name" yaml:"name"`
|
||||||
|
Example string `json:"example" datastore:"example" yaml:"example"`
|
||||||
|
Value string `json:"value" datastore:"value" yaml:"value,omitempty"`
|
||||||
|
Multiline bool `json:"multiline" datastore:"multiline" yaml:"multiline"`
|
||||||
|
ActionField string `json:"action_field" datastore:"action_field" yaml:"actionfield,omitempty"`
|
||||||
|
Variant string `json:"variant" datastore:"variant" yaml:"variant,omitempty"`
|
||||||
|
Required bool `json:"required" datastore:"required" yaml:"required"`
|
||||||
|
Configuration bool `json:"configuration" datastore:"configuration" yaml:"configuration"`
|
||||||
|
Schema SchemaDefinition `json:"schema" datastore:"schema" yaml:"schema"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SchemaDefinition struct {
|
||||||
|
Type string `json:"type" datastore:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WorkflowAppAction struct {
|
||||||
|
Description string `json:"description" datastore:"description"`
|
||||||
|
ID string `json:"id" datastore:"id" yaml:"id,omitempty"`
|
||||||
|
Name string `json:"name" datastore:"name"`
|
||||||
|
Label string `json:"label" datastore:"label"`
|
||||||
|
NodeType string `json:"node_type" datastore:"node_type"`
|
||||||
|
Environment string `json:"environment" datastore:"environment"`
|
||||||
|
Sharing bool `json:"sharing" datastore:"sharing"`
|
||||||
|
PrivateID string `json:"private_id" datastore:"private_id"`
|
||||||
|
AppID string `json:"app_id" datastore:"app_id"`
|
||||||
|
Authentication []AuthenticationStore `json:"authentication" datastore:"authentication" yaml:"authentication,omitempty"`
|
||||||
|
Tested bool `json:"tested" datastore:"tested" yaml:"tested"`
|
||||||
|
Parameters []WorkflowAppActionParameter `json:"parameters" datastore: "parameters"`
|
||||||
|
ExecutionVariable struct {
|
||||||
|
Description string `json:"description" datastore:"description"`
|
||||||
|
ID string `json:"id" datastore:"id"`
|
||||||
|
Name string `json:"name" datastore:"name"`
|
||||||
|
Value string `json:"value" datastore:"value"`
|
||||||
|
} `json:"execution_variable" datastore:"execution_variables"`
|
||||||
|
Returns struct {
|
||||||
|
Description string `json:"description" datastore:"returns" yaml:"description,omitempty"`
|
||||||
|
Example string `json:"example" datastore:"example" yaml:"example"`
|
||||||
|
ID string `json:"id" datastore:"id" yaml:"id,omitempty"`
|
||||||
|
Schema SchemaDefinition `json:"schema" datastore:"schema" yaml:"schema"`
|
||||||
|
} `json:"returns" datastore:"returns"`
|
||||||
|
AuthenticationId string `json:"authentication_id" datastore:"authentication_id"`
|
||||||
|
Example string `json:"example" datastore:"example" yaml:"example"`
|
||||||
|
AuthNotRequired bool `json:"auth_not_required" datastore:"auth_not_required" yaml:"auth_not_required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: Generate a callback authentication ID?
|
||||||
type WorkflowExecution struct {
|
type WorkflowExecution struct {
|
||||||
Type string `json:"type" datastore:"type"`
|
Type string `json:"type" datastore:"type"`
|
||||||
Status string `json:"status" datastore:"status"`
|
Status string `json:"status" datastore:"status"`
|
||||||
Start string `json:"start" datastore:"start"`
|
Start string `json:"start" datastore:"start"`
|
||||||
ExecutionArgument string `json:"execution_argument" datastore:"execution_argument"`
|
ExecutionArgument string `json:"execution_argument" datastore:"execution_argument"`
|
||||||
ExecutionId string `json:"execution_id" datastore:"execution_id"`
|
ExecutionId string `json:"execution_id" datastore:"execution_id"`
|
||||||
|
ExecutionSource string `json:"execution_source" datastore:"execution_source"`
|
||||||
WorkflowId string `json:"workflow_id" datastore:"workflow_id"`
|
WorkflowId string `json:"workflow_id" datastore:"workflow_id"`
|
||||||
LastNode string `json:"last_node" datastore:"last_node"`
|
LastNode string `json:"last_node" datastore:"last_node"`
|
||||||
Authorization string `json:"authorization" datastore:"authorization"`
|
Authorization string `json:"authorization" datastore:"authorization"`
|
||||||
@@ -81,6 +180,7 @@ type WorkflowExecution struct {
|
|||||||
} `json:"execution_variables,omitempty" datastore:"execution_variables,omitempty"`
|
} `json:"execution_variables,omitempty" datastore:"execution_variables,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is for the nodes in a workflow, NOT the app action itself.
|
||||||
type Action struct {
|
type Action struct {
|
||||||
AppName string `json:"app_name" datastore:"app_name"`
|
AppName string `json:"app_name" datastore:"app_name"`
|
||||||
AppVersion string `json:"app_version" datastore:"app_version"`
|
AppVersion string `json:"app_version" datastore:"app_version"`
|
||||||
@@ -107,14 +207,51 @@ type Action struct {
|
|||||||
X float64 `json:"x" datastore:"x"`
|
X float64 `json:"x" datastore:"x"`
|
||||||
Y float64 `json:"y" datastore:"y"`
|
Y float64 `json:"y" datastore:"y"`
|
||||||
} `json:"position"`
|
} `json:"position"`
|
||||||
|
Priority int `json:"priority" datastore:"priority"`
|
||||||
|
AuthenticationId string `json:"authentication_id" datastore:"authentication_id"`
|
||||||
|
Example string `json:"example" datastore:"example"`
|
||||||
|
AuthNotRequired bool `json:"auth_not_required" datastore:"auth_not_required" yaml:"auth_not_required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Added environment for location to execute
|
||||||
|
type Trigger struct {
|
||||||
|
AppName string `json:"app_name" datastore:"app_name"`
|
||||||
|
Description string `json:"description" datastore:"description"`
|
||||||
|
LongDescription string `json:"long_description" datastore:"long_description"`
|
||||||
|
Status string `json:"status" datastore:"status"`
|
||||||
|
AppVersion string `json:"app_version" datastore:"app_version"`
|
||||||
|
Errors []string `json:"errors" datastore:"errors"`
|
||||||
|
ID string `json:"id" datastore:"id"`
|
||||||
|
IsValid bool `json:"is_valid" datastore:"is_valid"`
|
||||||
|
IsStartNode bool `json:"isStartNode" datastore:"isStartNode"`
|
||||||
|
Label string `json:"label" datastore:"label"`
|
||||||
|
SmallImage string `json:"small_image" datastore:"small_image,noindex" required:false yaml:"small_image"`
|
||||||
|
LargeImage string `json:"large_image" datastore:"large_image,noindex" yaml:"large_image" required:false`
|
||||||
|
Environment string `json:"environment" datastore:"environment"`
|
||||||
|
TriggerType string `json:"trigger_type" datastore:"trigger_type"`
|
||||||
|
Name string `json:"name" datastore:"name"`
|
||||||
|
Parameters []WorkflowAppActionParameter `json:"parameters" datastore: "parameters,noindex"`
|
||||||
|
Position struct {
|
||||||
|
X float64 `json:"x" datastore:"x"`
|
||||||
|
Y float64 `json:"y" datastore:"y"`
|
||||||
|
} `json:"position"`
|
||||||
Priority int `json:"priority" datastore:"priority"`
|
Priority int `json:"priority" datastore:"priority"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Branch struct {
|
type Branch struct {
|
||||||
DestinationID string `json:"destination_id" datastore:"destination_id"`
|
DestinationID string `json:"destination_id" datastore:"destination_id"`
|
||||||
ID string `json:"id" datastore:"id"`
|
ID string `json:"id" datastore:"id"`
|
||||||
SourceID string `json:"source_id" datastore:"source_id"`
|
SourceID string `json:"source_id" datastore:"source_id"`
|
||||||
HasError bool `json:"has_errors" datastore: "has_errors"`
|
Label string `json:"label" datastore:"label"`
|
||||||
|
HasError bool `json:"has_errors" datastore: "has_errors"`
|
||||||
|
Conditions []Condition `json:"conditions" datastore: "conditions"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Same format for a lot of stuff
|
||||||
|
type Condition struct {
|
||||||
|
Condition WorkflowAppActionParameter `json:"condition" datastore:"condition"`
|
||||||
|
Source WorkflowAppActionParameter `json:"source" datastore:"source"`
|
||||||
|
Destination WorkflowAppActionParameter `json:"destination" datastore:"destination"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Schedule struct {
|
type Schedule struct {
|
||||||
@@ -124,44 +261,26 @@ type Schedule struct {
|
|||||||
Id string `json:"id" datastore:"id"`
|
Id string `json:"id" datastore:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Trigger struct {
|
|
||||||
AppName string `json:"app_name" datastore:"app_name"`
|
|
||||||
Status string `json:"status" datastore:"status"`
|
|
||||||
AppVersion string `json:"app_version" datastore:"app_version"`
|
|
||||||
Errors []string `json:"errors" datastore:"errors"`
|
|
||||||
ID string `json:"id" datastore:"id"`
|
|
||||||
IsValid bool `json:"is_valid" datastore:"is_valid"`
|
|
||||||
IsStartNode bool `json:"isStartNode" datastore:"isStartNode"`
|
|
||||||
Label string `json:"label" datastore:"label"`
|
|
||||||
SmallImage string `json:"small_image" datastore:"small_image,noindex" required:false yaml:"small_image"`
|
|
||||||
LargeImage string `json:"large_image" datastore:"large_image,noindex" yaml:"large_image" required:false`
|
|
||||||
Environment string `json:"environment" datastore:"environment"`
|
|
||||||
TriggerType string `json:"trigger_type" datastore:"trigger_type"`
|
|
||||||
Name string `json:"name" datastore:"name"`
|
|
||||||
Parameters []WorkflowAppActionParameter `json:"parameters" datastore: "parameters"`
|
|
||||||
Position struct {
|
|
||||||
X float64 `json:"x" datastore:"x"`
|
|
||||||
Y float64 `json:"y" datastore:"y"`
|
|
||||||
} `json:"position"`
|
|
||||||
Priority int `json:"priority" datastore:"priority"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Workflow struct {
|
type Workflow struct {
|
||||||
Actions []Action `json:"actions" datastore:"actions,noindex"`
|
Actions []Action `json:"actions" datastore:"actions,noindex"`
|
||||||
Branches []Branch `json:"branches" datastore:"branches,noindex"`
|
Branches []Branch `json:"branches" datastore:"branches,noindex"`
|
||||||
Triggers []Trigger `json:"triggers" datastore:"triggers,noindex"`
|
Triggers []Trigger `json:"triggers" datastore:"triggers,noindex"`
|
||||||
Schedules []Schedule `json:"schedules" datastore:"schedules,noindex"`
|
Schedules []Schedule `json:"schedules" datastore:"schedules,noindex"`
|
||||||
Errors []string `json:"errors,omitempty" datastore:"errors"`
|
Configuration struct {
|
||||||
Tags []string `json:"tags,omitempty" datastore:"tags"`
|
ExitOnError bool `json:"exit_on_error" datastore:"exit_on_error"`
|
||||||
ID string `json:"id" datastore:"id"`
|
StartFromTop bool `json:"start_from_top" datastore:"start_from_top"`
|
||||||
IsValid bool `json:"is_valid" datastore:"is_valid"`
|
} `json:"configuration,omitempty" datastore:"configuration"`
|
||||||
Name string `json:"name" datastore:"name"`
|
Errors []string `json:"errors,omitempty" datastore:"errors"`
|
||||||
Description string `json:"description" datastore:"description"`
|
Tags []string `json:"tags,omitempty" datastore:"tags"`
|
||||||
Start string `json:"start" datastore:"start"`
|
ID string `json:"id" datastore:"id"`
|
||||||
Owner string `json:"owner" datastore:"owner"`
|
IsValid bool `json:"is_valid" datastore:"is_valid"`
|
||||||
Sharing string `json:"sharing" datastore:"sharing"`
|
Name string `json:"name" datastore:"name"`
|
||||||
Org []Org `json:"org,omitempty" datastore:"org"`
|
Description string `json:"description" datastore:"description"`
|
||||||
ExecutingOrg Org `json:"execution_org,omitempty" datastore:"execution_org"`
|
Start string `json:"start" datastore:"start"`
|
||||||
|
Owner string `json:"owner" datastore:"owner"`
|
||||||
|
Sharing string `json:"sharing" datastore:"sharing"`
|
||||||
|
Org []Org `json:"org,omitempty" datastore:"org"`
|
||||||
|
ExecutingOrg Org `json:"execution_org,omitempty" datastore:"execution_org"`
|
||||||
WorkflowVariables []struct {
|
WorkflowVariables []struct {
|
||||||
Description string `json:"description" datastore:"description"`
|
Description string `json:"description" datastore:"description"`
|
||||||
ID string `json:"id" datastore:"id"`
|
ID string `json:"id" datastore:"id"`
|
||||||
@@ -173,48 +292,35 @@ type Workflow struct {
|
|||||||
ID string `json:"id" datastore:"id"`
|
ID string `json:"id" datastore:"id"`
|
||||||
Name string `json:"name" datastore:"name"`
|
Name string `json:"name" datastore:"name"`
|
||||||
Value string `json:"value" datastore:"value"`
|
Value string `json:"value" datastore:"value"`
|
||||||
} `json:"execution_variables,omitempty" datastore:"execution_variables,omitempty"`
|
} `json:"execution_variables,omitempty" datastore:"execution_variables"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ActionResult struct {
|
type ActionResult struct {
|
||||||
Action Action `json:"action" datastore:"action"`
|
Action Action `json:"action" datastore:"action"`
|
||||||
ExecutionId string `json:"execution_id" datastore:"execution_id"`
|
ExecutionId string `json:"execution_id" datastore:"execution_id"`
|
||||||
Authorization string `json:"authorization" datastore:"authorization"`
|
Authorization string `json:"authorization" datastore:"authorization"`
|
||||||
Result string `json:"result" datastore:"result"`
|
Result string `json:"result" datastore:"result,noindex"`
|
||||||
StartedAt int64 `json:"started_at" datastore:"started_at"`
|
StartedAt int64 `json:"started_at" datastore:"started_at"`
|
||||||
CompletedAt int64 `json:"completed_at" datastore:"completed_at"`
|
CompletedAt int64 `json:"completed_at" datastore:"completed_at"`
|
||||||
Status string `json:"status" datastore:"status"`
|
Status string `json:"status" datastore:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WorkflowApp struct {
|
type Authentication struct {
|
||||||
Name string `json:"name" yaml:"name" required:true datastore:"name"`
|
Required bool `json:"required" datastore:"required" yaml:"required" `
|
||||||
IsValid bool `json:"is_valid" yaml:"is_valid" required:true datastore:"is_valid"`
|
Parameters []AuthenticationParams `json:"parameters" datastore:"parameters" yaml:"parameters"`
|
||||||
ID string `json:"id" yaml:"id" required:false datastore:"id"`
|
|
||||||
Link string `json:"link" yaml:"link" required:false datastore:"link"`
|
|
||||||
AppVersion string `json:"app_version" yaml:"app_version" required:true datastore:"app_version"`
|
|
||||||
Description string `json:"description" datastore:"description" required:false yaml:"description"`
|
|
||||||
Environment string `json:"environment" datastore:"environment" required:true yaml:"environment"`
|
|
||||||
ContactInfo struct {
|
|
||||||
Name string `json:"name" datastore:"name" yaml:"name"`
|
|
||||||
Url string `json:"url" datastore:"url" yaml:"url"`
|
|
||||||
} `json:"contact_info" datastore:"contact_info" yaml:"contact_info" required:false`
|
|
||||||
Actions []WorkflowAppAction `json:"actions" yaml:"actions" required:true datastore:"actions"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name = current field
|
type AuthenticationParams struct {
|
||||||
// action_field is the field that it's set to
|
Description string `json:"description" datastore:"description" yaml:"description"`
|
||||||
// value, if Variant = ACTION_RESULT = the second field thingy, which will be
|
ID string `json:"id" datastore:"id" yaml:"id"`
|
||||||
type WorkflowAppActionParameter struct {
|
Name string `json:"name" datastore:"name" yaml:"name"`
|
||||||
Description string `json:"description" datastore:"description"`
|
Example string `json:"example" datastore:"example" yaml:"example"`
|
||||||
ID string `json:"id" datastore:"id"`
|
Value string `json:"value,omitempty" datastore:"value" yaml:"value"`
|
||||||
Name string `json:"name" datastore:"name"`
|
Multiline bool `json:"multiline" datastore:"multiline" yaml:"multiline"`
|
||||||
Value string `json:"value" datastore:"value"`
|
Required bool `json:"required" datastore:"required" yaml:"required"`
|
||||||
ActionField string `json:"action_field" datastore:"action_field"`
|
In string `json:"in" datastore:"in" yaml:"in"`
|
||||||
Variant string `json:"variant", datastore:"variant"`
|
Schema SchemaDefinition `json:"schema" datastore:"schema" yaml:"schema"`
|
||||||
Required bool `json:"required" datastore:"required"`
|
Scheme string `json:"scheme" datastore:"scheme" yaml:"scheme"` // Deprecated
|
||||||
Schema struct {
|
|
||||||
Type string `json:"type" datastore:"type"`
|
|
||||||
} `json:"schema"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthenticationStore struct {
|
type AuthenticationStore struct {
|
||||||
@@ -222,34 +328,8 @@ type AuthenticationStore struct {
|
|||||||
Value string `json:"value" datastore:"value"`
|
Value string `json:"value" datastore:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WorkflowAppAction struct {
|
type ExecutionRequestWrapper struct {
|
||||||
Description string `json:"description" datastore:"description"`
|
Data []ExecutionRequest `json:"data"`
|
||||||
ID string `json:"id" datastore:"id" yaml:"id,omitempty"`
|
|
||||||
Name string `json:"name" datastore:"name"`
|
|
||||||
Label string `json:"label" datastore:"label"`
|
|
||||||
NodeType string `json:"node_type" datastore:"node_type"`
|
|
||||||
Environment string `json:"environment" datastore:"environment"`
|
|
||||||
Sharing bool `json:"sharing" datastore:"sharing"`
|
|
||||||
PrivateID string `json:"private_id" datastore:"private_id"`
|
|
||||||
AppID string `json:"app_id" datastore:"app_id"`
|
|
||||||
Authentication []AuthenticationStore `json:"authentication" datastore:"authentication" yaml:"authentication,omitempty"`
|
|
||||||
Tested bool `json:"tested" datastore:"tested" yaml:"tested"`
|
|
||||||
Parameters []WorkflowAppActionParameter `json:"parameters" datastore: "parameters"`
|
|
||||||
ExecutionVariable struct {
|
|
||||||
Description string `json:"description" datastore:"description"`
|
|
||||||
ID string `json:"id" datastore:"id"`
|
|
||||||
Name string `json:"name" datastore:"name"`
|
|
||||||
Value string `json:"value" datastore:"value"`
|
|
||||||
} `json:"execution_variable" datastore:"execution_variables"`
|
|
||||||
Returns struct {
|
|
||||||
Description string `json:"description" datastore:"returns" yaml:"description,omitempty"`
|
|
||||||
ID string `json:"id" datastore:"id" yaml:"id,omitempty"`
|
|
||||||
Schema SchemaDefinition `json:"schema" datastore:"schema" yaml:"schema"`
|
|
||||||
} `json:"returns" datastore:"returns"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SchemaDefinition struct {
|
|
||||||
Type string `json:"type" datastore:"type"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// removes every container except itself (worker)
|
// removes every container except itself (worker)
|
||||||
@@ -783,14 +863,21 @@ func handleExecution(client *http.Client, req *http.Request, workflowExecution W
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
//log.Println(string(actionData))
|
executionData, err := json.Marshal(workflowExecution)
|
||||||
// FIXME - add proper FUNCTION_APIKEY from user definition
|
if err != nil {
|
||||||
|
log.Printf("Failed marshalling executiondata: %s", err)
|
||||||
|
executionData = []byte("")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sending full execution so that it won't have to load in every app
|
||||||
|
// This might be an issue if they can read environments, but that's alright
|
||||||
|
// if everything is generated during execution
|
||||||
env := []string{
|
env := []string{
|
||||||
fmt.Sprintf("ACTION=%s", string(actionData)),
|
fmt.Sprintf("ACTION=%s", string(actionData)),
|
||||||
fmt.Sprintf("EXECUTIONID=%s", workflowExecution.ExecutionId),
|
fmt.Sprintf("EXECUTIONID=%s", workflowExecution.ExecutionId),
|
||||||
fmt.Sprintf("FUNCTION_APIKEY=%s", "asdasd"),
|
|
||||||
fmt.Sprintf("AUTHORIZATION=%s", workflowExecution.Authorization),
|
fmt.Sprintf("AUTHORIZATION=%s", workflowExecution.Authorization),
|
||||||
fmt.Sprintf("CALLBACK_URL=%s", baseUrl),
|
fmt.Sprintf("CALLBACK_URL=%s", baseUrl),
|
||||||
|
fmt.Sprintf("FULL_EXECUTION=%s", string(executionData)),
|
||||||
}
|
}
|
||||||
|
|
||||||
err = deployApp(dockercli, image, identifier, env)
|
err = deployApp(dockercli, image, identifier, env)
|
||||||
@@ -1062,6 +1149,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
// Because of this, it always has updated data.
|
||||||
|
// Removed request requirement from app_sdk
|
||||||
newresp, err := client.Do(req)
|
newresp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed request: %s", err)
|
log.Printf("Failed request: %s", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user