Merge ~mthaddon/charm-k8s-discourse/+git/charm-k8s-discourse:tests into ~jk0ne/charm-k8s-discourse/+git/charm-k8s-discourse:tests

Proposed by Tom Haddon
Status: Merged
Approved by: Jay Kuri
Approved revision: 580d8b48f5039a317991ba287bd4a6cfc8669459
Merged at revision: 580d8b48f5039a317991ba287bd4a6cfc8669459
Proposed branch: ~mthaddon/charm-k8s-discourse/+git/charm-k8s-discourse:tests
Merge into: ~jk0ne/charm-k8s-discourse/+git/charm-k8s-discourse:tests
Diff against target: 1126 lines (+781/-85)
14 files modified
.gitmodules (+1/-4)
COPYRIGHT (+16/-0)
LICENSE (+674/-0)
Makefile (+8/-4)
dev/null (+0/-1)
metadata.yaml (+1/-1)
pyproject.toml (+3/-0)
requirements.txt (+1/-4)
src/charm.py (+41/-45)
tests/unit/fixtures/config_valid_1.yaml (+3/-3)
tests/unit/fixtures/config_valid_2.yaml (+3/-3)
tests/unit/fixtures/config_valid_3.yaml (+3/-3)
tests/unit/test_charm.py (+22/-15)
tox.ini (+5/-2)
Reviewer Review Type Date Requested Status
Jay Kuri Pending
Review via email: mp+390645@code.launchpad.net

Commit message

Switch to using requirements.txt for ops rather than submodule, update submodule path for oci-image to be generic, add COPYRIGHT & LICENSE files, add blacken to lint.

Description of the change

Switch to using requirements.txt for ops rather than submodule, update submodule path for oci-image to be generic, add COPYRIGHT & LICENSE files, add blacken to lint.

I've also removed the "pragma: no cover" from `on_new_client` - I don't think we should ignore this just because we don't have a test for it yet.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/.gitmodules b/.gitmodules
2index 75335ec..1d583a7 100644
3--- a/.gitmodules
4+++ b/.gitmodules
5@@ -1,6 +1,3 @@
6-[submodule "mod/operator"]
7- path = mod/operator
8- url = https://github.com/canonical/operator
9 [submodule "mod/resource-oci-image"]
10 path = mod/resource-oci-image
11- url = git@github.com:johnsca/resource-oci-image.git
12+ url = https://github.com/johnsca/resource-oci-image
13diff --git a/COPYRIGHT b/COPYRIGHT
14new file mode 100644
15index 0000000..1889423
16--- /dev/null
17+++ b/COPYRIGHT
18@@ -0,0 +1,16 @@
19+Format: http://dep.debian.net/deps/dep5/
20+
21+Files: *
22+Copyright: Copyright 2020, Canonical Ltd.
23+License: GPL-3
24+ This program is free software: you can redistribute it and/or modify
25+ it under the terms of the GNU General Public License version 3, as
26+ published by the Free Software Foundation.
27+ .
28+ This program is distributed in the hope that it will be useful,
29+ but WITHOUT ANY WARRANTY; without even the implied warranties of
30+ MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
31+ PURPOSE. See the GNU General Public License for more details.
32+ .
33+ You should have received a copy of the GNU General Public License
34+ along with this program. If not, see <http://www.gnu.org/licenses/>.
35diff --git a/LICENSE b/LICENSE
36new file mode 100644
37index 0000000..94a9ed0
38--- /dev/null
39+++ b/LICENSE
40@@ -0,0 +1,674 @@
41+ GNU GENERAL PUBLIC LICENSE
42+ Version 3, 29 June 2007
43+
44+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
45+ Everyone is permitted to copy and distribute verbatim copies
46+ of this license document, but changing it is not allowed.
47+
48+ Preamble
49+
50+ The GNU General Public License is a free, copyleft license for
51+software and other kinds of works.
52+
53+ The licenses for most software and other practical works are designed
54+to take away your freedom to share and change the works. By contrast,
55+the GNU General Public License is intended to guarantee your freedom to
56+share and change all versions of a program--to make sure it remains free
57+software for all its users. We, the Free Software Foundation, use the
58+GNU General Public License for most of our software; it applies also to
59+any other work released this way by its authors. You can apply it to
60+your programs, too.
61+
62+ When we speak of free software, we are referring to freedom, not
63+price. Our General Public Licenses are designed to make sure that you
64+have the freedom to distribute copies of free software (and charge for
65+them if you wish), that you receive source code or can get it if you
66+want it, that you can change the software or use pieces of it in new
67+free programs, and that you know you can do these things.
68+
69+ To protect your rights, we need to prevent others from denying you
70+these rights or asking you to surrender the rights. Therefore, you have
71+certain responsibilities if you distribute copies of the software, or if
72+you modify it: responsibilities to respect the freedom of others.
73+
74+ For example, if you distribute copies of such a program, whether
75+gratis or for a fee, you must pass on to the recipients the same
76+freedoms that you received. You must make sure that they, too, receive
77+or can get the source code. And you must show them these terms so they
78+know their rights.
79+
80+ Developers that use the GNU GPL protect your rights with two steps:
81+(1) assert copyright on the software, and (2) offer you this License
82+giving you legal permission to copy, distribute and/or modify it.
83+
84+ For the developers' and authors' protection, the GPL clearly explains
85+that there is no warranty for this free software. For both users' and
86+authors' sake, the GPL requires that modified versions be marked as
87+changed, so that their problems will not be attributed erroneously to
88+authors of previous versions.
89+
90+ Some devices are designed to deny users access to install or run
91+modified versions of the software inside them, although the manufacturer
92+can do so. This is fundamentally incompatible with the aim of
93+protecting users' freedom to change the software. The systematic
94+pattern of such abuse occurs in the area of products for individuals to
95+use, which is precisely where it is most unacceptable. Therefore, we
96+have designed this version of the GPL to prohibit the practice for those
97+products. If such problems arise substantially in other domains, we
98+stand ready to extend this provision to those domains in future versions
99+of the GPL, as needed to protect the freedom of users.
100+
101+ Finally, every program is threatened constantly by software patents.
102+States should not allow patents to restrict development and use of
103+software on general-purpose computers, but in those that do, we wish to
104+avoid the special danger that patents applied to a free program could
105+make it effectively proprietary. To prevent this, the GPL assures that
106+patents cannot be used to render the program non-free.
107+
108+ The precise terms and conditions for copying, distribution and
109+modification follow.
110+
111+ TERMS AND CONDITIONS
112+
113+ 0. Definitions.
114+
115+ "This License" refers to version 3 of the GNU General Public License.
116+
117+ "Copyright" also means copyright-like laws that apply to other kinds of
118+works, such as semiconductor masks.
119+
120+ "The Program" refers to any copyrightable work licensed under this
121+License. Each licensee is addressed as "you". "Licensees" and
122+"recipients" may be individuals or organizations.
123+
124+ To "modify" a work means to copy from or adapt all or part of the work
125+in a fashion requiring copyright permission, other than the making of an
126+exact copy. The resulting work is called a "modified version" of the
127+earlier work or a work "based on" the earlier work.
128+
129+ A "covered work" means either the unmodified Program or a work based
130+on the Program.
131+
132+ To "propagate" a work means to do anything with it that, without
133+permission, would make you directly or secondarily liable for
134+infringement under applicable copyright law, except executing it on a
135+computer or modifying a private copy. Propagation includes copying,
136+distribution (with or without modification), making available to the
137+public, and in some countries other activities as well.
138+
139+ To "convey" a work means any kind of propagation that enables other
140+parties to make or receive copies. Mere interaction with a user through
141+a computer network, with no transfer of a copy, is not conveying.
142+
143+ An interactive user interface displays "Appropriate Legal Notices"
144+to the extent that it includes a convenient and prominently visible
145+feature that (1) displays an appropriate copyright notice, and (2)
146+tells the user that there is no warranty for the work (except to the
147+extent that warranties are provided), that licensees may convey the
148+work under this License, and how to view a copy of this License. If
149+the interface presents a list of user commands or options, such as a
150+menu, a prominent item in the list meets this criterion.
151+
152+ 1. Source Code.
153+
154+ The "source code" for a work means the preferred form of the work
155+for making modifications to it. "Object code" means any non-source
156+form of a work.
157+
158+ A "Standard Interface" means an interface that either is an official
159+standard defined by a recognized standards body, or, in the case of
160+interfaces specified for a particular programming language, one that
161+is widely used among developers working in that language.
162+
163+ The "System Libraries" of an executable work include anything, other
164+than the work as a whole, that (a) is included in the normal form of
165+packaging a Major Component, but which is not part of that Major
166+Component, and (b) serves only to enable use of the work with that
167+Major Component, or to implement a Standard Interface for which an
168+implementation is available to the public in source code form. A
169+"Major Component", in this context, means a major essential component
170+(kernel, window system, and so on) of the specific operating system
171+(if any) on which the executable work runs, or a compiler used to
172+produce the work, or an object code interpreter used to run it.
173+
174+ The "Corresponding Source" for a work in object code form means all
175+the source code needed to generate, install, and (for an executable
176+work) run the object code and to modify the work, including scripts to
177+control those activities. However, it does not include the work's
178+System Libraries, or general-purpose tools or generally available free
179+programs which are used unmodified in performing those activities but
180+which are not part of the work. For example, Corresponding Source
181+includes interface definition files associated with source files for
182+the work, and the source code for shared libraries and dynamically
183+linked subprograms that the work is specifically designed to require,
184+such as by intimate data communication or control flow between those
185+subprograms and other parts of the work.
186+
187+ The Corresponding Source need not include anything that users
188+can regenerate automatically from other parts of the Corresponding
189+Source.
190+
191+ The Corresponding Source for a work in source code form is that
192+same work.
193+
194+ 2. Basic Permissions.
195+
196+ All rights granted under this License are granted for the term of
197+copyright on the Program, and are irrevocable provided the stated
198+conditions are met. This License explicitly affirms your unlimited
199+permission to run the unmodified Program. The output from running a
200+covered work is covered by this License only if the output, given its
201+content, constitutes a covered work. This License acknowledges your
202+rights of fair use or other equivalent, as provided by copyright law.
203+
204+ You may make, run and propagate covered works that you do not
205+convey, without conditions so long as your license otherwise remains
206+in force. You may convey covered works to others for the sole purpose
207+of having them make modifications exclusively for you, or provide you
208+with facilities for running those works, provided that you comply with
209+the terms of this License in conveying all material for which you do
210+not control copyright. Those thus making or running the covered works
211+for you must do so exclusively on your behalf, under your direction
212+and control, on terms that prohibit them from making any copies of
213+your copyrighted material outside their relationship with you.
214+
215+ Conveying under any other circumstances is permitted solely under
216+the conditions stated below. Sublicensing is not allowed; section 10
217+makes it unnecessary.
218+
219+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
220+
221+ No covered work shall be deemed part of an effective technological
222+measure under any applicable law fulfilling obligations under article
223+11 of the WIPO copyright treaty adopted on 20 December 1996, or
224+similar laws prohibiting or restricting circumvention of such
225+measures.
226+
227+ When you convey a covered work, you waive any legal power to forbid
228+circumvention of technological measures to the extent such circumvention
229+is effected by exercising rights under this License with respect to
230+the covered work, and you disclaim any intention to limit operation or
231+modification of the work as a means of enforcing, against the work's
232+users, your or third parties' legal rights to forbid circumvention of
233+technological measures.
234+
235+ 4. Conveying Verbatim Copies.
236+
237+ You may convey verbatim copies of the Program's source code as you
238+receive it, in any medium, provided that you conspicuously and
239+appropriately publish on each copy an appropriate copyright notice;
240+keep intact all notices stating that this License and any
241+non-permissive terms added in accord with section 7 apply to the code;
242+keep intact all notices of the absence of any warranty; and give all
243+recipients a copy of this License along with the Program.
244+
245+ You may charge any price or no price for each copy that you convey,
246+and you may offer support or warranty protection for a fee.
247+
248+ 5. Conveying Modified Source Versions.
249+
250+ You may convey a work based on the Program, or the modifications to
251+produce it from the Program, in the form of source code under the
252+terms of section 4, provided that you also meet all of these conditions:
253+
254+ a) The work must carry prominent notices stating that you modified
255+ it, and giving a relevant date.
256+
257+ b) The work must carry prominent notices stating that it is
258+ released under this License and any conditions added under section
259+ 7. This requirement modifies the requirement in section 4 to
260+ "keep intact all notices".
261+
262+ c) You must license the entire work, as a whole, under this
263+ License to anyone who comes into possession of a copy. This
264+ License will therefore apply, along with any applicable section 7
265+ additional terms, to the whole of the work, and all its parts,
266+ regardless of how they are packaged. This License gives no
267+ permission to license the work in any other way, but it does not
268+ invalidate such permission if you have separately received it.
269+
270+ d) If the work has interactive user interfaces, each must display
271+ Appropriate Legal Notices; however, if the Program has interactive
272+ interfaces that do not display Appropriate Legal Notices, your
273+ work need not make them do so.
274+
275+ A compilation of a covered work with other separate and independent
276+works, which are not by their nature extensions of the covered work,
277+and which are not combined with it such as to form a larger program,
278+in or on a volume of a storage or distribution medium, is called an
279+"aggregate" if the compilation and its resulting copyright are not
280+used to limit the access or legal rights of the compilation's users
281+beyond what the individual works permit. Inclusion of a covered work
282+in an aggregate does not cause this License to apply to the other
283+parts of the aggregate.
284+
285+ 6. Conveying Non-Source Forms.
286+
287+ You may convey a covered work in object code form under the terms
288+of sections 4 and 5, provided that you also convey the
289+machine-readable Corresponding Source under the terms of this License,
290+in one of these ways:
291+
292+ a) Convey the object code in, or embodied in, a physical product
293+ (including a physical distribution medium), accompanied by the
294+ Corresponding Source fixed on a durable physical medium
295+ customarily used for software interchange.
296+
297+ b) Convey the object code in, or embodied in, a physical product
298+ (including a physical distribution medium), accompanied by a
299+ written offer, valid for at least three years and valid for as
300+ long as you offer spare parts or customer support for that product
301+ model, to give anyone who possesses the object code either (1) a
302+ copy of the Corresponding Source for all the software in the
303+ product that is covered by this License, on a durable physical
304+ medium customarily used for software interchange, for a price no
305+ more than your reasonable cost of physically performing this
306+ conveying of source, or (2) access to copy the
307+ Corresponding Source from a network server at no charge.
308+
309+ c) Convey individual copies of the object code with a copy of the
310+ written offer to provide the Corresponding Source. This
311+ alternative is allowed only occasionally and noncommercially, and
312+ only if you received the object code with such an offer, in accord
313+ with subsection 6b.
314+
315+ d) Convey the object code by offering access from a designated
316+ place (gratis or for a charge), and offer equivalent access to the
317+ Corresponding Source in the same way through the same place at no
318+ further charge. You need not require recipients to copy the
319+ Corresponding Source along with the object code. If the place to
320+ copy the object code is a network server, the Corresponding Source
321+ may be on a different server (operated by you or a third party)
322+ that supports equivalent copying facilities, provided you maintain
323+ clear directions next to the object code saying where to find the
324+ Corresponding Source. Regardless of what server hosts the
325+ Corresponding Source, you remain obligated to ensure that it is
326+ available for as long as needed to satisfy these requirements.
327+
328+ e) Convey the object code using peer-to-peer transmission, provided
329+ you inform other peers where the object code and Corresponding
330+ Source of the work are being offered to the general public at no
331+ charge under subsection 6d.
332+
333+ A separable portion of the object code, whose source code is excluded
334+from the Corresponding Source as a System Library, need not be
335+included in conveying the object code work.
336+
337+ A "User Product" is either (1) a "consumer product", which means any
338+tangible personal property which is normally used for personal, family,
339+or household purposes, or (2) anything designed or sold for incorporation
340+into a dwelling. In determining whether a product is a consumer product,
341+doubtful cases shall be resolved in favor of coverage. For a particular
342+product received by a particular user, "normally used" refers to a
343+typical or common use of that class of product, regardless of the status
344+of the particular user or of the way in which the particular user
345+actually uses, or expects or is expected to use, the product. A product
346+is a consumer product regardless of whether the product has substantial
347+commercial, industrial or non-consumer uses, unless such uses represent
348+the only significant mode of use of the product.
349+
350+ "Installation Information" for a User Product means any methods,
351+procedures, authorization keys, or other information required to install
352+and execute modified versions of a covered work in that User Product from
353+a modified version of its Corresponding Source. The information must
354+suffice to ensure that the continued functioning of the modified object
355+code is in no case prevented or interfered with solely because
356+modification has been made.
357+
358+ If you convey an object code work under this section in, or with, or
359+specifically for use in, a User Product, and the conveying occurs as
360+part of a transaction in which the right of possession and use of the
361+User Product is transferred to the recipient in perpetuity or for a
362+fixed term (regardless of how the transaction is characterized), the
363+Corresponding Source conveyed under this section must be accompanied
364+by the Installation Information. But this requirement does not apply
365+if neither you nor any third party retains the ability to install
366+modified object code on the User Product (for example, the work has
367+been installed in ROM).
368+
369+ The requirement to provide Installation Information does not include a
370+requirement to continue to provide support service, warranty, or updates
371+for a work that has been modified or installed by the recipient, or for
372+the User Product in which it has been modified or installed. Access to a
373+network may be denied when the modification itself materially and
374+adversely affects the operation of the network or violates the rules and
375+protocols for communication across the network.
376+
377+ Corresponding Source conveyed, and Installation Information provided,
378+in accord with this section must be in a format that is publicly
379+documented (and with an implementation available to the public in
380+source code form), and must require no special password or key for
381+unpacking, reading or copying.
382+
383+ 7. Additional Terms.
384+
385+ "Additional permissions" are terms that supplement the terms of this
386+License by making exceptions from one or more of its conditions.
387+Additional permissions that are applicable to the entire Program shall
388+be treated as though they were included in this License, to the extent
389+that they are valid under applicable law. If additional permissions
390+apply only to part of the Program, that part may be used separately
391+under those permissions, but the entire Program remains governed by
392+this License without regard to the additional permissions.
393+
394+ When you convey a copy of a covered work, you may at your option
395+remove any additional permissions from that copy, or from any part of
396+it. (Additional permissions may be written to require their own
397+removal in certain cases when you modify the work.) You may place
398+additional permissions on material, added by you to a covered work,
399+for which you have or can give appropriate copyright permission.
400+
401+ Notwithstanding any other provision of this License, for material you
402+add to a covered work, you may (if authorized by the copyright holders of
403+that material) supplement the terms of this License with terms:
404+
405+ a) Disclaiming warranty or limiting liability differently from the
406+ terms of sections 15 and 16 of this License; or
407+
408+ b) Requiring preservation of specified reasonable legal notices or
409+ author attributions in that material or in the Appropriate Legal
410+ Notices displayed by works containing it; or
411+
412+ c) Prohibiting misrepresentation of the origin of that material, or
413+ requiring that modified versions of such material be marked in
414+ reasonable ways as different from the original version; or
415+
416+ d) Limiting the use for publicity purposes of names of licensors or
417+ authors of the material; or
418+
419+ e) Declining to grant rights under trademark law for use of some
420+ trade names, trademarks, or service marks; or
421+
422+ f) Requiring indemnification of licensors and authors of that
423+ material by anyone who conveys the material (or modified versions of
424+ it) with contractual assumptions of liability to the recipient, for
425+ any liability that these contractual assumptions directly impose on
426+ those licensors and authors.
427+
428+ All other non-permissive additional terms are considered "further
429+restrictions" within the meaning of section 10. If the Program as you
430+received it, or any part of it, contains a notice stating that it is
431+governed by this License along with a term that is a further
432+restriction, you may remove that term. If a license document contains
433+a further restriction but permits relicensing or conveying under this
434+License, you may add to a covered work material governed by the terms
435+of that license document, provided that the further restriction does
436+not survive such relicensing or conveying.
437+
438+ If you add terms to a covered work in accord with this section, you
439+must place, in the relevant source files, a statement of the
440+additional terms that apply to those files, or a notice indicating
441+where to find the applicable terms.
442+
443+ Additional terms, permissive or non-permissive, may be stated in the
444+form of a separately written license, or stated as exceptions;
445+the above requirements apply either way.
446+
447+ 8. Termination.
448+
449+ You may not propagate or modify a covered work except as expressly
450+provided under this License. Any attempt otherwise to propagate or
451+modify it is void, and will automatically terminate your rights under
452+this License (including any patent licenses granted under the third
453+paragraph of section 11).
454+
455+ However, if you cease all violation of this License, then your
456+license from a particular copyright holder is reinstated (a)
457+provisionally, unless and until the copyright holder explicitly and
458+finally terminates your license, and (b) permanently, if the copyright
459+holder fails to notify you of the violation by some reasonable means
460+prior to 60 days after the cessation.
461+
462+ Moreover, your license from a particular copyright holder is
463+reinstated permanently if the copyright holder notifies you of the
464+violation by some reasonable means, this is the first time you have
465+received notice of violation of this License (for any work) from that
466+copyright holder, and you cure the violation prior to 30 days after
467+your receipt of the notice.
468+
469+ Termination of your rights under this section does not terminate the
470+licenses of parties who have received copies or rights from you under
471+this License. If your rights have been terminated and not permanently
472+reinstated, you do not qualify to receive new licenses for the same
473+material under section 10.
474+
475+ 9. Acceptance Not Required for Having Copies.
476+
477+ You are not required to accept this License in order to receive or
478+run a copy of the Program. Ancillary propagation of a covered work
479+occurring solely as a consequence of using peer-to-peer transmission
480+to receive a copy likewise does not require acceptance. However,
481+nothing other than this License grants you permission to propagate or
482+modify any covered work. These actions infringe copyright if you do
483+not accept this License. Therefore, by modifying or propagating a
484+covered work, you indicate your acceptance of this License to do so.
485+
486+ 10. Automatic Licensing of Downstream Recipients.
487+
488+ Each time you convey a covered work, the recipient automatically
489+receives a license from the original licensors, to run, modify and
490+propagate that work, subject to this License. You are not responsible
491+for enforcing compliance by third parties with this License.
492+
493+ An "entity transaction" is a transaction transferring control of an
494+organization, or substantially all assets of one, or subdividing an
495+organization, or merging organizations. If propagation of a covered
496+work results from an entity transaction, each party to that
497+transaction who receives a copy of the work also receives whatever
498+licenses to the work the party's predecessor in interest had or could
499+give under the previous paragraph, plus a right to possession of the
500+Corresponding Source of the work from the predecessor in interest, if
501+the predecessor has it or can get it with reasonable efforts.
502+
503+ You may not impose any further restrictions on the exercise of the
504+rights granted or affirmed under this License. For example, you may
505+not impose a license fee, royalty, or other charge for exercise of
506+rights granted under this License, and you may not initiate litigation
507+(including a cross-claim or counterclaim in a lawsuit) alleging that
508+any patent claim is infringed by making, using, selling, offering for
509+sale, or importing the Program or any portion of it.
510+
511+ 11. Patents.
512+
513+ A "contributor" is a copyright holder who authorizes use under this
514+License of the Program or a work on which the Program is based. The
515+work thus licensed is called the contributor's "contributor version".
516+
517+ A contributor's "essential patent claims" are all patent claims
518+owned or controlled by the contributor, whether already acquired or
519+hereafter acquired, that would be infringed by some manner, permitted
520+by this License, of making, using, or selling its contributor version,
521+but do not include claims that would be infringed only as a
522+consequence of further modification of the contributor version. For
523+purposes of this definition, "control" includes the right to grant
524+patent sublicenses in a manner consistent with the requirements of
525+this License.
526+
527+ Each contributor grants you a non-exclusive, worldwide, royalty-free
528+patent license under the contributor's essential patent claims, to
529+make, use, sell, offer for sale, import and otherwise run, modify and
530+propagate the contents of its contributor version.
531+
532+ In the following three paragraphs, a "patent license" is any express
533+agreement or commitment, however denominated, not to enforce a patent
534+(such as an express permission to practice a patent or covenant not to
535+sue for patent infringement). To "grant" such a patent license to a
536+party means to make such an agreement or commitment not to enforce a
537+patent against the party.
538+
539+ If you convey a covered work, knowingly relying on a patent license,
540+and the Corresponding Source of the work is not available for anyone
541+to copy, free of charge and under the terms of this License, through a
542+publicly available network server or other readily accessible means,
543+then you must either (1) cause the Corresponding Source to be so
544+available, or (2) arrange to deprive yourself of the benefit of the
545+patent license for this particular work, or (3) arrange, in a manner
546+consistent with the requirements of this License, to extend the patent
547+license to downstream recipients. "Knowingly relying" means you have
548+actual knowledge that, but for the patent license, your conveying the
549+covered work in a country, or your recipient's use of the covered work
550+in a country, would infringe one or more identifiable patents in that
551+country that you have reason to believe are valid.
552+
553+ If, pursuant to or in connection with a single transaction or
554+arrangement, you convey, or propagate by procuring conveyance of, a
555+covered work, and grant a patent license to some of the parties
556+receiving the covered work authorizing them to use, propagate, modify
557+or convey a specific copy of the covered work, then the patent license
558+you grant is automatically extended to all recipients of the covered
559+work and works based on it.
560+
561+ A patent license is "discriminatory" if it does not include within
562+the scope of its coverage, prohibits the exercise of, or is
563+conditioned on the non-exercise of one or more of the rights that are
564+specifically granted under this License. You may not convey a covered
565+work if you are a party to an arrangement with a third party that is
566+in the business of distributing software, under which you make payment
567+to the third party based on the extent of your activity of conveying
568+the work, and under which the third party grants, to any of the
569+parties who would receive the covered work from you, a discriminatory
570+patent license (a) in connection with copies of the covered work
571+conveyed by you (or copies made from those copies), or (b) primarily
572+for and in connection with specific products or compilations that
573+contain the covered work, unless you entered into that arrangement,
574+or that patent license was granted, prior to 28 March 2007.
575+
576+ Nothing in this License shall be construed as excluding or limiting
577+any implied license or other defenses to infringement that may
578+otherwise be available to you under applicable patent law.
579+
580+ 12. No Surrender of Others' Freedom.
581+
582+ If conditions are imposed on you (whether by court order, agreement or
583+otherwise) that contradict the conditions of this License, they do not
584+excuse you from the conditions of this License. If you cannot convey a
585+covered work so as to satisfy simultaneously your obligations under this
586+License and any other pertinent obligations, then as a consequence you may
587+not convey it at all. For example, if you agree to terms that obligate you
588+to collect a royalty for further conveying from those to whom you convey
589+the Program, the only way you could satisfy both those terms and this
590+License would be to refrain entirely from conveying the Program.
591+
592+ 13. Use with the GNU Affero General Public License.
593+
594+ Notwithstanding any other provision of this License, you have
595+permission to link or combine any covered work with a work licensed
596+under version 3 of the GNU Affero General Public License into a single
597+combined work, and to convey the resulting work. The terms of this
598+License will continue to apply to the part which is the covered work,
599+but the special requirements of the GNU Affero General Public License,
600+section 13, concerning interaction through a network will apply to the
601+combination as such.
602+
603+ 14. Revised Versions of this License.
604+
605+ The Free Software Foundation may publish revised and/or new versions of
606+the GNU General Public License from time to time. Such new versions will
607+be similar in spirit to the present version, but may differ in detail to
608+address new problems or concerns.
609+
610+ Each version is given a distinguishing version number. If the
611+Program specifies that a certain numbered version of the GNU General
612+Public License "or any later version" applies to it, you have the
613+option of following the terms and conditions either of that numbered
614+version or of any later version published by the Free Software
615+Foundation. If the Program does not specify a version number of the
616+GNU General Public License, you may choose any version ever published
617+by the Free Software Foundation.
618+
619+ If the Program specifies that a proxy can decide which future
620+versions of the GNU General Public License can be used, that proxy's
621+public statement of acceptance of a version permanently authorizes you
622+to choose that version for the Program.
623+
624+ Later license versions may give you additional or different
625+permissions. However, no additional obligations are imposed on any
626+author or copyright holder as a result of your choosing to follow a
627+later version.
628+
629+ 15. Disclaimer of Warranty.
630+
631+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
632+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
633+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
634+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
635+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
636+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
637+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
638+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
639+
640+ 16. Limitation of Liability.
641+
642+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
643+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
644+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
645+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
646+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
647+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
648+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
649+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
650+SUCH DAMAGES.
651+
652+ 17. Interpretation of Sections 15 and 16.
653+
654+ If the disclaimer of warranty and limitation of liability provided
655+above cannot be given local legal effect according to their terms,
656+reviewing courts shall apply local law that most closely approximates
657+an absolute waiver of all civil liability in connection with the
658+Program, unless a warranty or assumption of liability accompanies a
659+copy of the Program in return for a fee.
660+
661+ END OF TERMS AND CONDITIONS
662+
663+ How to Apply These Terms to Your New Programs
664+
665+ If you develop a new program, and you want it to be of the greatest
666+possible use to the public, the best way to achieve this is to make it
667+free software which everyone can redistribute and change under these terms.
668+
669+ To do so, attach the following notices to the program. It is safest
670+to attach them to the start of each source file to most effectively
671+state the exclusion of warranty; and each file should have at least
672+the "copyright" line and a pointer to where the full notice is found.
673+
674+ <one line to give the program's name and a brief idea of what it does.>
675+ Copyright (C) <year> <name of author>
676+
677+ This program is free software: you can redistribute it and/or modify
678+ it under the terms of the GNU General Public License as published by
679+ the Free Software Foundation, either version 3 of the License, or
680+ (at your option) any later version.
681+
682+ This program is distributed in the hope that it will be useful,
683+ but WITHOUT ANY WARRANTY; without even the implied warranty of
684+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
685+ GNU General Public License for more details.
686+
687+ You should have received a copy of the GNU General Public License
688+ along with this program. If not, see <http://www.gnu.org/licenses/>.
689+
690+Also add information on how to contact you by electronic and paper mail.
691+
692+ If the program does terminal interaction, make it output a short
693+notice like this when it starts in an interactive mode:
694+
695+ <program> Copyright (C) <year> <name of author>
696+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
697+ This is free software, and you are welcome to redistribute it
698+ under certain conditions; type `show c' for details.
699+
700+The hypothetical commands `show w' and `show c' should show the appropriate
701+parts of the General Public License. Of course, your program's commands
702+might be different; for a GUI interface, you would use an "about box".
703+
704+ You should also get your employer (if you work as a programmer) or school,
705+if any, to sign a "copyright disclaimer" for the program, if necessary.
706+For more information on this, and how to apply and follow the GNU GPL, see
707+<http://www.gnu.org/licenses/>.
708+
709+ The GNU General Public License does not permit incorporating your program
710+into proprietary programs. If your program is a subroutine library, you
711+may consider it more useful to permit linking proprietary applications with
712+the library. If this is what you want to do, use the GNU Lesser General
713+Public License instead of this License. But first, please read
714+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
715diff --git a/Makefile b/Makefile
716index 34b2762..f81e542 100644
717--- a/Makefile
718+++ b/Makefile
719@@ -1,10 +1,14 @@
720-lint:
721+blacken:
722+ @echo "Normalising python layout with black."
723+ @tox -e black
724+
725+lint: blacken
726 @echo "Running flake8"
727 @tox -e lint
728
729 # We actually use the build directory created by charmcraft,
730 # but the .charm file makes a much more convenient sentinel.
731-unittest: discourse-charm.charm
732+unittest: discourse.charm
733 @tox -e unit
734
735 test: lint unittest
736@@ -13,7 +17,7 @@ clean:
737 @echo "Cleaning files"
738 @git clean -fXd
739
740-discourse-charm.charm: src/*.py requirements.txt
741+discourse.charm: src/*.py requirements.txt
742 charmcraft build
743
744-.PHONY: lint test unittest clean
745+.PHONY: blacken lint test unittest clean
746diff --git a/hooks/install b/hooks/install
747deleted file mode 120000
748index 25b1f68..0000000
749--- a/hooks/install
750+++ /dev/null
751@@ -1 +0,0 @@
752-../src/charm.py
753\ No newline at end of file
754diff --git a/lib/ops b/lib/ops
755deleted file mode 120000
756index c36dab1..0000000
757--- a/lib/ops
758+++ /dev/null
759@@ -1 +0,0 @@
760-../mod/operator/ops/
761\ No newline at end of file
762diff --git a/metadata.yaml b/metadata.yaml
763index b7308d9..e5aba8d 100644
764--- a/metadata.yaml
765+++ b/metadata.yaml
766@@ -1,4 +1,4 @@
767-name: "discourse-charm"
768+name: "discourse"
769 summary: "Discourse for juju-k8s operator framework"
770 description: "Discourse bundled for juju-k8s deployment"
771 maintainers:
772diff --git a/mod/operator b/mod/operator
773deleted file mode 160000
774index cfde948..0000000
775--- a/mod/operator
776+++ /dev/null
777@@ -1 +0,0 @@
778-Subproject commit cfde948d8997b7e7ae0046a9328b7bc10f7dccf0
779diff --git a/pyproject.toml b/pyproject.toml
780new file mode 100644
781index 0000000..d2f23b9
782--- /dev/null
783+++ b/pyproject.toml
784@@ -0,0 +1,3 @@
785+[tool.black]
786+skip-string-normalization = true
787+line-length = 120
788diff --git a/requirements.txt b/requirements.txt
789index 65431fc..2d81d3b 100644
790--- a/requirements.txt
791+++ b/requirements.txt
792@@ -1,4 +1 @@
793-mock
794-pytest
795-pytest-cov
796-pyyaml
797+ops
798diff --git a/src/charm.py b/src/charm.py
799index 55474bd..5e481db 100755
800--- a/src/charm.py
801+++ b/src/charm.py
802@@ -1,14 +1,12 @@
803 #!/usr/bin/env python3
804+# Copyright 2020 Canonical Ltd.
805+# See LICENSE file for licensing details.
806
807 from ops.charm import CharmBase
808 from ops.main import main
809 from ops.framework import StoredState
810
811-from ops.model import (
812- MaintenanceStatus,
813- BlockedStatus,
814- ActiveStatus
815-)
816+from ops.model import MaintenanceStatus, BlockedStatus, ActiveStatus
817
818
819 def create_discourse_pod_config(config):
820@@ -40,20 +38,10 @@ def create_ingress_config(app_name, config):
821 "rules": [
822 {
823 "host": config['external_hostname'],
824- "http": {
825- "paths": [
826- {
827- "path": "/",
828- "backend": {
829- "serviceName": app_name,
830- "servicePort": 3000
831- }
832- }
833- ]
834- }
835+ "http": {"paths": [{"path": "/", "backend": {"serviceName": app_name, "servicePort": 3000}}]},
836 }
837 ]
838- }
839+ },
840 }
841 return ingressResource
842
843@@ -61,29 +49,29 @@ def create_ingress_config(app_name, config):
844 def get_pod_spec(app_name, config):
845 pod_spec = {
846 "version": 3,
847- "containers": [{
848- "name": app_name,
849- "imageDetails": {"imagePath": config['discourse_image']},
850- "imagePullPolicy": "IfNotPresent",
851- "ports": [{
852- "containerPort": 3000,
853- "protocol": "TCP",
854- }],
855- "envConfig": create_discourse_pod_config(config),
856- "kubernetes": {
857- "readinessProbe": {
858- "httpGet": {
859- "path": "/srv/status",
860- "port": 3000,
861+ "containers": [
862+ {
863+ "name": app_name,
864+ "imageDetails": {"imagePath": config['discourse_image']},
865+ "imagePullPolicy": "IfNotPresent",
866+ "ports": [
867+ {
868+ "containerPort": 3000,
869+ "protocol": "TCP",
870 }
871- }
872- },
873- }],
874- "kubernetesResources": {
875- "ingressResources": [
876- create_ingress_config(app_name, config)
877- ]
878- }
879+ ],
880+ "envConfig": create_discourse_pod_config(config),
881+ "kubernetes": {
882+ "readinessProbe": {
883+ "httpGet": {
884+ "path": "/srv/status",
885+ "port": 3000,
886+ }
887+ }
888+ },
889+ }
890+ ],
891+ "kubernetesResources": {"ingressResources": [create_ingress_config(app_name, config)]},
892 }
893 # This handles when we are trying to get an image from a private
894 # registry.
895@@ -107,9 +95,18 @@ def check_for_config_problems(config):
896 def check_for_missing_config_fields(config):
897 missing_fields = []
898
899- needed_fields = ['db_user', 'db_host', 'db_name', 'smtp_address', 'redis_host',
900- 'cors_origin', 'developer_emails', 'smtp_domain',
901- 'discourse_image', 'external_hostname']
902+ needed_fields = [
903+ 'db_user',
904+ 'db_host',
905+ 'db_name',
906+ 'smtp_address',
907+ 'redis_host',
908+ 'cors_origin',
909+ 'developer_emails',
910+ 'smtp_domain',
911+ 'discourse_image',
912+ 'external_hostname',
913+ ]
914 for key in needed_fields:
915 if (config.get(key) is None) or (len(config[key]) == 0):
916 missing_fields.append(key)
917@@ -163,11 +160,10 @@ class DiscourseCharm(CharmBase):
918 self.state.is_started = True
919 self.model.unit.status = ActiveStatus()
920
921- def on_new_client(self, event): # pragma: no cover
922+ def on_new_client(self, event):
923 if not self.state.is_started:
924 return event.defer()
925- event.client.serve(hosts=[event.client.ingress_address],
926- port=self.model.config['http_port'])
927+ event.client.serve(hosts=[event.client.ingress_address], port=self.model.config['http_port'])
928
929
930 if __name__ == '__main__': # pragma: no cover
931diff --git a/tests/unit/fixtures/config_valid_1.yaml b/tests/unit/fixtures/config_valid_1.yaml
932index 1a9af02..970ac49 100644
933--- a/tests/unit/fixtures/config_valid_1.yaml
934+++ b/tests/unit/fixtures/config_valid_1.yaml
935@@ -45,20 +45,20 @@ spec:
936 httpGet:
937 path: /srv/status
938 port: 3000
939- name: discourse-charm
940+ name: discourse
941 ports:
942 - containerPort: 3000
943 protocol: TCP
944 kubernetesResources:
945 ingressResources:
946- - name: discourse-charm-ingress
947+ - name: discourse-ingress
948 spec:
949 rules:
950 - host: discourse.local
951 http:
952 paths:
953 - backend:
954- serviceName: discourse-charm
955+ serviceName: discourse
956 servicePort: 3000
957 path: /
958 version: 3
959diff --git a/tests/unit/fixtures/config_valid_2.yaml b/tests/unit/fixtures/config_valid_2.yaml
960index 4008917..ec7c818 100644
961--- a/tests/unit/fixtures/config_valid_2.yaml
962+++ b/tests/unit/fixtures/config_valid_2.yaml
963@@ -45,20 +45,20 @@ spec:
964 httpGet:
965 path: /srv/status
966 port: 3000
967- name: discourse-charm
968+ name: discourse
969 ports:
970 - containerPort: 3000
971 protocol: TCP
972 kubernetesResources:
973 ingressResources:
974- - name: discourse-charm-ingress
975+ - name: discourse-ingress
976 spec:
977 rules:
978 - host: discourse.example.com
979 http:
980 paths:
981 - backend:
982- serviceName: discourse-charm
983+ serviceName: discourse
984 servicePort: 3000
985 path: /
986 version: 3
987diff --git a/tests/unit/fixtures/config_valid_3.yaml b/tests/unit/fixtures/config_valid_3.yaml
988index fbc58fd..46bd3cf 100644
989--- a/tests/unit/fixtures/config_valid_3.yaml
990+++ b/tests/unit/fixtures/config_valid_3.yaml
991@@ -47,20 +47,20 @@ spec:
992 httpGet:
993 path: /srv/status
994 port: 3000
995- name: discourse-charm
996+ name: discourse
997 ports:
998 - containerPort: 3000
999 protocol: TCP
1000 kubernetesResources:
1001 ingressResources:
1002- - name: discourse-charm-ingress
1003+ - name: discourse-ingress
1004 spec:
1005 rules:
1006 - host: discourse.local
1007 http:
1008 paths:
1009 - backend:
1010- serviceName: discourse-charm
1011+ serviceName: discourse
1012 servicePort: 3000
1013 path: /
1014 version: 3
1015diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py
1016index e6e3c91..4fd7324 100644
1017--- a/tests/unit/test_charm.py
1018+++ b/tests/unit/test_charm.py
1019@@ -1,7 +1,7 @@
1020 #!/usr/bin/env python3
1021
1022 # Copyright 2020 Canonical Ltd.
1023-# Licensed under the GPLv3, see LICENCE file for details.
1024+# See LICENSE file for licensing details.
1025
1026 import os
1027 import glob
1028@@ -10,10 +10,7 @@ import yaml
1029 import mock
1030 from pprint import pprint
1031
1032-from charm import (
1033- DiscourseCharm,
1034- BlockedStatus
1035-)
1036+from charm import DiscourseCharm, BlockedStatus
1037
1038 from ops import testing
1039
1040@@ -66,9 +63,11 @@ class TestDiscourseK8sCharmHooksDisabled(unittest.TestCase):
1041 self.harness.update_config(self.configs[config_key]['config'])
1042 valid_config = self.harness.charm.check_config_is_valid(self.configs[config_key]['config'])
1043 self.assertEqual(valid_config, False, 'Bad Config {} is recognized.'.format(config_key))
1044- self.assertEqual(self.harness.charm.model.unit.status,
1045- BlockedStatus(self.configs[config_key]['expected_error_status']),
1046- 'Invalid config {} does not produce correct status'.format(config_key))
1047+ self.assertEqual(
1048+ self.harness.charm.model.unit.status,
1049+ BlockedStatus(self.configs[config_key]['expected_error_status']),
1050+ 'Invalid config {} does not produce correct status'.format(config_key),
1051+ )
1052
1053 def test_charm_creates_valid_ingress_config(self):
1054 """Test that a valid config creates a valid ingress spec."""
1055@@ -76,9 +75,11 @@ class TestDiscourseK8sCharmHooksDisabled(unittest.TestCase):
1056 if config_key.startswith('config_valid_'):
1057 self.harness.update_config(self.configs[config_key]['config'])
1058 spec = self.harness.charm.get_pod_spec(self.configs[config_key]['config'])
1059- self.assertEqual(spec['kubernetesResources']['ingressResources'],
1060- self.configs[config_key]['spec']['kubernetesResources']['ingressResources'],
1061- 'Valid config {} does not produce expected ingress config.'.format(config_key))
1062+ self.assertEqual(
1063+ spec['kubernetesResources']['ingressResources'],
1064+ self.configs[config_key]['spec']['kubernetesResources']['ingressResources'],
1065+ 'Valid config {} does not produce expected ingress config.'.format(config_key),
1066+ )
1067
1068 def test_valid_pod_spec(self):
1069 """A valid config results in a valid pod spec."""
1070@@ -86,16 +87,22 @@ class TestDiscourseK8sCharmHooksDisabled(unittest.TestCase):
1071 if config_key.startswith('config_valid_'):
1072 self.harness.update_config(self.configs[config_key]['config'])
1073 spec = self.harness.charm.get_pod_spec(self.configs[config_key]['config'])
1074- self.assertEqual(spec, self.configs[config_key]['spec'],
1075- 'Valid config {} does not produce expected pod spec.'.format(config_key))
1076+ self.assertEqual(
1077+ spec,
1078+ self.configs[config_key]['spec'],
1079+ 'Valid config {} does not produce expected pod spec.'.format(config_key),
1080+ )
1081
1082 def test_charm_config_process(self):
1083 action_event = mock.Mock()
1084 self.harness.update_config(self.configs['config_valid_1']['config'])
1085 self.harness.charm.configure_pod(action_event)
1086 (configured_spec, k8s_resources) = self.harness.get_pod_spec()
1087- self.assertEqual(configured_spec, self.configs['config_valid_1']['spec'],
1088- 'Valid config does not cause charm to set expected pod spec.')
1089+ self.assertEqual(
1090+ configured_spec,
1091+ self.configs['config_valid_1']['spec'],
1092+ 'Valid config does not cause charm to set expected pod spec.',
1093+ )
1094
1095 def test_charm_config_process_invalid_config(self):
1096 action_event = mock.Mock()
1097diff --git a/tox.ini b/tox.ini
1098index b4c09fb..d48b030 100644
1099--- a/tox.ini
1100+++ b/tox.ini
1101@@ -5,13 +5,12 @@ skip_missing_interpreters = True
1102
1103 [testenv]
1104 basepython = python3
1105-whitelist_externals = /usr/bin/pytest-3
1106 setenv =
1107 PYTHONPATH = {toxinidir}/build/lib:{toxinidir}/build/venv
1108
1109 [testenv:unit]
1110 commands =
1111- pytest-3 --ignore mod --ignore {toxinidir}/tests/functional \
1112+ pytest --ignore mod --ignore {toxinidir}/tests/functional \
1113 {posargs:-v --cov=src --cov-report=term-missing --cov-branch}
1114 deps = -r{toxinidir}/tests/unit/requirements.txt
1115 -r{toxinidir}/requirements.txt
1116@@ -19,6 +18,10 @@ setenv =
1117 PYTHONPATH={toxinidir}/src:{toxinidir}/build/lib:{toxinidir}/build/venv
1118 TZ=UTC
1119
1120+[testenv:black]
1121+commands = black src/ tests/
1122+deps = black
1123+
1124 [testenv:lint]
1125 commands = flake8 src/ tests/
1126 deps =

Subscribers

People subscribed via source and target branches

to all changes: