From 9604a4be253a5007350733d3ff8cef882305d5d4 Mon Sep 17 00:00:00 2001 From: frikky Date: Thu, 25 Mar 2021 16:36:09 +0100 Subject: [PATCH] Updates for 0.0.14 --- app_upload/stitcher.go | 18 ++++++++++++++---- db-connector.go | 11 ++++++++--- shared.go | 6 +++--- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/app_upload/stitcher.go b/app_upload/stitcher.go index 322f8b8..2e6fe8b 100644 --- a/app_upload/stitcher.go +++ b/app_upload/stitcher.go @@ -37,7 +37,7 @@ var appSearchIndex = "appsearch" // ALSO REQUIRES ACCESS TO UPLOAD TO CLOUD var appbasefile = "/home/frikky/git/shuffle/backend/app_sdk/app_base.py" var appfolder = "/home/frikky/git/shuffle-apps" -var baseUrl = "http://localhost:5002" +var baseUrl = "" var apikey = "" // Allows for overwriting if the user has access @@ -373,6 +373,7 @@ func deployFunction(appname, localization, applocation string, environmentVariab } // ProjectsLocationsListCall + appname = strings.ToLower(appname) projectsLocationsFunctionsService := cloudfunctions.NewProjectsLocationsFunctionsService(service) location := fmt.Sprintf("projects/%s/locations/%s", gceProject, localization) functionName := fmt.Sprintf("%s/functions/%s", location, appname) @@ -384,7 +385,7 @@ func deployFunction(appname, localization, applocation string, environmentVariab HttpsTrigger: &cloudfunctions.HttpsTrigger{}, MaxInstances: 0, Name: functionName, - Runtime: "python37", + Runtime: "python38", SourceArchiveUrl: applocation, ServiceAccountEmail: "shuffle-apps@shuffler.iam.gserviceaccount.com", } @@ -737,12 +738,21 @@ func deployAll() { } func main() { - //deployAll() - //return + if len(os.Args) < 3 { + log.Printf("Missing arguments. Required: go run stitcher.go APIKEY URL") + return + } + + baseUrl = os.Args[2] + apikey = os.Args[1] + log.Printf("\n\nRunning with: \nUrl: %s\nApikey: %s\n\n", baseUrl, apikey) appname := "Microsoft-Teams" appversion := "1.0.0" + deployAll() + return + err := deployConfigToBackend(appfolder, appname, appversion) if err != nil { log.Printf("Failed uploading config: %s", err) diff --git a/db-connector.go b/db-connector.go index 444becd..f9024d2 100644 --- a/db-connector.go +++ b/db-connector.go @@ -350,11 +350,16 @@ func GetWorkflowExecution(ctx context.Context, id string) (*WorkflowExecution, e return workflowExecution, nil } -func GetApp(ctx context.Context, id string) (*WorkflowApp, error) { - +func GetApp(ctx context.Context, id string, user User) (*WorkflowApp, error) { key := datastore.NameKey("workflowapp", strings.ToLower(id), nil) workflowApp := &WorkflowApp{} if err := project.Dbclient.Get(ctx, key, workflowApp); err != nil { + for _, app := range user.PrivateApps { + if app.ID == id { + return &app, nil + } + } + return &WorkflowApp{}, err } @@ -856,7 +861,7 @@ func GetPrioritizedApps(ctx context.Context, user User) ([]WorkflowApp, error) { break } - log.Printf("APP: %s", innerApp.Name) + //log.Printf("APP: %s", innerApp.Name) found := false //log.Printf("ACTIONS: %d - %s", len(app.Actions), app.Name) for _, loopedApp := range allApps { diff --git a/shared.go b/shared.go index 1bc7636..efa9c41 100644 --- a/shared.go +++ b/shared.go @@ -507,7 +507,7 @@ func AddAppAuthentication(resp http.ResponseWriter, request *http.Request) { } // FIXME: Doens't validate Org - app, err := GetApp(ctx, appAuth.App.ID) + app, err := GetApp(ctx, appAuth.App.ID, user) if err != nil { log.Printf("[WARNING] Failed finding app %s while setting auth. Finding it by looping apps.", appAuth.App.ID) workflowapps, err := GetPrioritizedApps(ctx, user) @@ -3689,7 +3689,7 @@ func UpdateWorkflowAppConfig(resp http.ResponseWriter, request *http.Request) { } ctx := getContext(request) - app, err := GetApp(ctx, fileId) + app, err := GetApp(ctx, fileId, user) if err != nil { log.Printf("Error getting app (update app): %s", fileId) resp.WriteHeader(401) @@ -3812,7 +3812,7 @@ func DeleteWorkflowApp(resp http.ResponseWriter, request *http.Request) { ctx := appengine.NewContext(request) log.Printf("ID: %s", fileId) - app, err := GetApp(ctx, fileId) + app, err := GetApp(ctx, fileId, user) if err != nil { log.Printf("Error getting app %s: %s", app.Name, err) resp.WriteHeader(401)