Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Magic Strings with literals.py Constants #208

Merged
merged 4 commits into from
Dec 5, 2024

Conversation

mateoflorido
Copy link
Member

Overview

Replace magic string in the codebase with constants.

Rationale

To align with the best practices from other charms and improve the code maintainability, this pull request replaces the "magic strings" used in the code with constants.

@mateoflorido mateoflorido requested a review from a team as a code owner December 4, 2024 20:13
@mateoflorido mateoflorido force-pushed the KU-2255/charm-literals branch from 7b8af28 to 6c836f9 Compare December 4, 2024 20:16
@mateoflorido mateoflorido force-pushed the KU-2255/charm-literals branch from 6c836f9 to 3526e53 Compare December 4, 2024 21:06
Copy link
Contributor

@addyess addyess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work, also liked the drive by

Comment on lines -207 to 206
if K8S_DQLITE_SERVICE in services and self.charm.datastore == "dqlite":
if K8S_DQLITE_SERVICE in services and self.charm.datastore != "dqlite":
services.remove(K8S_DQLITE_SERVICE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow yes king!

Copy link
Contributor

@louiseschmidtgen louiseschmidtgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thanks Mateo!

Copy link
Contributor

github-actions bot commented Dec 5, 2024

Test coverage for 8ef33d2

coverage-report: install_deps /home/runner/work/k8s-operator/k8s-operator/charms/worker/k8s> python -I -m pip install 'coverage[toml]'
coverage-report: commands[0] /home/runner/work/k8s-operator/k8s-operator/charms/worker/k8s> coverage report
Name                                    Stmts   Miss  Cover
-----------------------------------------------------------
lib/charms/k8s/v0/k8sd_api_manager.py     278     29    90%
src/charm.py                              489    242    51%
src/cloud_integration.py                   80      3    96%
src/config/extra_args.py                   27      1    96%
src/containerd.py                         140     16    89%
src/cos_integration.py                     33     12    64%
src/events/update_status.py                51     10    80%
src/inspector.py                           40      4    90%
src/kube_control.py                        39     31    21%
src/literals.py                            21      0   100%
src/protocols.py                           26      5    81%
src/reschedule.py                          77      4    95%
src/snap.py                               185     26    86%
src/token_distributor.py                  181    109    40%
src/upgrade.py                            105     48    54%
-----------------------------------------------------------
TOTAL                                    1772    540    70%
coverage-report: OK (1.23=setup[1.02]+cmd[0.21] seconds)
congratulations :) (1.28 seconds)

Static code analysis report

Run started:2024-12-05 13:51:48.382599

Test results:
  No issues identified.

Code scanned:
  Total lines of code: 3789
  Total lines skipped (#nosec): 3
  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):

@mateoflorido mateoflorido merged commit 0b7a377 into main Dec 5, 2024
61 checks passed
@mateoflorido mateoflorido deleted the KU-2255/charm-literals branch December 5, 2024 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants