charmed-lma / charm-k8s-grafana

Kubernetes Operator for Grafana
Apache License 2.0
5 stars 3 forks source link

Simplify ImageMeta #10

Open facundobatista opened 4 years ago

facundobatista commented 4 years ago

It looks its only purpose is to provide a "holder" to move some data around, so you can do...

                'imagePath': image_meta.image_path,

...instead of...

                'imagePath': image_meta['registrypath'],

As it doesn't have other functionality, you could just use a namedtuple:

>>> from collections import namedtuple
>>> ImageMeta = namedtuple('ImageMeta', 'image_path repo_username repo_password')
>>> rd = dict(registrypath='foo', username='bar', password='baz')
>>> im = ImageMeta(image_path=rd['registrypath'], repo_username=rd['username'], repo_password=rd['password'])
>>> im.image_path
'foo'