Added proxy options

This commit is contained in:
frikky
2020-07-05 11:25:08 +02:00
parent bd5f8226ad
commit 5cb19669be
9 changed files with 80 additions and 10 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ SHUFFLE_DEFAULT_PASSWORD=
SHUFFLE_DEFAULT_APIKEY=
# Local location of your app directory. Can't use ~/
APP_HOTLOAD_LOCATION=./shuffle-apps
SHUFFLE_APP_HOTLOAD_LOCATION=./shuffle-apps
# Other configs
BACKEND_HOSTNAME=shuffle-backend
+1
View File
@@ -395,6 +395,7 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg=
gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
gopkg.in/src-d/go-git.v4 v4.13.1 h1:SRtFyV8Kxc0UP7aCHcijOMQGPxHSmMOPrzulQWolkYE=
+48 -1
View File
@@ -28,6 +28,7 @@ import (
"cloud.google.com/go/datastore"
"cloud.google.com/go/pubsub"
"cloud.google.com/go/storage"
"google.golang.org/api/option"
"google.golang.org/appengine/mail"
"github.com/getkin/kin-openapi/openapi2"
@@ -50,9 +51,14 @@ import (
"golang.org/x/crypto/bcrypt"
"gopkg.in/yaml.v3"
// PROXY overrides
// "gopkg.in/src-d/go-git.v4/plumbing/transport/client"
// githttp "gopkg.in/src-d/go-git.v4/plumbing/transport/http"
// Web
// "github.com/gorilla/handlers"
"github.com/gorilla/mux"
"google.golang.org/grpc"
http2 "gopkg.in/src-d/go-git.v4/plumbing/transport/http"
// Old items (cloud)
// "google.golang.org/appengine"
@@ -2466,6 +2472,7 @@ func setUser(ctx context.Context, data *User) error {
// Used for testing only. Shouldn't impact production.
func handleCors(resp http.ResponseWriter, request *http.Request) bool {
//allowedOrigins := "*"
allowedOrigins := "http://localhost:3000"
resp.Header().Set("Vary", "Origin")
@@ -6144,6 +6151,45 @@ func runInit(ctx context.Context) {
if err != nil {
log.Printf("Failed increasing local stats: %s", err)
}
log.Printf("Finalized init statistics update")
httpProxy := os.Getenv("HTTP_PROXY")
if len(httpProxy) > 0 {
log.Printf("Running with HTTP proxy %s (env: HTTP_PROXY)", httpProxy)
}
/*
proxyUrl, err := url.Parse(httpProxy)
if err != nil {
log.Printf("Failed setting up proxy: %s", err)
} else {
// accept any certificate (might be useful for testing)
customClient := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
Proxy: http.ProxyURL(proxyUrl),
},
// 15 second timeout
Timeout: 15 * time.Second,
// don't follow redirect
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}
// Override http(s) default protocol to use our custom client
client.InstallProtocol("http", githttp.NewClient(customClient))
client.InstallProtocol("https", githttp.NewClient(customClient))
}
}
httpsProxy := os.Getenv("SHUFFLE_HTTPS_PROXY")
if len(httpsProxy) > 0 {
log.Printf("Running with HTTPS proxy %s", httpsProxy)
}
*/
// Fix active users etc
q := datastore.NewQuery("Users").Filter("active =", true)
@@ -6337,7 +6383,8 @@ func init() {
log.Printf("Starting Shuffle backend - initializing database connection")
// option.WithoutAuthentication
dbclient, err = datastore.NewClient(ctx, gceProject)
dbclient, err = datastore.NewClient(ctx, gceProject, option.WithGRPCDialOption(grpc.WithNoProxy()))
if err != nil {
panic(fmt.Sprintf("DBclient error during init: %s", err))
}
+8 -1
View File
@@ -1375,7 +1375,7 @@ func deleteWorkflow(resp http.ResponseWriter, request *http.Request) {
resp.Write([]byte(`{"success": true}`))
}
// FIXME - check whether all nodes has a branch, otherwise go back
// Saves a workflow to an ID
func saveWorkflow(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request)
if cors {
@@ -1462,6 +1462,11 @@ func saveWorkflow(resp http.ResponseWriter, request *http.Request) {
return
}
// Fixing wrong owners when importing
if workflow.Owner == "" {
workflow.Owner = user.Id
}
// FIXME - this shouldn't be necessary with proper API checks
newActions := []Action{}
allNodes := []string{}
@@ -1491,6 +1496,8 @@ func saveWorkflow(resp http.ResponseWriter, request *http.Request) {
workflow.Actions = newActions
for _, trigger := range workflow.Triggers {
log.Printf("Trigger %s: %s", trigger.TriggerType, trigger.Status)
//log.Println("TRIGGERS")
allNodes = append(allNodes, trigger.ID)
}
+3 -3
View File
@@ -14,7 +14,7 @@ services:
depends_on:
- backend
backend:
#build: ./backend
build: ./backend
image: frikky/shuffle:backend
container_name: shuffle-backend
hostname: ${BACKEND_HOSTNAME}
@@ -25,10 +25,10 @@ services:
- shuffle
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${APP_HOTLOAD_LOCATION}:/shuffle-apps
- ${SHUFFLE_APP_HOTLOAD_LOCATION}:/shuffle-apps
environment:
- DATASTORE_EMULATOR_HOST=shuffle-database:8000
- APP_HOTLOAD_FOLDER=/shuffle-apps
- SHUFFLE_APP_HOTLOAD_FOLDER=/shuffle-apps
- ORG_ID=${ORG_ID}
- APP_DOWNLOAD_LOCATION=${APP_DOWNLOAD_LOCATION}
- SHUFFLE_DEFAULT_USERNAME=${SHUFFLE_DEFAULT_USERNAME}
+3 -3
View File
@@ -62,7 +62,7 @@ const Docs = (props) => {
if (parent !== null) {
var elements = parent.getElementsByTagName('h2')
const name = window.location.hash.slice(1, window.location.hash.lenth).toLowerCase().split("%20").join(" ").split("_").join(" ")
const name = window.location.hash.slice(1, window.location.hash.lenth).toLowerCase().split("%20").join(" ").split("_").join(" ").split("-").join(" ")
console.log(name)
var found = false
@@ -214,7 +214,7 @@ const Docs = (props) => {
<ul style={{listStyle: "none", paddingLeft: "0"}}>
{list.map(item => {
const path = "/docs/"+item
const newname = item.charAt(0).toUpperCase()+item.substring(1).split("_").join(" ")
const newname = item.charAt(0).toUpperCase()+item.substring(1).split("_").join(" ").split("-").join(" ")
return (
<li style={{marginTop: "10px"}}>
<Link style={hrefStyle} to={path} onClick={() => {fetchDocs(item)}}>
@@ -264,7 +264,7 @@ const Docs = (props) => {
>
{list.map(item => {
const path = "/docs/"+item
const newname = item.charAt(0).toUpperCase()+item.substring(1).split("_").join(" ")
const newname = item.charAt(0).toUpperCase()+item.substring(1).split("_").join(" ").split("-").join(" ")
return (
<MenuItem onClick={() => {window.location.pathname = path}}>{newname}</MenuItem>
)
+13
View File
@@ -261,9 +261,17 @@ const Workflows = (props) => {
const exportWorkflow = (data) => {
console.log("export")
let dataStr = JSON.stringify(data)
let dataUri = 'data:application/json;charset=utf-8,'+ encodeURIComponent(dataStr);
let exportFileDefaultName = data.name+'.json';
data["owner"] = ""
for (var key in data.triggers) {
if (data.triggers[key].status == "running") {
data.triggers[key].status = "stopped"
}
}
let linkElement = document.createElement('a');
linkElement.setAttribute('href', dataUri);
linkElement.setAttribute('download', exportFileDefaultName);
@@ -727,9 +735,14 @@ const Workflows = (props) => {
var workflowdata = {}
if (editingWorkflow.id !== undefined) {
console.log("Building original workflow")
method = "PUT"
extraData = "/"+editingWorkflow.id
workflowdata = editingWorkflow
console.log("REMOVING OWNER")
workflowdata["owner"] = ""
// FIXME: Loop triggers and turn them off?
}
workflowdata["name"] = name
+2
View File
@@ -341,6 +341,8 @@ func main() {
fmt.Sprintf("EXECUTIONID=%s", execution.ExecutionId),
fmt.Sprintf("ENVIRONMENT_NAME=%s", environment),
fmt.Sprintf("BASE_URL=%s", baseUrl),
fmt.Sprintf("HTTP_PROXY=%s", os.Getenv("HTTP_PROXY")),
fmt.Sprintf("HTTPS_PROXY=%s", os.Getenv("HTTPS_PROXY")),
}
if dockerApiVersion != "" {
+1 -1
View File
@@ -1,5 +1,5 @@
# Installation guide
Installation of Shuffle is currently only available in docker.
Installation of Shuffle is currently only available in docker. Looking for how to update Shuffle? Check the [updating guide](https://shuffler.io/docs/configuration#updating_shuffle)
There are four parts to the infrastructure:
* Frontend - GUI, React