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

install-plugin action #311

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

install-plugin action #311

wants to merge 1 commit into from

Conversation

PietroPasotti
Copy link
Contributor

adds a development action to download and install into grafana a plugin.

Usage:
juju run grafana install-plugin some-plugin 1.0.0

The script will grab the plugin from grafana.com/api/plugins/some-plugin/versions/1.0.0/downloads, and unzip it into /var/lib/grafana/plugins, then restart grafana and the plugin should be there.

Can't test it at the moment because charmcraft pack is bork on main.

name:
type: string
description: |
Name of the plugin. Must be hosted at https://grafana.com/grafana/plugins`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make more sense to have url as the param?
That would lift the grafana.com restriction and the /plugins/{name}/versions/{version}/download assumption.

Or, if we want to keep the grafana.com restriction, then we could use grafana cli for that, which would be great help with uninstalling (which is currently missing in the PR).

Comment on lines +1161 to +1162
url = f"https://grafana.com/api/plugins/{name}/versions/{version}/download"
path = Path('/var/lib/grafana/plugins')
Copy link
Contributor

Choose a reason for hiding this comment

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

I would extract path and url to constants

Comment on lines +1183 to +1184
installed_plugins = [o.strip() for o in subprocess.getoutput("grafana cli plugin ls").splitlines()[1:]]
download_path.unlink()
Copy link
Contributor

Choose a reason for hiding this comment

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

I would put this inside a try...except blick

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.

4 participants