Skip to content

Commit 6feec22

Browse files
authored
Merge pull request #128 from scality/bugfix/PTFE-600-crash-on-boot
[PTFE-600] Crash on boot
2 parents c7e0253 + 1458b01 commit 6feec22

File tree

11 files changed

+55
-52
lines changed

11 files changed

+55
-52
lines changed

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
recursive-include bert_e/templates *
2+
recursive-include bert_e/server/templates *
3+
recursive-include bert_e/server/static *
24
recursive-include bert_e/docs *
35
include requirements.txt

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ All above instructions will assume you are inside the codespace environment
2222
```shell
2323
$ cp settings.sample.yml settings.yml
2424
# Configure settings.yml to your liking
25-
$ tox -e run
25+
$ tox run -e run
2626
```
2727

2828
### Run local tests

bert_e/git_host/github/schema.py

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@
1818
used by Bert-E) are declared.
1919
2020
"""
21-
from marshmallow import Schema, fields
21+
from marshmallow import Schema, fields, EXCLUDE
2222

2323

24-
class User(Schema):
24+
class GitHubSchema(Schema):
25+
class Meta:
26+
unknown = EXCLUDE
27+
28+
29+
class User(GitHubSchema):
2530
id = fields.Int(required=True)
2631
login = fields.Str(required=True)
2732
# Note: the "printable" name can be absent in most API call results.
@@ -30,7 +35,7 @@ class User(Schema):
3035
type = fields.Str()
3136

3237

33-
class Repo(Schema):
38+
class Repo(GitHubSchema):
3439
name = fields.Str(required=True)
3540
owner = fields.Nested(User, required=True)
3641
full_name = fields.Str(required=True)
@@ -41,7 +46,7 @@ class Repo(Schema):
4146
default_branch = fields.Str()
4247

4348

44-
class CreateRepo(Schema):
49+
class CreateRepo(GitHubSchema):
4550
name = fields.Str(required=True)
4651
description = fields.Str()
4752
homepage = fields.Url()
@@ -54,14 +59,14 @@ class CreateRepo(Schema):
5459
licence_template = fields.Str()
5560

5661

57-
class Status(Schema):
62+
class Status(GitHubSchema):
5863
state = fields.Str(required=True)
5964
target_url = fields.Str(required=True, allow_none=True)
6065
description = fields.Str(required=True, allow_none=True)
6166
context = fields.Str(required=True)
6267

6368

64-
class AggregatedStatus(Schema):
69+
class AggregatedStatus(GitHubSchema):
6570
# The most convenient way to get a pull request's build status is to
6671
# query github's API for an aggregated status.
6772
state = fields.Str()
@@ -70,23 +75,23 @@ class AggregatedStatus(Schema):
7075
statuses = fields.Nested(Status, many=True, required=True)
7176

7277

73-
class Branch(Schema):
78+
class Branch(GitHubSchema):
7479
label = fields.Str() # user:ref or org:ref
7580
ref = fields.Str()
7681
sha = fields.Str()
7782
user = fields.Nested(User)
7883
repo = fields.Nested(Repo)
7984

8085

81-
class App(Schema):
86+
class App(GitHubSchema):
8287
id = fields.Int()
8388
slug = fields.Str()
8489
owner = fields.Nested(User)
8590
name = fields.Str()
8691
description = fields.Str()
8792

8893

89-
class CheckSuite(Schema):
94+
class CheckSuite(GitHubSchema):
9095
id = fields.Integer()
9196
head_sha = fields.Str()
9297
head_branch = fields.Str()
@@ -98,20 +103,20 @@ class CheckSuite(Schema):
98103
app = fields.Nested(App)
99104

100105

101-
class AggregateCheckSuites(Schema):
106+
class AggregateCheckSuites(GitHubSchema):
102107
total_count = fields.Integer()
103108
check_suites = fields.Nested(CheckSuite, many=True)
104109

105110

106-
class CheckRun(Schema):
111+
class CheckRun(GitHubSchema):
107112
id = fields.Integer()
108113
head_sha = fields.Str()
109114
status = fields.Str()
110115
conclusion = fields.Str(allow_none=True)
111116
html_url = fields.Url()
112117

113118

114-
class WorkflowRun(Schema):
119+
class WorkflowRun(GitHubSchema):
115120
id = fields.Integer()
116121
head_sha = fields.Str()
117122
head_branch = fields.Str()
@@ -121,17 +126,17 @@ class WorkflowRun(Schema):
121126
event = fields.Str()
122127

123128

124-
class AggregateWorkflowRuns(Schema):
129+
class AggregateWorkflowRuns(GitHubSchema):
125130
total_count = fields.Integer()
126131
workflow_runs = fields.Nested(WorkflowRun, many=True)
127132

128133

129-
class AggregateCheckRuns(Schema):
134+
class AggregateCheckRuns(GitHubSchema):
130135
total_count = fields.Integer()
131136
check_runs = fields.Nested(CheckRun, many=True)
132137

133138

134-
class PullRequest(Schema):
139+
class PullRequest(GitHubSchema):
135140
number = fields.Int(required=True)
136141
url = fields.Url()
137142
html_url = fields.Url()
@@ -149,23 +154,23 @@ class PullRequest(Schema):
149154
merged_at = fields.DateTime(allow_none=True)
150155

151156

152-
class CreatePullRequest(Schema):
157+
class CreatePullRequest(GitHubSchema):
153158
title = fields.Str(required=True)
154159
head = fields.Str(required=True)
155160
base = fields.Str(required=True)
156161
body = fields.Str()
157162
maintainer_can_modify = fields.Bool()
158163

159164

160-
class UpdatePullRequest(Schema):
165+
class UpdatePullRequest(GitHubSchema):
161166
title = fields.Str()
162167
body = fields.Str()
163168
state = fields.Str()
164169
base = fields.Str()
165170
maintainer_can_modify = fields.Bool()
166171

167172

168-
class Comment(Schema):
173+
class Comment(GitHubSchema):
169174
id = fields.Int(required=True)
170175
body = fields.Str()
171176
created_at = fields.DateTime()
@@ -174,61 +179,61 @@ class Comment(Schema):
174179
url = fields.Url()
175180

176181

177-
class CreateComment(Schema):
182+
class CreateComment(GitHubSchema):
178183
body = fields.Str(required=True)
179184

180185

181-
class Review(Schema):
186+
class Review(GitHubSchema):
182187
id = fields.Int(allow_none=True)
183188
body = fields.Str(allow_none=True)
184189
commit_id = fields.Str()
185190
state = fields.Str()
186191
user = fields.Nested(User)
187192

188193

189-
class DraftReview(Schema):
194+
class DraftReview(GitHubSchema):
190195
path = fields.Str()
191196
position = fields.Int()
192197
body = fields.Str()
193198

194199

195-
class CreateReview(Schema):
200+
class CreateReview(GitHubSchema):
196201
body = fields.Str(allow_none=True)
197202
event = fields.Str()
198203

199204

200-
class PullRequestEvent(Schema):
205+
class PullRequestEvent(GitHubSchema):
201206
action = fields.Str(required=True)
202207
number = fields.Int()
203208
pull_request = fields.Nested(PullRequest)
204209

205210

206-
class Issue(Schema):
211+
class Issue(GitHubSchema):
207212
number = fields.Int()
208213
title = fields.Str()
209214
# If this dict is present and non-empty, then the issue is a pull request.
210215
pull_request = fields.Dict(optional=True, default={})
211216

212217

213-
class IssueCommentEvent(Schema):
218+
class IssueCommentEvent(GitHubSchema):
214219
action = fields.Str()
215220
issue = fields.Nested(Issue)
216221

217222

218-
class PullRequestReviewEvent(Schema):
223+
class PullRequestReviewEvent(GitHubSchema):
219224
action = fields.Str()
220225
pull_request = fields.Nested(PullRequest)
221226

222227

223-
class StatusEvent(Schema):
228+
class StatusEvent(GitHubSchema):
224229
sha = fields.Str()
225230
state = fields.Str()
226231
context = fields.Str()
227232
description = fields.Str(allow_none=True)
228233
target_url = fields.Str(allow_none=True)
229234

230235

231-
class CheckSuiteEvent(Schema):
236+
class CheckSuiteEvent(GitHubSchema):
232237
action = fields.Str()
233238
check_suite = fields.Nested(CheckSuite)
234239
repository = fields.Nested(Repo)

bert_e/lib/schema.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ def load(cls: Schema, data, **kwargs):
3737
the result of any @post_load processing.
3838
3939
"""
40-
res, errors = cls(**kwargs).load(data)
41-
if errors:
40+
try:
41+
res = cls(**kwargs).load(data)
42+
except Exception as errors:
4243
raise SchemaError(errors)
4344
return res
4445

bert_e/server/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
def setup_bert_e(settings_file, debug):
4141
"""Create and configure Bert-E instance."""
4242
settings = setup_settings(settings_file)
43-
settings['robot_password'] = os.environ['BERT_E_GITHOST_PWD']
44-
settings['jira_token'] = os.environ['BERT_E_JIRA_TOKEN']
4543
settings['backtrace'] = True
4644

4745
bert_e = BertE(settings)

bert_e/settings.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import logging
55
import os
66
from marshmallow import (
7-
Schema, fields, post_load, pre_load, validates_schema, ValidationError)
7+
Schema, fields, post_load, pre_load, validates_schema, ValidationError,
8+
EXCLUDE)
89

910
from bert_e.exceptions import (IncorrectSettingsFile,
1011
SettingsFileNotFound,
@@ -122,6 +123,9 @@ def deserialize(self, value, attr=None, data=None, **kwargs):
122123

123124

124125
class SettingsSchema(Schema):
126+
class Meta:
127+
unknown = EXCLUDE
128+
125129
# Settings defined in config files
126130
always_create_integration_pull_requests = fields.Bool(
127131
required=False, load_default=True)

charts/bert-e/templates/secrets.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ metadata:
1010
heritage: "{{ .Release.Service }}"
1111
type: Opaque
1212
data:
13-
BERT_E_GITHOST_PWD: {{ .Values.bertE.robot.password | b64enc | quote }}
13+
BERT_E_ROBOT_PASSWORD: {{ .Values.bertE.robot.password | b64enc | quote }}
1414
WEBHOOK_LOGIN: {{ .Values.bertE.webhook.username | b64enc | quote }}
1515
WEBHOOK_PWD: {{ .Values.bertE.webhook.password | b64enc | quote }}
1616
BERT_E_JIRA_TOKEN: {{ .Values.bertE.jira.token | b64enc | quote }}

manifests/base/secrets.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BERT_E_CLIENT_SECRET=vault:secret/data/bert-e#BERT_E_GITHUB_OAUTH_CLIENT_SECRET
22
BERT_E_CLIENT_ID=vault:secret/data/bert-e#BERT_E_GITHUB_OAUTH_CLIENT_ID
3-
BERT_E_GITHOST_PWD=vault:secret/data/bert-e#BERT_E_GITHUB_TOKEN
3+
BERT_E_ROBOT_PASSWORD=vault:secret/data/bert-e#BERT_E_GITHUB_TOKEN
44
BERT_E_GITHUB_TOKEN=vault:secret/data/bert-e#BERT_E_GITHUB_TOKEN
55
BERT_E_JIRA_TOKEN=vault:secret/data/bert-e#BERT_E_JIRA_TOKEN
66
BERT_E_JIRA_USER=vault:secret/data/bert-e#BERT_E_JIRA_USERNAME

settings.sample.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ frontend_url: https://bert-e.mydomain.com/bitbucket/my_company/my_repository/ber
55

66
# repository_host [MANDATORY]:
77
# The git hosting provider for the repository. Either bitbucket or github.
8-
repository_host: bitbucket
8+
repository_host: github
99

1010
# repository_owner [MANDATORY]:
1111
# The name of the owner of the Bitbucket/GitHub repository to work on
1212
#
1313
# (a.k.a. Bitbucket team or GitHub organization)
1414
#
15-
repository_owner: my_company
15+
repository_owner: scality
1616

1717

1818
# repository_slug [MANDATORY]:
1919
# The slug of the Bitbucket/GitHub repository to work on
2020
#
21-
repository_slug: my_repository
21+
repository_slug: bert-e
2222

2323

2424
# robot [MANDATORY]:

setup.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55
import pip
66

7-
from setuptools import setup
7+
from setuptools import setup, find_packages
88

99

1010
# Besides not advised,
@@ -44,16 +44,7 @@ def requires():
4444
url='https://github.com/scality/bert-e',
4545
license='Apache',
4646
include_package_data=True,
47-
packages=[
48-
'bert_e',
49-
'bert_e.jobs',
50-
'bert_e.lib',
51-
'bert_e.bin',
52-
'bert_e.git_host',
53-
'bert_e.git_host.github',
54-
'bert_e.workflow',
55-
'bert_e.workflow.gitwaterflow',
56-
],
47+
packages=find_packages(),
5748
install_requires=requires(),
5849
entry_points={
5950
'console_scripts': [

0 commit comments

Comments
 (0)