Merge lp:~thomir-deactivatedaccount/charm-haproxy/make-config-less-insane into lp:~ubuntuone-pqm-team/charm-haproxy/snap-store

Proposed by Thomi Richards on 2017-07-25
Status: Merged
Merged at revision: 111
Proposed branch: lp:~thomir-deactivatedaccount/charm-haproxy/make-config-less-insane
Merge into: lp:~ubuntuone-pqm-team/charm-haproxy/snap-store
Diff against target: 37 lines (+17/-9)
1 file modified
hooks/hooks.py (+17/-9)
To merge this branch: bzr merge lp:~thomir-deactivatedaccount/charm-haproxy/make-config-less-insane
Reviewer Review Type Date Requested Status
William Grant goodlord 2017-07-25 Approve on 2017-07-25
Review via email: mp+328004@code.launchpad.net

Commit message

Allow users to force particular option strings to the FE or BE sections.

Description of the change

Allow users to force particular option strings to the FE or BE sections, since the charm apparently has decided to tell me where my options must live :(

To post a comment you must log in.
112. By Thomi Richards on 2017-07-25

Fix service option filtering.

113. By Thomi Richards on 2017-07-25

Consolidate two loops.

114. By Thomi Richards on 2017-07-25

Code cleanups.

115. By Thomi Richards on 2017-07-25

Code cleanups.

116. By Thomi Richards on 2017-07-25

Code cleanups.

117. By Thomi Richards on 2017-07-25

Code cleanups.

William Grant (wgrant) wrote :

good riddance

review: Approve (code)
118. By Thomi Richards on 2017-07-25

Fixed failing test.

William Grant (wgrant) :
review: Approve (goodlord)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/hooks.py'
2--- hooks/hooks.py 2017-03-02 16:10:43 +0000
3+++ hooks/hooks.py 2017-07-25 07:09:10 +0000
4@@ -347,16 +347,24 @@
5 if any(map(o.strip().startswith, service_options)):
6 fe_options.append(o)
7 be_options.append(o)
8+
9 # Filter provided service options into frontend-only and backend-only.
10- results = izip(
11- (fe_options, be_options),
12- (True, False),
13- tee((o, any(map(o.strip().startswith,
14- frontend_only_options)))
15- for o in service_options))
16- for out, cond, result in results:
17- out.extend(option for option, match in result
18- if match is cond and option not in out)
19+ # XXX: The '{FE}' and '{BE}' feature is a local patch in this version
20+ # of the charm, and is not present in the upstream charm.
21+ for option in service_options:
22+ option = option.strip()
23+ if option.startswith('{FE}'):
24+ fe_options.append(option[4:].strip())
25+ elif option.startswith('{BE}'):
26+ be_options.append(option[4:].strip())
27+ else:
28+ if any(map(option.startswith, frontend_only_options)):
29+ if option not in fe_options:
30+ fe_options.append(option)
31+ else:
32+ if option not in be_options:
33+ be_options.append(option)
34+
35 service_config = []
36 unit_name = os.environ["JUJU_UNIT_NAME"].replace("/", "-")
37 service_config.append("frontend %s-%s" % (unit_name, service_port))

Subscribers

People subscribed via source and target branches

to all changes: