-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.py
204 lines (171 loc) · 5.17 KB
/
config.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
import os, sys
def parsebool(s):
if s.lower() in ["1", "t", "true"]:
return True
if s.lower() in ["0", "f", "false"]:
return False
raise ValueError("invalid boolean flag")
# https://mysqlclient.readthedocs.io/user_guide.html#mysqldb-mysql
mysql_host = os.getenv("MYSQL_HOST")
mysql_db = os.getenv("MYSQL_DATABASE")
mysql_user = os.getenv("MYSQL_USER")
mysql_password = os.getenv("MYSQL_PASSWORD")
# app.config['MYSQL_DATABASE_HOST'] = os.getenv('MYSQL_HOST')
# app.config['MYSQL_DATABASE_DB'] = os.getenv('MYSQL_DATABASE')
# app.config['MYSQL_DATABASE_USER'] = os.getenv('MYSQL_USER')
# app.config['MYSQL_DATABASE_PASSWORD'] = os.getenv('MYSQL_PASSWORD')
S3_ENDPOINT = os.getenv("S3_ENDPOINT")
S3_ACCESS_KEY = os.getenv("S3_ACCESS_KEY")
S3_SECRET_KEY = os.getenv("S3_SECRET_KEY")
S3_BUCKET = os.getenv("S3_BUCKET")
S3_FOLDER = os.getenv("S3_FOLDER")
# directory to clone and zip git repositories (not used by jenkins)
ecr_temp_dir = "/temp/ecr/"
# app definition , these are the app fields (as seen by user) that are stored in the tables Apps
valid_fields = [
"namespace",
"name",
"version",
"description",
"keywords",
"authors",
"collaborators",
"homepage",
"funding",
"license",
"source",
"depends_on",
"baseCommand",
"arguments",
"inputs",
"resources",
"metadata",
"frozen",
"testing",
]
valid_fields_set = set(valid_fields)
app_view_fields = [
"namespace",
"name",
"version",
"description",
"source",
"depends_on",
"baseCommand",
"arguments",
"inputs",
"resources",
"metadata",
"testing",
]
required_fields = {"description": "str", "source": "dict"}
mysql_Apps_fields = {
"id": "str",
"namespace": "str",
"name": "str",
"version": "str",
"description": "str",
"keywords": "str",
"authors": "str",
"collaborators": "str",
"homepage": "str",
"funding": "str",
"license": "str",
"depends_on": "str",
"baseCommand": "str",
"arguments": "str",
"inputs": "json",
"metadata": "json",
"frozen": "bool",
"testing": "json",
"owner": "str",
"time_created": "datetime",
"time_last_updated": "datetime",
}
mysql_Sources_fields = {
"architectures": "json",
"url": "str",
"branch": "str",
"tag": "str",
"git_commit": "str",
"directory": "str",
"dockerfile": "str",
"build_args": "json",
}
# mysql_Apps_fields_set = set(valid_fields)
# architecture https://github.com/docker-library/official-images#architectures-other-than-amd64
architecture_valid = [
"linux/amd64",
"linux/arm64",
"linux/arm/v6",
"linux/arm/v7",
"linux/arm/v8",
]
# app input
input_fields_expected = ["id", "type"]
input_fields_valid = ["id", "type", "description", "default"]
# "Directory" not suypported yet # ref: https://www.commonwl.org/v1.1/CommandLineTool.html#CWLType
input_valid_types = ["boolean", "int", "long", "float", "double", "string", "File"]
# Apps table fields
# dbAppsFields = mysql_Apps_fields.keys()
dbAppsFields_str = ",".join(mysql_Apps_fields.keys())
dbSourcesFields_str = ",".join(mysql_Sources_fields.keys())
auth_method = os.getenv("AUTH_METHOD", default="static") # or sage
if auth_method == "":
auth_method = "static"
if auth_method != "static" and auth_method != "sage":
sys.exit(f"AUTH_METHOD {auth_method} invalid")
# for auth_method==sage
tokenInfoEndpoint = os.getenv("tokenInfoEndpoint")
tokenInfoUser = os.getenv("tokenInfoUser")
tokenInfoPassword = os.getenv("tokenInfoPassword")
if auth_method == "sage":
if tokenInfoEndpoint == "":
sys.exit("tokenInfoEndpoint not defined")
if tokenInfoUser == "":
sys.exit("tokenInfoUser not defined")
if tokenInfoPassword == "":
sys.exit("tokenInfoPassword not defined")
# static_tokens: only used for testing
static_tokens = {
"testuser_token": {
"id": "testuser",
"is_approved": True,
},
"testuser2_token": {
"id": "testuser2",
"is_approved": True,
},
"notapproved_token": {
"id": "notapproved",
"is_approved": False,
},
"admin_token": {
"id": "admin",
"is_admin": True,
"is_approved": True,
},
"sage_docker_auth_token": {
"id": "sage_docker_auth",
"scopes": "ecr_authz_introspection",
"is_approved": False,
},
}
# jenkins
jenkins_user = os.environ.get("JENKINS_USER", "ecrdb")
jenkins_token = os.environ.get("JENKINS_TOKEN", "")
jenkins_server = os.getenv("JENKINS_SERVER", default="http://localhost:8082")
docker_build_args = os.environ.get("DOCKER_BUILD_ARGS", "")
docker_run_args = os.environ.get("DOCKER_RUN_ARGS", "")
# docker registry
docker_registry_url = os.environ.get("DOCKER_REGISTRY_URL")
docker_registry_push_allowed = parsebool(
os.environ.get("DOCKER_REGISTRY_PUSH_ALLOWED", "0")
)
docker_registry_insecure = parsebool(os.environ.get("DOCKER_REGISTRY_INSECURE", "0"))
# buildkitd settings
buildkitd_address = os.environ.get("BUILDKITD_ADDR")
# redis cache settings
redis_host = os.environ.get("REDIS_HOST", "localhost")
redis_port = int(os.environ.get("REDIS_PORT", "6379"))
redis_ttl_seconds = int(os.environ.get("REDIS_TTL_SECONDS", "60"))