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

[Feature]: Add charm_name on ApplicationStatus #888

Closed
gabrielcocenza opened this issue Jun 23, 2023 · 1 comment
Closed

[Feature]: Add charm_name on ApplicationStatus #888

gabrielcocenza opened this issue Jun 23, 2023 · 1 comment
Assignees
Labels
kind/wishlist requested feature

Comments

@gabrielcocenza
Copy link

Description

We are using libjuju to access status of applications.
A simple juju status --format yaml gives this kind of output:

applications:
  keystone:
    charm: keystone
    series: focal
    os: ubuntu
    charm-origin: charmhub
    charm-name: keystone
    charm-rev: 636
    charm-channel: victoria/stable
    exposed: false
....

Using libjuju gives a ApplicationStatus object containing the following fields:

{
   "base":"<class""juju.client._definitions.Base"">("{
      "channel":"20.04/stable",
      "name":"ubuntu",
      "unknown_fields":{
         
      }
   }")",
   "can_upgrade_to":"",
   "charm":"ch:amd64/focal/keystone-636",
   "charm_channel":"victoria/stable",
   "charm_profile":"",
   "charm_version":"",

The way that we are getting the charm name is by applying a regex to get rid off charm origin, architecture and revision.
It seems to me that a new field in this class like charm_name is simple and can help us get the name directly without a workaround.

Urgency

It would save from a weird workaround

Code I'd Like to Run

$ python3 -m asyncio


>>> from juju.model import Model
>>> model = Model()
>>> await model.connect_current()
>>> status = await model.get_status()

>>> status.applications["keystone"].charm_name
keystone
@gabrielcocenza gabrielcocenza added the kind/wishlist requested feature label Jun 23, 2023
@cderici cderici self-assigned this Jun 28, 2023
cderici added a commit to cderici/python-libjuju that referenced this issue Jul 10, 2023
jujubot added a commit that referenced this issue Jul 12, 2023
#901

#### Description

Adds the `charm_name` property in `Application` object, which saves people from going through the status and stripping things from the charm URL, just to get the name of the charm.

Fixes #888 

The issue in there was that the `FullStatus` actually returns the charm URL as the `charm` field in `[] ApplicationStatus` field, but the client is aliasing it before printing so you see only the charm name in the `juju status --format yaml`

https://github.com/juju/juju/blob/87d8ddc9de5219b3a1d854e14ee4c90a7d781d25/cmd/juju/status/formatter.go#L267

#### QA Steps

```
tox -e integration -- tests/integration/test_application.py::test_app_charm_name
```
@cderici
Copy link
Contributor

cderici commented Jul 12, 2023

Closed by #901

@cderici cderici closed this as completed Jul 12, 2023
cderici added a commit to cderici/python-libjuju that referenced this issue Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/wishlist requested feature
Projects
None yet
Development

No branches or pull requests

2 participants