Skip to content

Commit

Permalink
feat(app_source): Add gitlab_access_token field
Browse files Browse the repository at this point in the history
  • Loading branch information
cogk committed Apr 26, 2024
1 parent 17a420b commit 752f033
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions press/press/doctype/app_source/app_source.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"github_installation_id",
"uninstalled",
"gitlab_project_id",
"gitlab_access_token",
"section_break_12",
"versions",
"github_section",
Expand Down Expand Up @@ -83,6 +84,12 @@
"fieldtype": "Data",
"label": "GitLab Project ID"
},
{
"depends_on": "eval:doc.gitlab_project_id",
"fieldname": "gitlab_access_token",
"fieldtype": "Password",
"label": "GitLab Access Token"
},
{
"fieldname": "data_3",
"fieldtype": "Column Break"
Expand Down
11 changes: 9 additions & 2 deletions press/press/doctype/app_source/app_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,15 @@ def create_gitlab_release(self, force=False):
url = f"{repo_url.scheme}://{repo_url.netloc}{api_path}"

headers = {}
# if gitlab_token := frappe.get_value("Press Settings", None, "gitlab_access_token"):
# headers["Authorization"] = f"Bearer {gitlab_token}"

gitlab_token = ""
if self.get("gitlab_access_token"):
gitlab_token = gitlab_token or self.get_password("gitlab_access_token")
# gitlab_token = gitlab_token or frappe.db.get_single_value("Press Settings", None, "gitlab_access_token")

if gitlab_token:
headers["Authorization"] = f"Bearer {gitlab_token}"

res = requests.get(url, headers=headers).json()

frappe.db.set_value(
Expand Down

0 comments on commit 752f033

Please sign in to comment.