Skip to content

Commit

Permalink
Updates for 0.0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
frikky committed Mar 25, 2021
1 parent 844742d commit 9604a4b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
18 changes: 14 additions & 4 deletions app_upload/stitcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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",
}
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 8 additions & 3 deletions db-connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9604a4b

Please sign in to comment.