-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpush.py
More file actions
executable file
·37 lines (26 loc) · 1.18 KB
/
push.py
File metadata and controls
executable file
·37 lines (26 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
# (C) 2022 GoodData Corporation
import os
from pathlib import Path
from dotenv import load_dotenv
from utils import get_gooddata_sdk
def main():
# Get current environment, defaulting to "development"
environment = os.getenv("GD_ENV", "development")
# Load corresponding env variables from file, if exists
load_dotenv(f".env.{environment}")
credentials_path = os.getenv("GD_CREDENTIALS", f"credentials.{environment}.yaml")
if not Path(credentials_path).exists():
raise RuntimeError(f"Credentials file does not exist, trying to load from {credentials_path}")
test_data_sources = os.getenv("GD_TEST_DATA_SOURCES", "True").lower() in ("true", "t", "1", "yes", "y")
root_path = Path.cwd()
sdk = get_gooddata_sdk()
# Push data sources and PDM
sdk.catalog_data_source.load_and_put_declarative_data_sources(root_path, credentials_path, test_data_sources)
# Push user groups
sdk.catalog_user.load_and_put_declarative_user_groups(root_path)
# Push workspaces
sdk.catalog_workspace.load_and_put_declarative_workspaces(root_path)
print("Pushed definitions to GoodData server")
if __name__ == "__main__":
main()