Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mr-label): Add label parameter to mr creation #15

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ make upgrade
value: 60
- name: GITLAB_GRAPHQL_PAGE_LENGTH
value: 100
- name: GITLAB_MR_LABEL_LIST
value: "sentry,your-label" # comma separated list of labels for the mr
```

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```.
Expand Down
7 changes: 7 additions & 0 deletions gitlab2sentry/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
TEST_GITLAB_GRAPHQL_SUFFIX,
TEST_GITLAB_GRAPHQL_TIMEOUT,
TEST_GITLAB_MR_KEYWORD,
TEST_GITLAB_MR_LABEL_LIST,
TEST_GITLAB_RMV_SRC_BRANCH,
TEST_GITLAB_TOKEN,
TEST_GITLAB_URL,
Expand Down Expand Up @@ -161,6 +162,12 @@ def is_test_env(env: str) -> bool:
if is_test_env(ENV)
else os.environ["GITLAB_MR_KEYWORD"]
)
GITLAB_MR_LABEL_LIST = (
TEST_GITLAB_MR_LABEL_LIST
if is_test_env(ENV)
else os.environ.get("GITLAB_MR_LABEL_LIST", "").split(",")
)

except KeyError as key_error:
logging.error(
"<Gitlab2Sentry>: env vars are not configured properly - {}".format(str(key_error))
Expand Down
2 changes: 2 additions & 0 deletions gitlab2sentry/utils/gitlab_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
GITLAB_GRAPHQL_TIMEOUT,
GITLAB_MENTIONS_ACCESS_LEVEL,
GITLAB_MENTIONS_LIST,
GITLAB_MR_LABEL_LIST,
GITLAB_PROJECT_CREATION_LIMIT,
GITLAB_RMV_SRC_BRANCH,
GITLAB_TOKEN,
Expand Down Expand Up @@ -268,6 +269,7 @@ def _create_mr(
"source_branch": branch_name,
"target_branch": project.default_branch,
"title": title,
"labels": GITLAB_MR_LABEL_LIST,
}
)
return True
Expand Down
2 changes: 2 additions & 0 deletions helm/values-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,5 @@ cronjob:
value: 60
- name: GITLAB_GRAPHQL_PAGE_LENGTH
value: 100
- name: GITLAB_MR_LABEL_LIST
value: "sentry,gitlab2sentry" # comma separated list
3 changes: 2 additions & 1 deletion tests/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@
TEST_GITLAB_AUTHOR_EMAIL = "test-content"
TEST_GITLAB_AUTHOR_NAME = "test-content"
TEST_GITLAB_RMV_SRC_BRANCH = True
TEST_GITLAB_MR_KEYWORD = "sentry"
TEST_GITLAB_MR_KEYWORD = "sentry"
TEST_GITLAB_MR_LABEL_LIST = ["sentry"]
Loading