@@ -61,6 +61,7 @@ import (
6161 "golang.org/x/crypto/bcrypt"
6262
6363 "github.com/Masterminds/semver"
64+ dockerclient "github.com/docker/docker/client"
6465)
6566
6667var project ShuffleStorage
@@ -3335,7 +3336,7 @@ func HandleApiAuthentication(resp http.ResponseWriter, request *http.Request) (U
33353336 // Get the user based on APIkey here
33363337 userdata, err := GetApikey(ctx, apikeyCheck[1])
33373338 if err != nil {
3338- // log.Printf("[WARNING] Apikey %s doesn't exist: %s", apikey, err)
3339+ log.Printf("[WARNING] Apikey %s doesn't exist: %s", apikey, err)
33393340 return User{}, err
33403341 }
33413342
@@ -8052,6 +8053,13 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
80528053 return
80538054 }
80548055
8056+ // This fix the region issues with public workflow but can it create problem?
8057+ if len(tmpworkflow.ID) == 0 || workflow.Public == true {
8058+ log.Printf("[WARNING] Failed to find public workflow in region, using user provided workflow data")
8059+ tmp := workflow
8060+ tmpworkflow = &tmp
8061+ }
8062+
80558063 if project.Environment == "cloud" && tmpworkflow.Validated == false {
80568064 if workflow.Validated == true {
80578065
@@ -8892,6 +8900,8 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
88928900 fmt.Sprintf("/workflows/%s", workflow.ID),
88938901 user.ActiveOrg.Id,
88948902 true,
8903+ "MEDIUM",
8904+ "git",
88958905 )
88968906
88978907 if err != nil {
@@ -16761,6 +16771,8 @@ func ParsedExecutionResult(ctx context.Context, workflowExecution WorkflowExecut
1676116771 fmt.Sprintf("/workflows/%s?execution_id=%s&view=executions&node=%s", workflowExecution.Workflow.ID, workflowExecution.ExecutionId, actionResult.Action.ID),
1676216772 workflowExecution.ExecutionOrg,
1676316773 true,
16774+ "CRITICAL",
16775+ "workflow_execution",
1676416776 )
1676516777
1676616778 workflowExecution.NotificationsCreated++
@@ -16798,6 +16810,8 @@ func ParsedExecutionResult(ctx context.Context, workflowExecution WorkflowExecut
1679816810 fmt.Sprintf("/workflows/%s?execution_id=%s&view=executions&node=%s", workflowExecution.Workflow.ID, workflowExecution.ExecutionId, actionResult.Action.ID),
1679916811 workflowExecution.ExecutionOrg,
1680016812 true,
16813+ "CRITICAL",
16814+ "liquid_syntax",
1680116815 )
1680216816
1680316817 workflowExecution.NotificationsCreated++
@@ -16840,6 +16854,8 @@ func ParsedExecutionResult(ctx context.Context, workflowExecution WorkflowExecut
1684016854 fmt.Sprintf("/workflows/%s?execution_id=%s&view=executions&node=%s", workflowExecution.Workflow.ID, workflowExecution.ExecutionId, actionResult.Action.ID),
1684116855 workflowExecution.ExecutionOrg,
1684216856 true,
16857+ "CRITICAL",
16858+ "action_failure",
1684316859 )
1684416860
1684516861 workflowExecution.NotificationsCreated++
@@ -17261,6 +17277,8 @@ func ParsedExecutionResult(ctx context.Context, workflowExecution WorkflowExecut
1726117277 fmt.Sprintf("/workflows/%s?execution_id=%s&view=executions&node=%s", workflowExecution.Workflow.ID, workflowExecution.ExecutionId, actionResult.Action.ID),
1726217278 workflowExecution.ExecutionOrg,
1726317279 true,
17280+ "HIGH",
17281+ "workflow_silent_failure",
1726417282 )
1726517283
1726617284 workflowExecution.NotificationsCreated++
@@ -17287,6 +17305,8 @@ func ParsedExecutionResult(ctx context.Context, workflowExecution WorkflowExecut
1728717305 fmt.Sprintf("/workflows/%s?execution_id=%s&node=%s", workflowExecution.Workflow.ID, workflowExecution.ExecutionId, actionResult.Action.ID),
1728817306 workflowExecution.ExecutionOrg,
1728917307 true,
17308+ "CRITICAL",
17309+ "app_error",
1729017310 )
1729117311 }
1729217312 }
@@ -25645,6 +25665,8 @@ func PrepareWorkflowExecution(ctx context.Context, workflow Workflow, request *h
2564525665 fmt.Sprintf("/workflows/%s?execution_id=%s", workflowExecution.Workflow.ID, workflowExecution.ExecutionId),
2564625666 workflowExecution.ExecutionOrg,
2564725667 true,
25668+ "MEDIUM",
25669+ "KMS_DECRYPT_FAILURE",
2564825670 )
2564925671 }
2565025672 }
@@ -25824,6 +25846,8 @@ func GetAuthentication(ctx context.Context, workflowExecution WorkflowExecution,
2582425846 fmt.Sprintf("/workflows/%s?execution_id=%s", workflowExecution.Workflow.ID, workflowExecution.ExecutionId),
2582525847 workflowExecution.ExecutionOrg,
2582625848 true,
25849+ "HIGH",
25850+ "AUTH_ID_MISSING",
2582725851 )
2582825852
2582925853 //return workflowExecution, ExecInfo{}, fmt.Sprintf("App Auth ID %s doesn't exist for app '%s' among %d auth for org ID '%s'. Please re-authenticate the app (1).", action.AuthenticationId, action.AppName, len(allAuths), workflow.ExecutingOrg.Id), errors.New(fmt.Sprintf("App Auth ID %s doesn't exist for app '%s' among %d auth for org ID '%s'. Please re-authenticate the app (2).", action.AuthenticationId, action.AppName, len(allAuths), workflow.ExecutingOrg.Id))
@@ -25976,6 +26000,8 @@ func GetAuthentication(ctx context.Context, workflowExecution WorkflowExecution,
2597626000 fmt.Sprintf("/workflows/%s?execution_id=%s", workflowExecution.Workflow.ID, workflowExecution.ExecutionId),
2597726001 workflowExecution.ExecutionOrg,
2597826002 true,
26003+ "HIGH",
26004+ "OAUTH2_REFRESH_FAILURE",
2597926005 )
2598026006
2598126007 // Abort the workflow due to auth being bad
@@ -26076,6 +26102,8 @@ func GetAuthentication(ctx context.Context, workflowExecution WorkflowExecution,
2607626102 fmt.Sprintf("/workflows/%s?execution_id=%s", workflowExecution.Workflow.ID, workflowExecution.ExecutionId),
2607726103 workflowExecution.ExecutionOrg,
2607826104 true,
26105+ "HIGH",
26106+ "OAUTH2_REFRESH_FAILURE",
2607926107 )
2608026108
2608126109 // Adding so it can be used to fail the auth naturally with Outlook
@@ -33720,3 +33748,49 @@ func getPrioritisedAppActions(ctx context.Context, inputApp string, maxAmount in
3372033748
3372133749 return returnActions
3372233750}
33751+
33752+ func GetDockerClient() (*dockerclient.Client, string, error) {
33753+ ctx := context.Background()
33754+ dockerApiVersion := os.Getenv("DOCKER_API_VERSION")
33755+ cli, err := dockerclient.NewEnvClient()
33756+ if err != nil {
33757+ return nil, dockerApiVersion,err
33758+ }
33759+
33760+ _, err = cli.Info(ctx)
33761+ if err == nil {
33762+ return cli, dockerApiVersion,nil
33763+ }
33764+
33765+ if strings.Contains(strings.ToLower(err.Error()), strings.ToLower("Minimum supported API version is")) {
33766+ re := regexp.MustCompile(`(?i)minimum supported api version is ([0-9\.]+)`)
33767+ match := re.FindStringSubmatch(err.Error())
33768+ if len(match) == 2 {
33769+ required := match[1]
33770+ os.Setenv("DOCKER_API_VERSION", required)
33771+ cli, err = dockerclient.NewEnvClient()
33772+ if err == nil {
33773+ dockerApiVersion = required
33774+ _, err = cli.Info(ctx)
33775+ return cli, dockerApiVersion, err
33776+ }
33777+ }
33778+ }
33779+
33780+ if strings.Contains(strings.ToLower(err.Error()), strings.ToLower("Maximum supported API version is")) {
33781+ re := regexp.MustCompile(`(?i)maximum supported api version is ([0-9\.]+)`)
33782+ match := re.FindStringSubmatch(err.Error())
33783+ if len(match) == 2 {
33784+ required := match[1]
33785+ os.Setenv("DOCKER_API_VERSION", required)
33786+ cli, err = dockerclient.NewEnvClient()
33787+ if err == nil {
33788+ dockerApiVersion = required
33789+ _, err = cli.Info(ctx)
33790+ return cli, dockerApiVersion, err
33791+ }
33792+ }
33793+ }
33794+
33795+ return cli, dockerApiVersion, err
33796+ }
0 commit comments