Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import (
"golang.org/x/crypto/bcrypt"

"github.com/Masterminds/semver"
dockerclient "github.com/docker/docker/client"
)

var project ShuffleStorage
Expand Down Expand Up @@ -8052,6 +8053,13 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
return
}

// This fix the region issues with public workflow but can it create problem?
if len(tmpworkflow.ID) == 0 || workflow.Public == true {
log.Printf("[WARNING] Failed to find public workflow in region, using user provided workflow data")
tmp := workflow
tmpworkflow = &tmp
}

if project.Environment == "cloud" && tmpworkflow.Validated == false {
if workflow.Validated == true {

Expand Down Expand Up @@ -33713,3 +33721,49 @@ func getPrioritisedAppActions(ctx context.Context, inputApp string, maxAmount in

return returnActions
}

func GetDockerClient() (*dockerclient.Client, string, error) {
ctx := context.Background()
dockerApiVersion := os.Getenv("DOCKER_API_VERSION")
cli, err := dockerclient.NewEnvClient()
if err != nil {
return nil, dockerApiVersion,err
}

_, err = cli.Info(ctx)
if err == nil {
return cli, dockerApiVersion,nil
}

if strings.Contains(strings.ToLower(err.Error()), strings.ToLower("Minimum supported API version is")) {
re := regexp.MustCompile(`(?i)minimum supported api version is ([0-9\.]+)`)
match := re.FindStringSubmatch(err.Error())
if len(match) == 2 {
required := match[1]
os.Setenv("DOCKER_API_VERSION", required)
cli, err = dockerclient.NewEnvClient()
if err == nil {
dockerApiVersion = required
_, err = cli.Info(ctx)
return cli, dockerApiVersion, err
}
}
}

if strings.Contains(strings.ToLower(err.Error()), strings.ToLower("Maximum supported API version is")) {
re := regexp.MustCompile(`(?i)maximum supported api version is ([0-9\.]+)`)
match := re.FindStringSubmatch(err.Error())
if len(match) == 2 {
required := match[1]
os.Setenv("DOCKER_API_VERSION", required)
cli, err = dockerclient.NewEnvClient()
if err == nil {
dockerApiVersion = required
_, err = cli.Info(ctx)
return cli, dockerApiVersion, err
}
}
}

return cli, dockerApiVersion, err
}
Loading