canonical / discourse-k8s-operator

discourse-k8s-operator - charm repository.
Apache License 2.0
6 stars 5 forks source link

Revisited add-admin action #241

Closed codethulu closed 2 months ago

codethulu commented 4 months ago

Overview

Created an add_user action, which simply creates a user account. The on_add_admin method then is responsible for calling this method, and then promoting the user to admin level. This behaviour has effectively been split.

Rationale

We want an action to change an existing user to an admin and an action to create a user. And if the user already exists, we don’t want to update the password. If the user doesn’t exist, we can to create the user and generate a random secure password for them.

Juju Events Changes

N/A

Module Changes

N/A

Library Changes

No significant changes, just updates to be consistent with main.

Checklist

codethulu commented 3 months ago

There were a few methods that needed to be considered. In the end, after discussion with @nrobinaubertin and @amandahla I have decided to create a new rake patch -

This approach was chosen for a few reasons:

codethulu commented 3 months ago

Additionally, the previous rake patch to add user:anonymize has been removed, since this has been merged to discourse in version 3.2.0, which is what we use in rockcraft.

nrobinaubertin commented 3 months ago

rather places additional rake commands in a canonical.rake file

I would name it something like discourse-charm.rake to avoid tying it directly to the Canonical name (it's not a patch specifically for our needs but for the charm's needs)

github-actions[bot] commented 2 months ago

Test coverage for 6df044233c2d2b49c178c53e2e7ae3cdf42dd168

Name              Stmts   Miss Branch BrPart  Cover   Missing
-------------------------------------------------------------
src/charm.py        371     41     94     15    88%   184, 192-193, 205, 337->345, 378->383, 395, 577-579, 584-585, 597-599, 604-605, 617-619, 642-644, 686->exit, 696->exit, 745-748, 758-759, 783-784, 796-797, 824-826, 828->833, 830-831, 873-874, 890-891, 901->exit, 915
src/database.py      29      1      8      1    95%   56
-------------------------------------------------------------
TOTAL               400     42    102     16    88%

Static code analysis report

Run started:2024-06-14 14:28:12.926870

Test results:
    No issues identified.

Code scanned:
    Total lines of code: 2336
    Total lines skipped (#nosec): 2
    Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
    Total issues (by severity):
        Undefined: 0
        Low: 0
        Medium: 0
        High: 0
    Total issues (by confidence):
        Undefined: 0
        Low: 0
        Medium: 0
        High: 0
Files skipped (0):