Skip to content

Commit

Permalink
[ADD] Security group dedicated for reporting statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
tarteo committed Aug 27, 2024
1 parent 8abceef commit 4c5f261
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions argocd_deployer/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"views/application_stat_type_view.xml",
"views/application_stat_view.xml",
"templates/application_description.xml",
"security/res_groups.xml",
"security/ir.model.access.csv",
"menuitems.xml",
],
Expand Down
8 changes: 5 additions & 3 deletions argocd_deployer/models/application_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ def create_stats(self, application_name, stats):
- message: string value
@return: ids of the created records
"""
application = self.env["argocd.application"].search(
[("name", "=", application_name)]
)
application = (
self.env["argocd.application"]
.sudo()
.search([("name", "=", application_name)])
) # sudo so we don't have to give access to argocd.application which can contain sensitive information
if not application:
raise MissingError(
"Application with name `%s` doesn't exist" % application_name
Expand Down
2 changes: 2 additions & 0 deletions argocd_deployer/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ application_namespace_prefix_access,application_namespace_prefix_access,model_ar
application_domain_access,application_domain_access,model_argocd_application_domain,base.group_system,1,1,1,1
application_stat_access,application_stat_access,model_argocd_application_stat,base.group_system,1,1,1,1
application_stat_type_access,application_stat_type_access,model_argocd_application_stat_type,base.group_system,1,1,1,1
application_stat_reporter_access,application_stat_reporter_access,model_argocd_application_stat,argocd_deployer.group_report_stats,0,0,1,0
application_stat_type_reporter_access,application_stat_type_reporter_access,model_argocd_application_stat_type,argocd_deployer.group_report_stats,1,0,0,0
7 changes: 7 additions & 0 deletions argocd_deployer/security/res_groups.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="group_report_stats" model="res.groups">
<field name="name">Application Statistics Reporter</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
</odoo>
1 change: 1 addition & 0 deletions argocd_deployer/views/application_value_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<tree editable="bottom">
<field name="application_id" invisible="1" />
<field name="key" />
<field name="message" />
<field name="value" />
</tree>
</field>
Expand Down

0 comments on commit 4c5f261

Please sign in to comment.