Merge ppa-dev-tools:add-ppa-credentials-command into ppa-dev-tools:main

Proposed by Bryce Harrington
Status: Merged
Merge reported by: Bryce Harrington
Merged at revision: 3fed215c7ab95c1753c3136e2d278aa1d195a1c4
Proposed branch: ppa-dev-tools:add-ppa-credentials-command
Merge into: ppa-dev-tools:main
Diff against target: 397 lines (+185/-31)
6 files modified
ppa/constants.py (+2/-0)
ppa/lp.py (+37/-16)
scripts/ppa (+77/-10)
tests/helpers.py (+12/-1)
tests/test_lp.py (+4/-4)
tests/test_scripts_ppa.py (+53/-0)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  (community) Approve
PpaDevTools Developers Pending
Canonical Server packageset reviewers Pending
Canonical Server Reporter Pending
Review via email: mp+450981@code.staging.launchpad.net

Description of the change

This adds a 'ppa credentials' command that dumps your Launchpad creds to a file, that can be passed back in via LP_CREDENTIALS.

This enables a workaround for LP: #2022363, but may be handy for any case where either you can't log in via the website, or the automatically stored credentials aren't getting read for some reason.

This is not a complete solution for LP: #2022363, since the snap should be handling this automatically, but that will require separate investigation.

I imagine this command could benefit from some options, like specifying how to name the credentials file, and it might be nice to be able to refer to it via --credentials-file=<filename> instead of via the env variable. But for this first pass I'm keeping it simple, as I just want the functionality available for the release, which I want to get out the door ASAP.

To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

A few minor comments and suggestions to improve before merging as we might never look back to it otherwise.

The "allow argument to specify output file" seems so easy that it should IMHO be added.
I mean any snap magic that needs to be research, yes that is later.
But allowing where to store, that should be so easy that we should not hold back on that.

And TBH a global arg (not per subcommand, but generally available) to pass a filename.
"--use-credential" (if no arg given also using the default path) and "--use-credential foo" which would do not more but load that into the environment variable - that also seems rather close. Like <1h of work.
So again, unless you already released by time pressure, please consider adding that right away.

review: Needs Fixing
Revision history for this message
Bryce Harrington (bryce) wrote :

Unfortunately this was kind of a "pull a loose thread from a sweater" problem, and ended up actually involving a more extensive amount of work than apparent. The credentials handling is pretty early on in the process (obviously) which made it tricky to tweak without breaking other things, but the good news is that the testsuite is extensive and thorough enough now that it was super helpful in spotting problems.

I've refactored the env var handling to be more general purpose, and layered in functionality to allow it to come from the specified file. I opted to name the option --credentials rather than --use-credentials to match the similar option --config.

I had initially hoped to split the review changes out separately to make it easier for you to check, but due to needing to add more fixes it was simpler to just merge all the rework into the main commits. Hopefully you can see what changed via range-diff, although since so much changed it may be worth just doing a fresh review from scratch.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

+1 on refactoring the argparse and help text later in a separate PR - just make sure it is not forgotten

This MP LGMT now, the few things that came to my mind were too small to mention or known and can be done in follow up iterations.

review: Approve
Revision history for this message
Bryce Harrington (bryce) wrote :

Thanks, change landed to main:

$ git merge --ff-only add-ppa-credentials-command
Updating 06e6152..20533a7
Fast-forward
 ppa/constants.py | 2 ++
 ppa/lp.py | 53 +++++++++++++++++++++++++++++++++++----------------
 scripts/ppa | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
 tests/helpers.py | 13 ++++++++++++-
 tests/test_lp.py | 8 ++++----
 tests/test_scripts_ppa.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 185 insertions(+), 31 deletions(-)
$ git push origin
Enumerating objects: 33, done.
Counting objects: 100% (33/33), done.
Delta compression using up to 12 threads
Compressing objects: 100% (20/20), done.
Writing objects: 100% (23/23), 4.83 KiB | 1.21 MiB/s, done.
Total 23 (delta 17), reused 0 (delta 0), pack-reused 0
To git+ssh://git.launchpad.net/ppa-dev-tools
   06e6152..20533a7 main -> main

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to all changes: