canonical / canonical/data-platform-helpers

Add display helpers

Open
#21 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
2
Forks
1
Avg merge
14m
Merged PRs (30d)
1

Description

I have a couple of ideas for a `display` submodule:

### Backup tables

Since we should have more or less the same fields in our charms, we could regroup our existing solutions to create those kinds of tables:

```
backup-id | backup-type | backup-status
----------------------------------------------------
YYYY-MM-DDTHH:MM:SSZ | logical | finished
```

Two existing solutions:
- Manual approach: https://github.com/canonical/mongodb-operator/blob/6/edge/lib/charms/mongodb/v1/mongodb_backups.py#L576
- Object oriented (with third-party dep): https://github.com/canonical/zookeeper-operator/blob/main/src/managers/backup.py#L160

### Log friendly state diffs

We work with data structure subject to changes. It can be a relation databag or an application configuration.
The idea here is to create a function to properly display the difference between a "before" and an "after" state.
For reference, here is what I like to see in my package manager post upgrade:

```
Version changes:
[U.] #1 pyenv 2.4.11 -> 2.4.12
[U.] #2 pyright 1.1.378 -> 1.1.380
[U.] #3 pyright-internal 1.1.378 -> 1.1.380
[U.] #4 ruff 0.6.4 -> 0.6.5
[U.] #5 uv 0.4.8 -> 0.4.10
[U.] #6 zoxide 0.9.4 -> 0.9.5
Added packages:
[A.] #1 bottom 0.10.2
Removed packages:
[R.] #1 btop 1.3.2
```

I think ^this (replace "packages" by "keys") would be a nice addition to log state changes in our charms.
Pedro made a valid point by saying that we need to scrub passwords from those. We could take some inspiration/regex from what sos report does?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by comparing the referenced backup implementations in mongodb_backups.py and backup.py, then determine the package entry point for the proposed display submodule. Define the backup-table and state-diff interfaces, including password scrubbing, and add tests that cover the displayed output and sensitive values.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.