Skip to content

Commit 654d067

Browse files
LowaizLujeni
authored andcommitted
feat(mr-label): Add label parameter to mr creation
1 parent b3dfda2 commit 654d067

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ make upgrade
119119
value: 60
120120
- name: GITLAB_GRAPHQL_PAGE_LENGTH
121121
value: 100
122+
- name: GITLAB_MR_LABEL_LIST
123+
value: "sentry,your-label" # comma separated list of labels for the mr
122124
```
123125
124126
2. If you want to follow the ```helm``` deployment process you will have to fill your details into the ```helm/values-production.yaml``` and ```helm/Chart.yaml```.

gitlab2sentry/resources.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
TEST_GITLAB_GRAPHQL_SUFFIX,
1515
TEST_GITLAB_GRAPHQL_TIMEOUT,
1616
TEST_GITLAB_MR_KEYWORD,
17+
TEST_GITLAB_MR_LABEL_LIST,
1718
TEST_GITLAB_RMV_SRC_BRANCH,
1819
TEST_GITLAB_TOKEN,
1920
TEST_GITLAB_URL,
@@ -161,6 +162,12 @@ def is_test_env(env: str) -> bool:
161162
if is_test_env(ENV)
162163
else os.environ["GITLAB_MR_KEYWORD"]
163164
)
165+
GITLAB_MR_LABEL_LIST = (
166+
TEST_GITLAB_MR_LABEL_LIST
167+
if is_test_env(ENV)
168+
else os.environ.get("GITLAB_MR_LABEL_LIST", "").split(",")
169+
)
170+
164171
except KeyError as key_error:
165172
logging.error(
166173
"<Gitlab2Sentry>: env vars are not configured properly - {}".format(str(key_error))

gitlab2sentry/utils/gitlab_provider.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
GITLAB_GRAPHQL_TIMEOUT,
2424
GITLAB_MENTIONS_ACCESS_LEVEL,
2525
GITLAB_MENTIONS_LIST,
26+
GITLAB_MR_LABEL_LIST,
2627
GITLAB_PROJECT_CREATION_LIMIT,
2728
GITLAB_RMV_SRC_BRANCH,
2829
GITLAB_TOKEN,
@@ -271,6 +272,7 @@ def _create_mr(
271272
"source_branch": branch_name,
272273
"target_branch": project.default_branch,
273274
"title": title,
275+
"labels": GITLAB_MR_LABEL_LIST,
274276
}
275277
)
276278
return True

helm/values-production.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,5 @@ cronjob:
102102
value: 60
103103
- name: GITLAB_GRAPHQL_PAGE_LENGTH
104104
value: 100
105+
- name: GITLAB_MR_LABEL_LIST
106+
value: "sentry,gitlab2sentry" # comma separated list

tests/resources.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,5 @@
5151
TEST_GITLAB_AUTHOR_EMAIL = "test-content"
5252
TEST_GITLAB_AUTHOR_NAME = "test-content"
5353
TEST_GITLAB_RMV_SRC_BRANCH = True
54-
TEST_GITLAB_MR_KEYWORD = "sentry"
54+
TEST_GITLAB_MR_KEYWORD = "sentry"
55+
TEST_GITLAB_MR_LABEL_LIST = ["sentry"]

0 commit comments

Comments
 (0)