canonical / jhack

Chock-full of Juju hackery.
Apache License 2.0
50 stars 24 forks source link

`jhack deploy` fails when selecting from multiple .charm files #145

Closed carlcsaposs-canonical closed 5 months ago

carlcsaposs-canonical commented 5 months ago
$ jhack deploy
Multiple charms found in ..
0: mysql-router_ubuntu-22.04-amd64.charm
1: mysql-router_ubuntu-20.04-amd64.charm
pick one (0, 1) [mysql-router_ubuntu-22.04-amd64.charm]: 
Error: PosixPath('mysql-router_ubuntu-22.04-amd64.charm') is not one of '0', '1'.
pick one (0, 1) [mysql-router_ubuntu-22.04-amd64.charm]: 0
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/ubuntu/.local/share/pipx/venvs/jhack/lib/python3.10/site-packages/jhack/utils/just_deploy_ │
│ this.py:113 in just_deploy_this                                                                  │
│                                                                                                  │
│   110 │   - ``$ jhack deploy ./some/path/foo.charm bar -- --to-machine 42``                      │
│   111 │   - ``$ jhack deploy ./some/path/foo.charm bar --refresh -- --to-machine 42``            │
│   112 │   """                                                                                    │
│ ❱ 113 │   _just_deploy_this(path, name, dry_run=dry_run, refresh=refresh)                        │
│   114                                                                                            │
│   115                                                                                            │
│   116 if __name__ == "__main__":                                                                 │
│                                                                                                  │
│ ╭───────── locals ─────────╮                                                                     │
│ │ dry_run = False          │                                                                     │
│ │    name = None           │                                                                     │
│ │    path = PosixPath('.') │                                                                     │
│ │ refresh = False          │                                                                     │
│ ╰──────────────────────────╯                                                                     │
│                                                                                                  │
│ /home/ubuntu/.local/share/pipx/venvs/jhack/lib/python3.10/site-packages/jhack/utils/just_deploy_ │
│ this.py:75 in _just_deploy_this                                                                  │
│                                                                                                  │
│    72 │   if refresh:                                                                            │
│    73 │   │   cmd = f"juju refresh {name} --path {charm.absolute()} {' '.join(resources_args)}   │
│    74 │   else:                                                                                  │
│ ❱  75 │   │   cmd = f"juju deploy {charm.absolute()} {' '.join(resources_args)} {name}{extra_a   │
│    76 │                                                                                          │
│    77 │   if dry_run:                                                                            │
│    78 │   │   print(f"would run:\n\t{cmd}")                                                      │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │              c = PosixPath('mysql-router_ubuntu-20.04-amd64.charm')                          │ │
│ │          charm = '0'                                                                         │ │
│ │         charms = [                                                                           │ │
│ │                  │   PosixPath('mysql-router_ubuntu-22.04-amd64.charm'),                     │ │
│ │                  │   PosixPath('mysql-router_ubuntu-20.04-amd64.charm')                      │ │
│ │                  ]                                                                           │ │
│ │        dry_run = False                                                                       │ │
│ │     extra_args = ''                                                                          │ │
│ │              i = 1                                                                           │ │
│ │           meta = PosixPath('metadata.yaml')                                                  │ │
│ │           name = 'mysql-router'                                                              │ │
│ │           path = PosixPath('.')                                                              │ │
│ │       raw_meta = {                                                                           │ │
│ │                  │   'name': 'mysql-router',                                                 │ │
│ │                  │   'display-name': 'MySQL Router',                                         │ │
│ │                  │   'summary': 'Charmed MySQL Router VM operator',                          │ │
│ │                  │   'description': 'Enables effective access to a MySQL cluster with Group  │ │
│ │                  Replication.\n\nThis charm '+61,                                            │ │
│ │                  │   'docs':                                                                 │ │
│ │                  'https://discourse.charmhub.io/t/charmed-mysql-router-documentation/12131', │ │
│ │                  │   'source': 'https://github.com/canonical/mysql-router-operator',         │ │
│ │                  │   'issues': 'https://github.com/canonical/mysql-router-operator/issues',  │ │
│ │                  │   'website': [                                                            │ │
│ │                  │   │   'https://ubuntu.com/data/mysql',                                    │ │
│ │                  │   │   'https://charmhub.io/mysql-router',                                 │ │
│ │                  │   │   'https://github.com/canonical/mysql-router-operator',               │ │
│ │                  │   │   'https://chat.charmhub.io/charmhub/channels/data-platform'          │ │
│ │                  │   ],                                                                      │ │
│ │                  │   'maintainers': [                                                        │ │
│ │                  │   │   'Canonical Data Platform <data-platform@lists.launchpad.net>'       │ │
│ │                  │   ],                                                                      │ │
│ │                  │   'subordinate': True,                                                    │ │
│ │                  │   ... +3                                                                  │ │
│ │                  }                                                                           │ │
│ │       raw_name = 'mysql-router'                                                              │ │
│ │  raw_resources = {}                                                                          │ │
│ │        refresh = False                                                                       │ │
│ │ resources_args = []                                                                          │ │
│ │           trim = <function _just_deploy_this.<locals>.trim at 0x7feaba8d69e0>                │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'str' object has no attribute 'absolute'
  1. default argument fails (guessing [] is default)
  2. passing 0 fails
PietroPasotti commented 5 months ago

Gotcha! Found the issue, will be releasing soon to edge.