forked from apache/beam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Playground] Move modify saved snippets functionality to to cloudfunc…
…tions (apache#26026) * Move priviledged Datastore operations to Cloudfunctions * Terraform changes to deploy cloud functions * Remove setting for snippets retention period as it's now hardcoded in a cloud function * service account access review * Datastore namespace added * Update .gitignore * Terraform fixes to permissions and namespaces * Move PutSnippet() into a separate CloudFunction * Remove unused role * Do not apply data migrations which are already applied * Move DB migration to external command * Hook up DB migration script to GKE deployment task * Remove trailing whitespace * Apply migrations in ToB integration tests * CloudFunctions review * remove unused code * Fix EOL on EOF * Update Readme * 'Cloud Functions Developer' role added to requirements * Fix issue with namespace value being ignored * Paths for archive_file set relative to path.root * Pass namespace into cloudfunctions * change arcive * fix name * fix module * Cloud Datastore User role added Required to run DB migration tool * Variable renamed --------- Co-authored-by: Sergey Makarkin <[email protected]> Co-authored-by: Sergey Makarkin <[email protected]> Co-authored-by: Rouslan <[email protected]> Co-authored-by: rshamunov <[email protected]>
- Loading branch information
1 parent
a13749f
commit 68ed7ce
Showing
62 changed files
with
1,594 additions
and
472 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one or more | ||
// contributor license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright ownership. | ||
// The ASF licenses this file to You under the Apache License, Version 2.0 | ||
// (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package main | ||
|
||
import ( | ||
"beam.apache.org/playground/backend/internal/constants" | ||
"beam.apache.org/playground/backend/internal/db/datastore" | ||
"beam.apache.org/playground/backend/internal/db/mapper" | ||
"beam.apache.org/playground/backend/internal/db/schema" | ||
"beam.apache.org/playground/backend/internal/logger" | ||
"context" | ||
"flag" | ||
"fmt" | ||
"os" | ||
) | ||
|
||
func main() { | ||
projectId := flag.String("project-id", "", "GCP project id") | ||
sdkConfigPath := flag.String("sdk-config", "", "Path to the sdk config file") | ||
namespace := flag.String("namespace", constants.Namespace, "Datastore namespace") | ||
|
||
flag.Parse() | ||
|
||
ctx := context.WithValue(context.Background(), constants.DatastoreNamespaceKey, *namespace) | ||
|
||
cwd, err := os.Getwd() | ||
if err != nil { | ||
fmt.Printf("Couldn't get the current working directory, err: %s \n", err.Error()) | ||
os.Exit(1) | ||
} | ||
logger.SetupLogger(context.Background(), cwd, *projectId) | ||
|
||
migratedDb, err := datastore.New(ctx, mapper.NewPrecompiledObjectMapper(), nil, *projectId) | ||
if err != nil { | ||
logger.Fatalf("Couldn't create DB client instance, err: %s \n", err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
if err := migratedDb.ApplyMigrations(ctx, schema.Migrations, *sdkConfigPath); err != nil { | ||
logger.Fatalf("Couldn't apply migrations, err: %s \n", err.Error()) | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.