Merge ~bjornt/maas/+git/maas-release-tools:release-status-new-snapcraft into ~maas-committers/maas/+git/maas-release-tools:main

Proposed by Björn Tillenius
Status: Merged
Approved by: Björn Tillenius
Approved revision: 536c2c20b39a78b515e8d4e56b1a77e9cfde0d85
Merged at revision: 536c2c20b39a78b515e8d4e56b1a77e9cfde0d85
Proposed branch: ~bjornt/maas/+git/maas-release-tools:release-status-new-snapcraft
Merge into: ~maas-committers/maas/+git/maas-release-tools:main
Diff against target: 74 lines (+15/-18)
1 file modified
maas_release_tools/scripts/release_status.py (+15/-18)
Reviewer Review Type Date Requested Status
Alberto Donato (community) Approve
Review via email: mp+429690@code.launchpad.net

Commit message

Fix release-status to work with new (7.0) snapcraft.

The format of the credentials produced by 'snapcraft export-login'
has changed.

To post a comment you must log in.
Revision history for this message
Alberto Donato (ack) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/maas_release_tools/scripts/release_status.py b/maas_release_tools/scripts/release_status.py
2index 511b301..bf6743a 100644
3--- a/maas_release_tools/scripts/release_status.py
4+++ b/maas_release_tools/scripts/release_status.py
5@@ -14,8 +14,9 @@ will go smoother.
6
7 from abc import ABC, abstractmethod
8 from argparse import ArgumentParser, FileType
9-from configparser import ConfigParser
10+import base64
11 import glob
12+import json
13 import subprocess
14 import sys
15 from typing import Optional
16@@ -406,23 +407,18 @@ class PackagesCopiedToReleasePPA(MAASPPA):
17 return self._check_packages_copied(source_ppa, target_ppa)
18
19
20-def macaroon_auth(conf):
21+def macaroon_auth(macaroons):
22 """Format a macaroon and its associated discharge.
23
24 :return: A string suitable to use in an Authorization header.
25
26 """
27- root_macaroon_raw = conf.get("macaroon")
28- unbound_raw = conf.get("unbound_discharge")
29-
30- root_macaroon = Macaroon.deserialize(root_macaroon_raw)
31- unbound = Macaroon.deserialize(unbound_raw)
32- bound = root_macaroon.prepare_for_request(unbound)
33- discharge_macaroon_raw = bound.serialize()
34- auth = "Macaroon root={}, discharge={}".format(
35- root_macaroon_raw, discharge_macaroon_raw
36- )
37- return auth
38+ root_macaroon = Macaroon.deserialize(macaroons["r"])
39+ discharged_macaroon = Macaroon.deserialize(macaroons["d"])
40+ bound_macaroon = root_macaroon.prepare_for_request(
41+ discharged_macaroon
42+ ).serialize()
43+ return f"Macaroon root={macaroons['r']}, discharge={bound_macaroon}"
44
45
46 class PackageBuilt(ReleaseStep):
47@@ -611,21 +607,22 @@ def parse_args():
48
49 def main():
50 args = parse_args()
51- config = ConfigParser()
52- config.read("release.macaroon")
53+ with open("release.macaroon", "r") as credentials_file:
54+ raw = base64.b64decode(credentials_file.read())
55 try:
56- macaroon = config["login.ubuntu.com"]
57- except KeyError:
58+ macaroons = json.loads(raw)
59+ except json.decoder.JSONDecodeError:
60 print("Macaroon couldn't be found", file=sys.stderr)
61 print(get_macaroon_refresh_help(), file=sys.stderr)
62 return 1
63+
64 launchpad = LaunchpadActions(
65 "maas", credentials_file=args.launchpad_credentials
66 )
67 release_version = ReleaseVersion(args.version)
68 preparer = ReleasePreparer(
69 release_version,
70- macaroon_auth(macaroon),
71+ macaroon_auth(macaroons),
72 launchpad=launchpad,
73 )
74 preparer.steps = [

Subscribers

People subscribed via source and target branches