-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #7
- Loading branch information
Showing
11 changed files
with
535 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import json | ||
import os | ||
|
||
import dxf | ||
import frappe | ||
from erpnext_feature_board.clients.k8s import get_container_registry | ||
|
||
|
||
def get_registry_client(repo=None): | ||
auth = get_container_registry_auth() | ||
is_dev_mode = True if frappe.get_conf().get("developer_mode") else False | ||
|
||
dxf_client = dxf.DXF( | ||
get_container_registry(), | ||
auth=auth, | ||
repo=repo, | ||
insecure=is_dev_mode, | ||
tlsverify=not is_dev_mode, | ||
) | ||
dxf_client.authenticate(authorization=auth, actions=["*"]) | ||
|
||
return dxf_client | ||
|
||
|
||
def get_container_registry_auth(): | ||
config = {} | ||
home = os.environ.get("HOME", "/home/frappe") | ||
docker_config = os.path.join(home, ".docker", "config.json") | ||
|
||
with open(docker_config, encoding="utf-8") as f: | ||
config = json.load(f) | ||
|
||
return "Basic " + ( | ||
config.get("auths", {}) | ||
.get(get_container_registry(), {}) | ||
.get("auth", "YWRtaW46cGFzc3dvcmQ=") | ||
) | ||
|
||
|
||
def delete_image_tag(image_name, tag_name): | ||
try: | ||
dxf_client = get_registry_client(image_name) | ||
res = dxf_client.del_alias(tag_name) | ||
return res | ||
except Exception as e: | ||
out = { | ||
"error": e, | ||
"params": {"image_name": image_name, "tag_name": tag_name}, | ||
} | ||
|
||
frappe.log_error(out, "delete_image_tag") | ||
return out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 56 additions & 1 deletion
57
erpnext_feature_board/erpnext_feature_board/doctype/improvement/improvement.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,66 @@ | ||
# Copyright (c) 2021, ERPNext Community and contributors | ||
# For license information, please see license.txt | ||
|
||
# import frappe | ||
import frappe | ||
from frappe import _ | ||
from frappe.website.website_generator import WebsiteGenerator | ||
|
||
|
||
class Improvement(WebsiteGenerator): | ||
# the WebsiteGenerator class overrides the naming_series in the | ||
# doctype definition, overriding the override | ||
autoname = "naming_series:" | ||
|
||
|
||
@frappe.whitelist(methods=["POST"]) | ||
def queue_deployment(improvement_name): | ||
return set_deployment_status( | ||
improvement_name, | ||
"Build Queued", | ||
).as_dict() | ||
|
||
|
||
@frappe.whitelist(methods=["POST"]) | ||
def queue_upgrade(improvement_name): | ||
return set_deployment_status( | ||
improvement_name, | ||
"Upgrade Queued", | ||
).as_dict() | ||
|
||
|
||
@frappe.whitelist(methods=["POST"]) | ||
def queue_delete(improvement_name): | ||
return set_deployment_status( | ||
improvement_name, | ||
"Delete Queued", | ||
).as_dict() | ||
|
||
|
||
def set_deployment_status(improvement_name, deployment_status): | ||
imps_under_process = frappe.get_list( | ||
"Improvement", | ||
filters={ | ||
"deployment_status": [ | ||
"in", | ||
[ | ||
"Build Queued", | ||
"Building", | ||
"Build Complete", | ||
"Release Queued", | ||
"Upgrade Queued", | ||
"Rebuilding", | ||
"Rebuild Complete", | ||
"Upgrading", | ||
"Delete Queued", | ||
"Release Deleted", | ||
], | ||
], | ||
}, | ||
) | ||
if imps_under_process: | ||
frappe.throw(_("Improvements already under process")) | ||
|
||
improvement = frappe.get_doc("Improvement", improvement_name) | ||
improvement.deployment_status = deployment_status | ||
improvement.save() | ||
return improvement |
39 changes: 39 additions & 0 deletions
39
erpnext_feature_board/erpnext_feature_board/workspace/feature_board/feature_board.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"category": "Modules", | ||
"charts": [], | ||
"creation": "2021-06-04 13:23:22.576857", | ||
"developer_mode_only": 0, | ||
"disable_user_customization": 0, | ||
"docstatus": 0, | ||
"doctype": "Workspace", | ||
"extends_another_page": 0, | ||
"hide_custom": 0, | ||
"icon": "", | ||
"idx": 0, | ||
"is_default": 0, | ||
"is_standard": 1, | ||
"label": "Feature Board", | ||
"links": [], | ||
"modified": "2021-06-04 13:23:22.576857", | ||
"modified_by": "Administrator", | ||
"module": "ERPNext Feature Board", | ||
"name": "Feature Board", | ||
"owner": "Administrator", | ||
"pin_to_bottom": 0, | ||
"pin_to_top": 0, | ||
"shortcuts": [ | ||
{ | ||
"doc_view": "List", | ||
"label": "Github Repository", | ||
"link_to": "Github Repository", | ||
"type": "DocType" | ||
}, | ||
{ | ||
"doc_view": "List", | ||
"label": "Improvement", | ||
"link_to": "Improvement", | ||
"type": "DocType" | ||
} | ||
], | ||
"shortcuts_label": "Feature Links" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.