It is hard to open juju API if you're not implementing a ModelCommand

Bug #1566271 reported by Roger Peppe
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Triaged
Low
Unassigned

Bug Description

Much of the logic for finding out the current model and controller
lives in ModelCommandBase.SetModelName and related
methods.

When implementing a command that is not a ModelCommand
(for whatever reason - perhaps it's a regular Go command that
isn't using the juju/cmd package), connecting to the API
of the current model involves a lot of copy and paste
of the code in ModelCommandBase and friends.

There should be a high level package API that makes
it trivial to connect to the Juju network API.

Roger Peppe (rogpeppe)
description: updated
description: updated
Changed in juju-core:
status: New → Triaged
importance: Undecided → Medium
affects: juju-core → juju
Revision history for this message
Anastasia (anastasia-macmood) wrote :

Since this bug was filed, there was a new command base introduced - juju/cmd/modelcmd.ControllerCommand.

I believe this base allows to achieve what you described, so I believe this is fixed.

Let me know if you think otherwise.

Changed in juju:
status: Triaged → Fix Released
Revision history for this message
Simon Richardson (simonrichardson) wrote :

I'm reopening this one.

It really is way too hard to open an API connection to connect to Juju without using the cmd package. You shouldn't rely on anything in the cmd package to open an API connection.

An example of what is actually required can be found here[1], yet somehow we still have modelcmd in the mix. This really should never be the case.

If we want others to play nicely with Juju, we should fix this with some expediency.

1. https://github.com/SimonRichardson/juju-api-example/tree/main/client

Changed in juju:
status: Fix Released → Triaged
Revision history for this message
Canonical Juju QA Bot (juju-qa-bot) wrote :

This Medium-priority bug has not been updated in 60 days, so we're marking it Low importance. If you believe this is incorrect, please update the importance.

Changed in juju:
importance: Medium → Low
tags: added: expirebugs-bot
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.