[
  {
    "path": ".gitignore",
    "content": "*.pyc\n**/__pycache__\ndist/\nbuild/\n*.egg-info/\n.pytest_cache/\n.tox/\n.coverage\n.vscode\n\nvenv/\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "README.md",
    "content": "# O Must Gather (omg) v2 (WORK IN PROGRESS)\n\nWith the previous (v1) implementation of omg, there were some major limitations. A major restructuring is being done to implement some advance features that are necessary, for example:\n\n- **Multi directory support**:  Often times a single must-gather is not enough to capture all the components that are being investigated hence multiple must-gathers (or combination of must-gathes and oc-adm-inspect) are collected. omg needs to be able to look at them at once (using v1 omg we have to switch to these directories individually, which is very inconvenient).\n\n- **Dynamic CRDs**: The CRDs in OpenShift are huge in number and growing. In the current implementation of omg, every CRD needs to be \"handled\" manually for omg to recoginze it. A [resource map](https://github.com/kxr/o-must-gather/blob/172f84afc2b81ab523edf78eb6d4a0e64d34cd32/omg/common/resource_map.py#L62-L625) to handle each CRD is hard to scale and fails to pick any new/undefined CRDs. In the newer implementation, CRDs will be automatically detected and recognized. This idea was orignally pitched by Robert Bost [here](https://github.com/kxr/o-must-gather/issues/34).\n\n- **API Groups**: Handling API Groups for each CRD is important. For example to differentiate between `oc get config.operator` and `oc get config.imageregistry`.\n\n- **Components Output**: Provide an easy way to see outputs of other components like elasticsearch and ceph when component specific must-gathers are collected (ODF, Logging, CNV, etc.)\n\n- **High Level Summary**: A high level summary of a must-gather would be very useful. For exmaple `omg show summary` and `omg show issues`. \n\n- **Console Logging**: A proper console logging library [loguru](https://github.com/Delgan/loguru) is being used that supports standard/debug output and can separate standard and error outputs.\n\n"
  },
  {
    "path": "omg/__init__.py",
    "content": "version_info = (2, 0, 0)\nversion = '.'.join(str(c) for c in version_info)\n"
  },
  {
    "path": "omg/cli.py",
    "content": "import click\nimport os\nimport subprocess\n\nfrom omg import version\nfrom omg.config import logging, config\nfrom omg.use import use\nfrom omg.project import project, projects\nfrom omg.project.complete import complete_projects\nfrom omg.get import get\nfrom omg.get.complete import complete_get\nfrom omg.log.complete import complete_pods, complete_containers\nfrom omg.log import log\nfrom omg.whoami import whoami\nfrom omg.components.ceph import ceph\nfrom omg.components.etcdctl import etcdctl\nfrom omg.machine_config.compare import mc_compare\nfrom omg.machine_config.extract import mc_extract\n\n\n# Common Options used by multiple subcommands\no_filtered_path = click.option(\n    \"-P\", \"--path\", type=int, default=0)\n\no_log_level = click.option(\n    \"-l\", \"--loglevel\", type=click.Choice([\"normal\", \"info\", \"debug\", \"trace\"]))\n\no_namespace = click.option(\n    \"--namespace\", \"-n\", required=False, shell_complete=complete_projects)\n\no_all_namespaces = click.option(\n    \"--all-namespaces\", \"-A\", required=False, is_flag=True)\n\n\n# Main click group\n@click.group()\n@o_log_level\n@o_filtered_path\n@o_namespace\n@o_all_namespaces\ndef cli(loglevel, path, namespace, all_namespaces):\n    logging.setup_logging(loglevel)\n    if path:\n        config.filtered_path = path\n    if namespace:\n        config.namespace = namespace\n    if all_namespaces:\n        config.all_namespaces = all_namespaces\n\n\n# omg *use*\n@cli.command(\"use\")\n@click.argument(\"mg_paths\", nargs=-1, required=False, type=click.Path(\n                    exists=True, file_okay=False, resolve_path=True, allow_dash=False))\n@click.option(\"--cwd\", is_flag=True)\n@o_log_level\n@o_filtered_path\ndef use_cmd(mg_paths, cwd, loglevel, path):\n    \"\"\"\n    Select one or more must-gather(s) to use\n    \"\"\"\n    if loglevel:\n        logging.setup_logging(loglevel)\n    if path:\n        config.filtered_path = path\n    use.cmd(mg_paths, cwd)\n\n\n# omg *project*\n@cli.command(\"project\")\n@click.argument(\"name\", required=False,\n                shell_complete=complete_projects)\n@o_log_level\n@o_filtered_path\ndef project_cmd(name, loglevel, path):\n    \"\"\"\n    Switch to another project\n    \"\"\"\n    if loglevel:\n        logging.setup_logging(loglevel)\n    if path:\n        config.filtered_path = path\n    project.cmd(name)\n\n\n# omg *projects*\n@cli.command(\"projects\")\n@o_log_level\n@o_filtered_path\ndef projects_cmd(path, loglevel):\n    \"\"\"\n    Display existing projects\n    \"\"\"\n    if loglevel:\n        logging.setup_logging(loglevel)\n    if path:\n        config.filtered_path = path\n    projects.cmd()\n\n\n# omg *get*\n@cli.command(\"get\")\n@click.argument(\"objects\", nargs=-1, shell_complete=complete_get)\n@click.option(\"--output\", \"-o\", type=click.Choice([\"yaml\", \"json\", \"wide\", \"name\"]))\n@click.option(\"--show-labels\", is_flag=True, type=bool)\n@o_log_level\n@o_namespace\n@o_all_namespaces\n@o_filtered_path\ndef get_cmd(objects, output, show_labels, loglevel, namespace, all_namespaces, path):\n    \"\"\"\n    Display one or many resources\n    \"\"\"\n    if loglevel:\n        logging.setup_logging(loglevel)\n    if path:\n        config.filtered_path = path\n    if namespace:\n        config.namespace = namespace\n    if all_namespaces:\n        config.all_namespaces = all_namespaces\n    get.cmd(objects, output, show_labels)\n\n\n# omg *log*\n@cli.command(\"logs\")\n@click.argument(\"resource\", shell_complete=complete_pods)\n@click.option(\"--container\", \"-c\", shell_complete=complete_containers)\n@click.option(\"--previous\", \"-p\", is_flag=True)\n@o_log_level\n@o_filtered_path\n@o_namespace\ndef logs_cmd(resource, container, previous, namespace, loglevel, path):\n    \"\"\"\n    Print the logs for a container in a pod\n    \"\"\"\n    if loglevel:\n        logging.setup_logging(loglevel)\n    if path:\n        config.filtered_path = path\n    if namespace:\n        config.namespace = namespace\n    log.cmd(resource, container, previous)\n\n\n# omg *whoami*\n@cli.command(\"whoami\")\ndef whoami_cmd():\n    \"\"\"\n    Tell you who you are\n    \"\"\"\n    whoami.cmd()\n\n\n# omg *version*\n@cli.command(\"version\")\ndef version_cmd():\n    \"\"\"\n    Prints the version of o-must-gather\n    \"\"\"\n    print()\n    print(\"omg version \" + str(version) + \" (https://github.com/kxr/o-must-gather)\")\n    print()\n\n\n@cli.command(\"completion\")\n@click.argument(\"shell\", nargs=1, type=click.Choice([\"bash\", \"zsh\", \"fish\"]))\ndef completion(shell):\n    \"\"\"\n    Output shell completion code for the specified shell (bash or zsh)\n    \"\"\"\n    newenv = os.environ.copy()\n    newenv[\"_OMG_COMPLETE\"] = \"{}_source\".format(shell)\n    subprocess.run(\"omg\", env=newenv)\n\n\n# omg *ceph*\n@cli.command(\"ceph\", context_settings={\"ignore_unknown_options\": True})\n@click.argument(\"ceph_args\", nargs=-1)\n@click.option(\"--output\", \"--format\", \"-o\", type=click.Choice([\"json\", \"json-pretty\"]))\n@o_log_level\n@o_filtered_path\ndef ceph_cmd(ceph_args, output, loglevel, path):\n    if loglevel:\n        logging.setup_logging(loglevel)\n    if path:\n        config.filtered_path = path\n    ceph.cmd(ceph_args, output, com=\"ceph\")\n\n\n# omg *rados*\n@cli.command(\"rados\", context_settings={\"ignore_unknown_options\": True})\n@click.argument(\"ceph_args\", nargs=-1)\n@o_log_level\n@o_filtered_path\ndef rados_cmd(ceph_args, loglevel, path):\n    if loglevel:\n        logging.setup_logging(loglevel)\n    if path:\n        config.filtered_path = path\n    ceph.cmd(ceph_args, None, com=\"rados\")\n\n\n# omg *rbd*\n@cli.command(\"rbd\", context_settings={\"ignore_unknown_options\": True})\n@click.argument(\"ceph_args\", nargs=-1)\n@o_log_level\n@o_filtered_path\ndef rbd_cmd(ceph_args, loglevel, path):\n    if loglevel:\n        logging.setup_logging(loglevel)\n    if path:\n        config.filtered_path = path\n    ceph.cmd(ceph_args, None, com=\"rbd\")\n\n\n# omg *etcdctl*\n@cli.command(\"etcdctl\", context_settings={\"ignore_unknown_options\": True})\n@click.option(\"--output\", \"--write-out\", \"-o\", type=click.Choice([\"json\", \"table\", \"simple\"]))\n@click.argument(\"etcdctl_args\", nargs=-1)\n@o_log_level\n@o_filtered_path\ndef etcdctl_cmd(etcdctl_args, output, loglevel, path):\n    if loglevel:\n        logging.setup_logging(loglevel)\n    if path:\n        config.filtered_path = path\n    etcdctl.cmd(etcdctl_args, output)\n\n\n# Click group for machine-config\n@cli.group(\"machine-config\")\ndef mc_cmd():\n    \"\"\"\n    Explore Machine Configs\n    \"\"\"\n    pass\n\n\n# omg machine-config *extract*\n@mc_cmd.command(\"extract\")\n@click.argument(\"mc_names\", nargs=-1)\n@o_log_level\n@o_filtered_path\ndef extract_mc_cmd(mc_names, loglevel, path):\n    \"\"\"\n    Extract Machine Configs\n    \"\"\"\n    if loglevel:\n        logging.setup_logging(loglevel)\n    if path:\n        config.filtered_path = path\n    mc_extract(mc_names)\n\n\n# omg machine-config *compare*\n@mc_cmd.command(\"compare\")\n@click.argument(\"mc_names\", nargs=2)\n@click.option(\"--show-contents\", is_flag=True)\n@o_log_level\n@o_filtered_path\ndef compare_mc_cmd(mc_names, show_contents, loglevel, path):\n    \"\"\"\n    Compare Machine Configs\n    \"\"\"\n    if loglevel:\n        logging.setup_logging(loglevel)\n    if path:\n        config.filtered_path = path\n    mc_compare(mc_names, show_contents)\n"
  },
  {
    "path": "omg/completion/__init__.py",
    "content": ""
  },
  {
    "path": "omg/components/__init__.py",
    "content": ""
  },
  {
    "path": "omg/components/ceph/__init__.py",
    "content": ""
  },
  {
    "path": "omg/components/ceph/ceph.py",
    "content": "import os\nfrom loguru import logger as lg\n\nfrom omg.config import config\n\n\ndef cmd(ceph_args, output, com):\n    cfg = config.get()\n    mg_paths = cfg[\"paths\"]\n\n    if output in [\"json\", \"json-pretty\"]:\n        commands_dir = \"must_gather_commands_json_output\"\n        json_add = \"_--format_json-pretty\"\n    else:\n        commands_dir = \"must_gather_commands\"\n        json_add = \"\"\n\n    file_name = \"{}_{}{}\".format(com, \"_\".join(ceph_args), json_add)\n    if file_name.startswith(\"ceph_config_show_\"):\n        file_name = file_name.replace(\"ceph_config_show_\", \"config_\")\n\n    ceph_file = os.path.join(\"ceph\", commands_dir, file_name)\n\n    lg.debug(\"ceph_file: {}\".format(ceph_file))\n\n    ceph_cmd_paths = {}\n    i = 1\n    for p in mg_paths:\n        ceph_cmd_path = os.path.join(p, ceph_file)\n        if os.path.isfile(ceph_cmd_path):\n            lg.info(\"Command output file found: {}\".format(ceph_cmd_path))\n            ceph_cmd_paths[i] = ceph_cmd_path\n        i += 1\n\n    if ceph_cmd_paths:\n        for i, cp in ceph_cmd_paths.items():\n            with open(cp, \"r\") as lf:\n                print(lf.read())\n            if len(mg_paths) > 1:\n                lg.opt(colors=True).success(\"^^^<e>[{}]</>^^^\\n\".format(i))\n    else:\n        suggestions = {}\n        i = 1\n        for p in mg_paths:\n            try:\n                files = os.listdir(os.path.join(p, \"ceph\", \"must_gather_commands\"))\n                file_match = \"{}_{}\".format(com, \"_\".join(ceph_args))\n                sugg = []\n                sugg.extend([\n                    \"omg \" + f.replace(\"_\", \" \")\n                    for f in files if f.startswith(file_match)])\n                sugg.extend([\n                    \"omg ceph config show {}\".format(f.replace(\"config_\", \"\"))\n                    for f in files if f.startswith(\"config_\")\n                ])\n                if sugg:\n                    suggestions[i] = sugg\n            except Exception as e:\n                lg.debug(e)\n                pass\n            i += 1\n        if suggestions:\n            lg.success(\"\\nNote: Output of following commands are available:\\n\")\n            for i, sugg in suggestions.items():\n                lg.success(\"\\n\".join(sugg))\n                lg.opt(colors=True).success(\"^^^<e>[{}]</>^^^\\n\".format(i))\n        else:\n            lg.error(\n                \"Command output not found in any of the\"\n                \" {} must-gather paths\".format(len(mg_paths))\n            )\n"
  },
  {
    "path": "omg/components/etcdctl/__init__.py",
    "content": ""
  },
  {
    "path": "omg/components/etcdctl/etcdctl.py",
    "content": "import os\nfrom importlib import import_module\nfrom loguru import logger as lg\nfrom omg.utils.load_json import load_json\n\nfrom omg.config import config\n\n\ndef cmd(etcdctl_args, output):\n    cfg = config.get()\n    mg_paths = cfg[\"paths\"]\n\n    if output is None:\n        output = \"table\"\n\n    command = \"_\".join(etcdctl_args)\n    etcd_file = os.path.join(\n        \"etcd_info\", \"{}.json\".format(command))\n\n    lg.debug(\"etcd_file: {}\".format(etcd_file))\n\n    etcd_cmd_paths = {}\n    i = 1\n    for p in mg_paths:\n        ceph_cmd_path = os.path.join(p, etcd_file)\n        if os.path.isfile(ceph_cmd_path):\n            lg.info(\"Command output file found: {}\".format(ceph_cmd_path))\n            etcd_cmd_paths[i] = ceph_cmd_path\n        i += 1\n    if etcd_cmd_paths:\n        for i, cp in etcd_cmd_paths.items():\n            try:\n                j_data = load_json(cp)\n                table_mod = import_module(\n                    \"omg.components.etcdctl.output.{}\".format(command))\n                table_mod.etcdctl_out(j_data, output)\n            except Exception as e:\n                lg.warning(\"Error generating output for {}: {}\".format(command, e))\n                lg.success(\"\\nHere is the raw file ({}):\".format(cp))\n                with open(cp, \"r\") as cf:\n                    print(cf.read())\n            if len(mg_paths) > 1:\n                lg.opt(colors=True).success(\"^^^<e>[{}]</>^^^\\n\".format(i))\n    else:\n        suggestions = {}\n        i = 1\n        for p in mg_paths:\n            try:\n                files = os.listdir(os.path.join(p, \"etcd_info\"))\n                file_match = \"_\".join(etcdctl_args)\n                sugg = []\n                sugg.extend([\n                    \"omg etcdctl \" + f.replace(\"_\", \" \").replace(\".json\", \"\")\n                    for f in files if f.startswith(file_match)])\n                if sugg:\n                    suggestions[i] = sugg\n            except Exception:\n                pass\n            i += 1\n        if suggestions:\n            lg.success(\"\\nNote: Output of following commands are available:\\n\")\n            for i, sugg in suggestions.items():\n                lg.success(\"\\n\".join(sugg))\n                lg.opt(colors=True).success(\"^^^<e>[{}]</>^^^\\n\".format(i))\n        else:\n            lg.error(\n                \"Command output not found in any of the\"\n                \" {} must-gather paths\".format(len(mg_paths))\n            )\n"
  },
  {
    "path": "omg/components/etcdctl/output/__init__.py",
    "content": ""
  },
  {
    "path": "omg/components/etcdctl/output/alarm_list.py",
    "content": "import json\n\n\ndef etcdctl_out(j_data, output):\n    print(json.dumps(j_data, indent=2))\n"
  },
  {
    "path": "omg/components/etcdctl/output/endpoint_health.py",
    "content": "import json\nfrom tabulate import tabulate\nfrom omg.utils.dget import dget\n\n\ndef etcdctl_out(j_data, output):\n    if output == \"json\":\n        print(json.dumps(j_data, indent=2))\n    else:\n        head = [\"ENDPOINT\", \"HEALTH\", \"TOOK\", \"ERROR\"]\n        body = []\n        for jd in j_data:\n            body.append([\n                dget(jd, [\"endpoint\"], \"?\"),\n                dget(jd, [\"health\"], \"?\"),\n                dget(jd, [\"took\"], \"?\"),\n                dget(jd, [\"error\"], \"\"),\n            ])\n        if output == \"table\":\n            print(tabulate(body, head, tablefmt=\"psql\"))\n        elif output is None or output == \"simple\":\n            for row in body:\n                if row[3] == \"\":\n                    print(\n                        \"{} is healthy: \"\n                        \"successfully committed proposal: took = {}\"\n                        .format(row[0], row[2])\n                    )\n                else:\n                    print(\n                        \"{} is unhealthy: \"\n                        \"failed to commit proposal: {}\"\n                        .format(row[0], row[3])\n                    )\n"
  },
  {
    "path": "omg/components/etcdctl/output/endpoint_status.py",
    "content": "import json\nfrom tabulate import tabulate\nfrom omg.utils.dget import dget\nfrom omg.utils.size import num2human\n\n\ndef etcdctl_out(j_data, output):\n    if output == \"json\":\n        print(json.dumps(j_data, indent=2))\n    else:\n        head = [\n            \"ENDPOINT\", \"ID\", \"VERSION\", \"DB SIZE/IN USE\",\n            \"IS LEADER\", \"IS LEARNER\", \"RAFT TERM\", \"RAFT INDEX\",\n            \"RAFT APPLIED INDEX\", \"ERRORS\"\n        ]\n        body = []\n        for jd in j_data:\n            member_id = dget(jd, [\"Status\", \"header\", \"member_id\"])\n            leader_id = dget(jd, [\"Status\", \"leader\"])\n            body.append([\n                dget(jd, [\"Endpoint\"], \"?\"),\n                \"{:x}\".format(int(member_id)),\n                dget(jd, [\"Status\", \"version\"], \"?\"),\n                \"{}/{}\".format(\n                    num2human(dget(jd, [\"Status\", \"dbSize\"], \"0\")),\n                    num2human(dget(jd, [\"Status\", \"dbSizeInUse\"], \"0\"))\n                ),\n                \"true\" if member_id == leader_id else \"false\",\n                dget(jd, [\"isLearner\"], \"false\"),\n                dget(jd, [\"Status\", \"raftTerm\"], \"?\"),\n                dget(jd, [\"Status\", \"raftIndex\"], \"?\"),\n                dget(jd, [\"Status\", \"raftAppliedIndex\"], \"?\"),\n                dget(jd, [\"Status\", \"errors\"], \"\"),\n            ])\n        if output == \"table\":\n            print(tabulate(body, head, tablefmt=\"psql\"))\n        elif output is None or output == \"simple\":\n            for row in body:\n                print(\", \".join([str(r) for r in row]))\n"
  },
  {
    "path": "omg/components/etcdctl/output/member_list.py",
    "content": "import json\nfrom tabulate import tabulate\nfrom omg.utils.dget import dget\n\n\ndef etcdctl_out(j_data, output):\n    if output == \"json\":\n        print(json.dumps(j_data, indent=2))\n    else:\n        head = [\"ID\", \"STATUS\", \"NAME\", \"PEER ADDRS\", \"CLIENT ADDRS\", \"IS LEARNER\"]\n        body = []\n        for jd in dget(j_data, [\"members\"]):\n            name = dget(jd, [\"name\"], \"\")\n            body.append([\n                \"{:x}\".format(int(dget(jd, [\"ID\"]))),\n                \"started\" if len(name) > 0 else \"unstarted\",\n                name,\n                \",\".join(dget(jd, [\"peerURLs\"], \"?\")),\n                \",\".join(dget(jd, [\"clientURLs\"], \"?\")),\n                dget(jd, [\"isLearner\"], \"false\")\n            ])\n        if output == \"table\":\n            print(tabulate(body, head, tablefmt=\"psql\"))\n        elif output is None or output == \"simple\":\n            for row in body:\n                print(\", \".join([str(r) for r in row]))\n"
  },
  {
    "path": "omg/config/__init__.py",
    "content": ""
  },
  {
    "path": "omg/config/config.py",
    "content": "\"\"\" config.py \"\"\"\n\nimport yaml\nfrom os import path, getenv\nfrom loguru import logger as lg\nfrom omg.utils.dget import dget\nfrom omg.must_gather.scan_mg import scan_mg, NoValidMgFound\n\n_default_cfile = path.join(getenv(\"HOME\") or \"\", \".omgconfig\")\n\n# -p, --path\nfiltered_path = 0\n\n# -n, --namespace\nnamespace = None\n\n# -A, --all-namespaces\nall_namespaces = False\n\n\nclass NoMgSelected(Exception):\n    \"\"\"\n    Error raised when no must-gather is selected\n    \"\"\"\n    pass\n\n\nclass InvalidConfig(Exception):\n    \"\"\"\n    Error raised when config is invalid\n    \"\"\"\n    pass\n\n\ndef _load_config(cfile):\n    \"\"\"Load config from file.\n\n    If file doesn't exist MgConfigNotFound is raised.\n\n    Args:\n        cfile (str): Config file\n\n    Returns:\n        dict: Config dict\n    \"\"\"\n    lg.debug(\"FUNC_INIT: {}\".format(locals()))\n\n    if not cfile:\n        cfile = _default_cfile\n\n    config = {\"paths\": None, \"project\": None}\n\n    if path.isfile(cfile):\n        try:\n            with open(cfile, \"r\") as c_f:\n                lg.debug(\"Loading config from: {}\".format(cfile))\n                lconf = yaml.safe_load(c_f)\n                lg.debug(\"Loaded config from file: {}\".format(lconf))\n\n            config[\"paths\"] = dget(lconf, [\"paths\"], None)\n            config[\"project\"] = dget(lconf, [\"project\"], None)\n        except Exception as e:\n            raise InvalidConfig(e)\n\n    if not dget(config, [\"paths\"], None):\n        raise NoMgSelected(\"Please select a must-gather (omg use </path/to/must-gather>)\")\n\n    return config\n\n\ndef _dump_config(config, cfile):\n    \"\"\"Dump config to file\n\n    Args:\n        config (dict): Config dict\n        cfile (str): Config file\n    \"\"\"\n    if not cfile:\n        cfile = _default_cfile\n    try:\n        with open(cfile, \"w\") as c_f:\n            yaml.dump(config, c_f, default_flow_style=False)\n            lg.debug(\"Config dumped to {}\".format(cfile))\n    except Exception as e:\n        lg.error(e)\n        raise SystemExit(1)\n\n\ndef get(cfile=None):\n    \"\"\"Get config from file.\n\n    Args:\n        cfile (str, optional): Config file. Defaults to None.\n\n    Raises:\n        SystemExit: If paths is not found in config file\n\n    Returns:\n        dict: Config dict\n    \"\"\"\n    if not cfile:\n        env_config = getenv(\"OMGCONFIG\")\n        if env_config:\n            cfile = env_config\n        else:\n            cfile = _default_cfile\n\n    try:\n        config = _load_config(cfile)\n    except NoMgSelected as e:\n        lg.error(e)\n        raise SystemExit(1)\n\n    if config[\"paths\"] == [\".\"]:\n        try:\n            v_mgs = scan_mg([\".\"])\n            config[\"paths\"] = v_mgs\n            config[\"cwd\"] = True\n        except NoValidMgFound as e:\n            lg.error(e)\n            raise SystemExit(1)\n\n    if filtered_path:\n        config[\"paths\"] = [config[\"paths\"][filtered_path - 1]]\n\n    if namespace:\n        config[\"project\"] = namespace\n\n    if all_namespaces:\n        config[\"project\"] = \"_all\"\n\n    return config\n\n\ndef save(paths=None, project=None, cfile=None):\n    \"\"\"Save config to file\n\n    Args:\n        paths (list[str], optional): Must-gather paths. Defaults to None.\n        project ([type], optional): Project. Defaults to None.\n        cfile ([type], optional): Config file. Defaults to None.\n    \"\"\"\n\n    try:\n        config = _load_config(cfile)\n    except (NoMgSelected, InvalidConfig):\n        c_paths = None\n        c_project = None\n    else:\n        c_paths = dget(config, [\"paths\"])\n        c_project = dget(config, [\"project\"])\n\n    if paths:\n        save_paths = paths\n    else:\n        save_paths = c_paths\n\n    if project:\n        save_project = project\n    else:\n        save_project = c_project\n\n    _dump_config(\n        {\"paths\": save_paths, \"project\": save_project}, cfile)\n"
  },
  {
    "path": "omg/config/logging.py",
    "content": "import sys\nfrom os import getenv\nfrom loguru import logger\n\n\ndef _is_debug_or_trace(record):\n    return (\n        record[\"level\"].name == \"DEBUG\"\n        or\n        record[\"level\"].name == \"TRACE\"\n    )\n\n\ndef _is_info(record):\n    return record[\"level\"].name == \"INFO\"\n\n\ndef _is_success(record):\n    return record[\"level\"].name == \"SUCCESS\"\n\n\ndef _is_warning_or_error(record):\n    return (\n        record[\"level\"].name == \"WARNING\"\n        or\n        record[\"level\"].name == \"ERROR\"\n    )\n\n\n_debug_fmt = (\n    \"<level>{level}</level> \"\n    \"[<cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan>] \"\n    \"{message}\"\n)\n_info_fmt = (\n    \"<level>{level}</level> {message}\"\n)\n_success_fmt = (\n    \"<bold>{message}</bold>\"\n)\n\n\ndef setup_logging(loglevel):\n\n    # If loglevel is not set, we check the env['OMG_LOG_LEVEL']\n    # else we set it to default \"normal\"\n    if not loglevel:\n        env_log_level = getenv(\"OMG_LOG_LEVEL\")\n        if (env_log_level and env_log_level in ['normal', 'info', 'debug', 'trace']):\n            loglevel = env_log_level\n        else:\n            loglevel = \"normal\"\n\n    # Map the loglevel to loguru's standard/default loglevel\n    # normal -> SUCCESS(25)\n    # info   -> INFO(20)\n    # debug  -> DEBUG(10)\n    # trace  -> TRACE(5)\n    if loglevel == 'normal':\n        level = 25\n    elif loglevel == 'info':\n        level = 20\n    elif loglevel == 'debug':\n        level = 10\n    elif loglevel == 'trace':\n        level = 5\n    else:\n        raise ValueError('Invalid loglevel: ' + str(loglevel))\n\n    logger.remove()\n\n    # debug or trace uses _debug_fmt format\n    if level <= 10:\n        logger.add(sys.stderr, colorize=True, level=level,\n                   filter=_is_debug_or_trace, format=_debug_fmt)\n\n    # info uses _info_fmt format\n    if level <= 20:\n        logger.add(sys.stderr, colorize=True, level=level,\n                   filter=_is_info, format=_info_fmt)\n\n    # normal/default uses _success_fmt for success logs\n    # and _info_fmt for error and warning logs\n    if level <= 25:\n        logger.add(sys.stderr, colorize=True, level=level,\n                   filter=_is_success, format=_success_fmt)\n        logger.add(sys.stderr, colorize=True, level=level,\n                   filter=_is_warning_or_error, format=_info_fmt)\n"
  },
  {
    "path": "omg/get/__init__.py",
    "content": ""
  },
  {
    "path": "omg/get/complete.py",
    "content": "from omg.must_gather.RDEFS import RDEFS\nfrom omg.must_gather.get_rdef import get_generated_rdefs\nfrom omg.get.get_resources import get_all_resource_names\nfrom omg.get.parse import parse_get_args, ParseError\nfrom omg.config import config\nfrom omg.utils.dget import dget\nfrom loguru import logger as lg\n\n\ndef _suggest_type(incomplete_type):\n    \"\"\"\n    Match type based on incomplete string\n    \"\"\"\n    all_rdefs = []\n    all_rdefs.extend(RDEFS)\n    all_rdefs.extend(get_generated_rdefs())\n\n    all_types = set()\n    for rdef in all_rdefs:\n        singular = dget(rdef, [\"singular\"])\n        plural = dget(rdef, [\"plural\"])\n        # shortNames = dget(rdef, [\"shortNames\"])\n        group = dget(rdef, [\"group\"])\n\n        if group != \"core\":\n            all_types.add(plural + \".\" + group)\n        else:\n            all_types.add(singular)\n            all_types.add(plural)\n            # if shortNames:\n            #     all_types.update(shortNames)\n\n    match = [f for f in all_types if f.startswith(incomplete_type)]\n    return match\n\n\ndef complete_get(ctx, args, incomplete):\n    \"\"\"\n    Pull out objects args from Click context and return completions.\n    \"\"\"\n    lg.remove()\n    try:\n        cfg = config.get()\n        project = dget(cfg, [\"project\"])\n        namespace = ctx.params.get(\"namespace\") or project\n\n        objects = ctx.params.get(\"objects\")\n\n        if \"/\" in incomplete:\n            # We're completing something like `oc get pod/<tab>`.\n            in_rtype = incomplete.split(\"/\")[0]\n            in_rname = incomplete.split(\"/\")[1]\n            names = get_all_resource_names({in_rtype: []}, namespace)\n            return [\n                in_rtype + \"/\" + n\n                for n in names\n                if n.startswith(in_rname) and in_rtype + \"/\" + n not in objects\n            ]\n\n        if \",\" in incomplete or [o for o in objects if \",\" in o]:\n            # This is a NOP like oc\n            return []\n\n        slash_mode = False\n        comma_mode = False\n        if objects:\n            try:\n                parsed_objects = parse_get_args(objects)\n            except ParseError:\n                return []\n            else:\n                slash_mode = all(\"/\" in o for o in objects)\n                comma_mode = all(\",\" in o for o in objects)\n\n        # First arg after get, autocomplete type\n        # or autocompleting after existing slash-notation arg\n        if not objects or slash_mode:\n            if slash_mode:\n                add_slash = \"/\"\n            else:\n                add_slash = \"\"\n            sugg = _suggest_type(incomplete)\n            return [s + add_slash for s in sugg]\n\n        if not slash_mode and not comma_mode and len(parsed_objects) > 0:\n            # Autocomplete resource names based on the type: oc get pod mypod1 mypod2\n            names = get_all_resource_names(parsed_objects, namespace)\n            return [n for n in names if n.startswith(incomplete) and n not in objects]\n        # Catch all\n        return []\n\n    except Exception:\n        # Swallow any exception\n        return []\n"
  },
  {
    "path": "omg/get/get.py",
    "content": "from loguru import logger as lg\nfrom omg.get.parse import parse_get_args, ParseError\nfrom omg.config import config\nfrom omg.get.output.o_raw import o_raw\nfrom omg.get.output.o_table import o_table\nfrom omg.utils.dget import dget\nfrom omg.get.get_resources import get_all_resources\n\n\ndef cmd(objects, output, show_labels):\n    lg.debug(\"FUNC_INIT: {}\".format(locals()))\n\n    # Parse objects\n    try:\n        parsed_objects = parse_get_args(objects)\n    except ParseError as e:\n        lg.error(e)\n        return 2\n\n    lg.debug(\"parsed_objects: {}\".format(parsed_objects))\n\n    # Set namespace\n    ns = dget(config.get(), [\"project\"])\n\n    lg.debug(\"Namespace resolved to: {}\".format(ns))\n\n    # Collect resources\n    all_res_d = get_all_resources(parsed_objects, ns)\n\n    # No resource type found e.g:\n    # all_res_d == [{}, {}, ..<paths>.. ]\n    if not any(all_res_d):\n        lg.error(\"Unkown resource type\")\n        return 2\n\n    # Resource type found, but no resources found e.g:\n    # [{'pods': []}, {'pods': []}, ..<paths>..]\n    if not any([bool(all_res_d[i][rtype]) for i in all_res_d for rtype in all_res_d[i]]):\n        print(\"No resources found\")\n        return 2\n\n    # Pass the parsed object to respective output function\n    if output in [\"yaml\", \"json\", \"name\"]:\n        o_raw(all_res_d, output)\n    elif output is None or output == \"wide\":\n        o_table(all_res_d, ns, output, show_labels)\n    else:\n        lg.error(\"Unknow output type: {}\".format(output))\n"
  },
  {
    "path": "omg/get/get_resources.py",
    "content": "from loguru import logger as lg\n\nfrom omg.config import config\nfrom omg.utils.dget import dget\nfrom omg.must_gather.load_resources import load_res\nfrom omg.must_gather.exceptions import NameSpaceRequired, UnkownResourceType\n\n\ndef get_all_resources(parsed_objects, ns=None):\n    \"\"\"Get resources from all paths\n\n    Args:\n        parsed_objects (dict): Parsed object\n        ns (string): Namespace/project\n\n    Returns:\n        list:   for each r_type, list of resources from each path\n                (list of dict of list)\n                For example:\n                    [\n                        # resources_from_path1\n                        {   'pod': [ res1, res2 ... ],\n                            'svc': [ res1, ... ],\n                            ...\n                        },\n                        # resources_from_path2\n                        ...\n                    ]\n    \"\"\"\n    lg.debug(\"FUNC_INIT: {}\".format(locals()))\n\n    cfg = config.get()\n    paths = cfg[\"paths\"]\n\n    # Resources dicts from selected paths\n    # resd_from_paths = []\n    resd_from_paths = {}\n\n    i = 0\n    for path in paths:\n        i += 1\n        resd = {}\n        for r_type in parsed_objects:\n            r_names = parsed_objects[r_type]\n\n            try:\n                res = load_res(path, r_type, r_names, ns)\n            except NameSpaceRequired as e:\n                lg.error(e)\n                raise SystemExit(1)\n            except UnkownResourceType:\n                lg.error(\"Unknow resource type: {}\".format(r_type))\n                raise SystemExit(1)\n            else:\n                resd[r_type] = res\n        # resd_from_paths.append(resd)\n        resd_from_paths[i] = resd\n    return resd_from_paths\n\n\ndef get_all_resource_names(parsed_objects, ns=None):\n\n    resd_from_paths = get_all_resources(parsed_objects, ns)\n\n    all_names = []\n    for i, path_resd in resd_from_paths.items():\n        for r_type in path_resd:\n            res = path_resd[r_type]\n            if res:\n                for r in res:\n                    name = dget(r, [\"res\", \"metadata\", \"name\"])\n                    if name:\n                        all_names.append(name)\n    return all_names\n"
  },
  {
    "path": "omg/get/output/__init__.py",
    "content": ""
  },
  {
    "path": "omg/get/output/build_table.py",
    "content": "from importlib import import_module\nfrom loguru import logger as lg\n\nfrom omg.utils.dget import dget\nfrom omg.utils.age import age\n\n\ndef _col_ns(res):\n    return dget(res, [\"res\", \"metadata\", \"namespace\"], \"\")\n\n\ndef _col_name(res):\n    return dget(res, [\"res\", \"metadata\", \"name\"], \"\")\n\n\ndef _col_name_wtype(res):\n    group = dget(res, [\"rdef\", \"group\"])\n    singular = dget(res, [\"rdef\", \"singular\"])\n    if group == \"core\":\n        out_type = singular\n    else:\n        out_type = str(singular) + \".\" + str(group)\n    name = dget(res, [\"res\", \"metadata\", \"name\"], \"\")\n    return \"{}/{}\".format(out_type, name)\n\n\ndef _col_age(res):\n    pod_ct = dget(res, [\"res\", \"metadata\", \"creationTimestamp\"])\n    yfile_ts = dget(res, [\"yfile_ts\"])\n    return age(pod_ct, yfile_ts)\n\n\ndef _col_labels(res):\n    lab = dget(res, [\"res\", \"metadata\", \"labels\"])\n    if lab:\n        return \",\".join([\"{}={}\".format(k, v) for k, v in lab.items()])\n    else:\n        return \"<none>\"\n\n\ndef build_table(res, ns, output, show_type, show_labels):\n    lg.debug(\"FUNC_INIT: {}\".format(locals()))\n\n    rdef = dget(res[0], [\"rdef\"])\n\n    # Get columns for the type of resources we are building table for\n    # If we find the matching module in table_modules we will use that\n    # Otherwise the default NAME and AGE columns will be used.\n    kind = dget(rdef, [\"kind\"])\n    try:\n        table_mod = import_module(\"omg.get.output.table_modules.{}\".format(kind))\n        def_cols = table_mod.DEFAULT_COLUMNS\n        wid_cols = table_mod.WIDE_COLUMNS\n    except ModuleNotFoundError:\n        def_cols = {\n            \"NAME\": None,\n            \"AGE\": None\n        }\n        wid_cols = {}\n    pass\n\n    # Header and respective header functions\n    # We build the table header in header array and alongside,\n    # populate the respective functions for that column in head_f array\n    header = []\n    head_f = []\n\n    scope = dget(rdef, [\"scope\"])\n\n    # Populate NAME/AGE in default column dict\n    if dget(def_cols, [\"NAME\"], \"\") is None:\n        if show_type:\n            def_cols[\"NAME\"] = _col_name_wtype\n        else:\n            def_cols[\"NAME\"] = _col_name\n    if dget(def_cols, [\"AGE\"], \"\") is None:\n        def_cols[\"AGE\"] = _col_age\n\n    # Go over default/wide column dicts and populate\n    # header and header_fn. Namespace and Labels are added\n    # (first and last respectively) if needed\n    if ns == \"_all\" and scope == \"Namespaced\":\n        header.append(\"NAMESPACE\")\n        head_f.append(_col_ns)\n    for hd, fn in def_cols.items():\n        header.append(hd)\n        head_f.append(fn)\n    if output == \"wide\":\n        for hd, fn in wid_cols.items():\n            header.append(hd)\n            head_f.append(fn)\n    if show_labels:\n        header.append(\"LABELS\")\n        head_f.append(_col_labels)\n\n    # Iterate over resources and call the header function\n    # to build the table body\n    body = []\n    for r in res:\n        row = []\n        for hf in head_f:\n            try:\n                row.append(hf(r))\n            except Exception as e:\n                lg.debug(\"table cell execption: {}\".format(e))\n                row.append(\"?Unknown?\")\n        body.append(row)\n\n    return [header] + body\n"
  },
  {
    "path": "omg/get/output/o_raw.py",
    "content": "from loguru import logger as lg\nfrom omg.config import config\nfrom omg.utils.dget import dget\nimport yaml\nimport json\n\n\ndef o_raw(resd_from_paths, output):\n    lg.debug(\"FUNC_INIT: {}\".format(locals()))\n\n    cfg = config.get()\n    paths = cfg[\"paths\"]\n\n    for i, path_resd in resd_from_paths.items():\n        all_res = []\n        for r_type in path_resd:\n            res = path_resd[r_type]\n            if res:\n                all_res.extend(res)\n\n        if all_res:\n            if len(all_res) == 1:\n                out_res = dget(all_res[0], [\"res\"])\n            elif len(all_res) > 1:\n                out_res = {\n                        \"apiVersion\": \"v1\",\n                        \"kind\": \"List\",\n                        \"items\": [dget(res, [\"res\"]) for res in all_res]\n                    }\n            else:\n                continue\n\n            if output == \"yaml\":\n                print(yaml.dump(out_res))\n            elif output == \"json\":\n                print(json.dumps(out_res))\n            elif output == \"name\":\n                for res in all_res:\n                    group = dget(res, [\"rdef\", \"group\"])\n                    singular = dget(res, [\"rdef\", \"singular\"])\n                    if group == \"core\":\n                        out_type = singular\n                    else:\n                        out_type = str(singular) + \".\" + str(group)\n                    name = dget(res, [\"res\", \"metadata\", \"name\"])\n                    print(\n                        str(out_type) + \"/\" + str(name)\n                    )\n\n            if (len(paths) > 1):\n                lg.opt(colors=True).success(\"^^^<e>[{}]</>^^^\\n\".format(i))\n"
  },
  {
    "path": "omg/get/output/o_table.py",
    "content": "from tabulate import tabulate\nfrom loguru import logger as lg\nfrom os import getenv\nfrom omg.config import config\nfrom omg.get.output.build_table import build_table\n\n\ndef o_table(resd_from_paths, ns, output, show_labels):\n    \"\"\"Handles table output.\n       Both simple (without -o) and wide (-o wide)\n\n    Args:\n        parsed_objects (dict):  Contains parsed dictionary of objects to get.\n                                This dict is the one we get from parse.py module.\n\n        ns (str): Namespace is needed if we are showing output for all-namespaces.\n\n        output (str):   This is passed from click (-o). We need to know if the output\n                        is simple (-o not set) or wide (-o wide).\n\n        show_labels (bool):     This is passed from click (--show-labels)\n    \"\"\"\n    lg.debug(\"FUNC_INIT: {}\".format(locals()))\n\n    cfg = config.get()\n    paths = cfg[\"paths\"]\n\n    tablefmt = getenv(\"OMG_TABLE_FMT\") or \"plain\"\n\n    show_type = False\n    if max([len(resd_from_paths[i]) for i in resd_from_paths]) > 1:\n        show_type = True\n\n    for i, path_resd in resd_from_paths.items():\n        table_all_res = None\n        for r_type in path_resd:\n            res = path_resd[r_type]\n            if res:\n                res_table = build_table(res, ns, output, show_type, show_labels)\n                if table_all_res:\n                    table_all_res += [[\"\"]] + res_table\n                else:\n                    table_all_res = res_table\n        if table_all_res:\n            print(tabulate(table_all_res, tablefmt=tablefmt))\n            if (len(paths) > 1):\n                lg.opt(colors=True).success(\"^^^<e>[{}]</>^^^\\n\".format(i))\n"
  },
  {
    "path": "omg/get/output/table_modules/Build.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\nfrom omg.utils.age import age\n\n\ndef _col_type(res):\n    return dget(res, [\"res\", \"spec\", \"strategy\", \"type\"], \"Unknown\")\n\n\ndef _col_from(res):\n    return dget(res, [\"res\", \"spec\", \"source\", \"type\"], \"Unknown\")\n\n\ndef _col_status(res):\n    return dget(res, [\"res\", \"status\", \"phase\"], \"Unknown\")\n\n\ndef _col_started(res):\n    stt = dget(res, [\"res\", \"status\", \"startTimestamp\"])\n    if stt:\n        yfile_ts = dget(res, [\"yfile_ts\"])\n        return age(stt, yfile_ts)\n\n\ndef _col_duration(res):\n    dur = dget(res, [\"res\", \"status\", \"duration\"])\n    if dur:\n        return str(int(dur/1000000000)) + \"s\"\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"TYPE\": _col_type,\n    \"FROM\": _col_from,\n    \"STATUS\": _col_status,\n    \"STARTED\": _col_started,\n    \"DURATION\": _col_duration\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/BuildConfig.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_type(res):\n    return dget(res, [\"res\", \"spec\", \"strategy\", \"type\"], \"Unknown\")\n\n\ndef _col_from(res):\n    return dget(res, [\"res\", \"spec\", \"source\", \"type\"], \"Unknown\")\n\n\ndef _col_latest(res):\n    return dget(res, [\"res\", \"status\", \"lastVersion\"], \"Unknown\")\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"TYPE\": _col_type,\n    \"FROM\": _col_from,\n    \"LATEST\": _col_latest\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/CSIDriver.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_attachrequired(res):\n    return dget(res, [\"res\", \"spec\", \"attachRequired\"], \"Unknown\")\n\n\ndef _col_podinfoonmount(res):\n    return dget(res, [\"res\", \"spec\", \"podInfoOnMount\"], \"Unknown\")\n\n\ndef _col_modes(res):\n    return \",\".join(dget(res, [\"res\", \"spec\", \"volumeLifecycleModes\"], []))\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"ATTACHREQUIRED\": _col_attachrequired,\n    \"PODINFOONMOUNT\": _col_podinfoonmount,\n    \"MODES\": _col_modes,\n    \"AGE\": None\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/CSINode.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_drivers(res):\n    drivers = dget(res, [\"res\", \"spec\", \"drivers\"])\n    if drivers:\n        return len(drivers)\n    return \"0\"\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"DRIVERS\": _col_drivers,\n    \"AGE\": None\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/CatalogSource.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_display(res):\n    return dget(res, [\"res\", \"spec\", \"displayName\"])\n\n\ndef _col_type(res):\n    return dget(res, [\"res\", \"spec\", \"sourceType\"])\n\n\ndef _col_publisher(res):\n    return dget(res, [\"res\", \"spec\", \"publisher\"])\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"DISPLAY\": _col_display,\n    \"TYPE\": _col_type,\n    \"PUBLISHER\": _col_publisher,\n    \"AGE\": None\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/CephCluster.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_datadirhostpath(res):\n    return dget(res, [\"res\", \"spec\", \"dataDirHostPath\"], \"Unknown\")\n\n\ndef _col_moncount(res):\n    return dget(res, [\"res\", \"spec\", \"mon\", \"count\"], \"Unknown\")\n\n\ndef _col_phase(res):\n    return dget(res, [\"res\", \"status\", \"phase\"], \"Unknown\")\n\n\ndef _col_message(res):\n    return dget(res, [\"res\", \"status\", \"message\"], \"Unknown\")\n\n\ndef _col_health(res):\n    return dget(res, [\"res\", \"status\", \"ceph\", \"health\"], \"Unknown\")\n\n\ndef _col_external(res):\n    return dget(res, [\"res\", \"spec\", \"external\", \"enable\"], \"\")\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"DATADIRHOSTPATH\": _col_datadirhostpath,\n    \"MONCOUNT\": _col_moncount,\n    \"AGE\": None,\n    \"PHASE\": _col_phase,\n    \"MESSAGE\": _col_message,\n    \"HEALTH\": _col_health,\n    \"EXTERNAL\": _col_external\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/CephFilesystem.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_activemds(res):\n    return dget(res, [\"res\", \"spec\", \"metadataServer\", \"activeCount\"], \"Unknown\")\n\n\ndef _col_phase(res):\n    return dget(res, [\"res\", \"status\", \"phase\"], \"Unknown\")\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"ACTIVEMDS\": _col_activemds,\n    \"AGE\": None,\n    \"PHASE\": _col_phase,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/CertificateSigningRequest.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_signername(res):\n    return dget(res, [\"res\", \"spec\", \"signerName\"], \"\")\n\n\ndef _col_requestor(res):\n    return dget(res, [\"res\", \"spec\", \"username\"], \"\")\n\n\ndef _col_condition(res):\n    conds = dget(res, [\"res\", \"status\", \"conditions\"])\n    if conds:\n        return \",\".join([c[\"type\"] for c in conds])\n    return \"Pending\"\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"AGE\": None,\n    \"SIGNERNAME\": _col_signername,\n    \"REQUESTOR\": _col_requestor,\n    \"CONDITION\": _col_condition\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/ClusterOperator.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\nfrom omg.utils.age import age\n\n\ndef _col_version(res):\n    vers = dget(res, [\"res\", \"status\", \"versions\"])\n    if vers:\n        operator_v = [v[\"version\"] for v in vers if v[\"name\"] == \"operator\"]\n        if operator_v:\n            return operator_v[0]\n    return \"\"\n\n\ndef _col_available(res):\n    conds = dget(res, [\"res\", \"status\", \"conditions\"])\n    if conds:\n        available = [c[\"status\"] for c in conds if c[\"type\"] == \"Available\"]\n        if available:\n            return available[0]\n    return \"Unknown\"\n\n\ndef _col_progressing(res):\n    conds = dget(res, [\"res\", \"status\", \"conditions\"])\n    if conds:\n        prog = [c[\"status\"] for c in conds if c[\"type\"] == \"Progressing\"]\n        if prog:\n            return prog[0]\n    return \"Unknown\"\n\n\ndef _col_degraded(res):\n    conds = dget(res, [\"res\", \"status\", \"conditions\"])\n    if conds:\n        degraded = [c[\"status\"] for c in conds if c[\"type\"] == \"Degraded\"]\n        if degraded:\n            return degraded[0]\n    return \"Unknown\"\n\n\ndef _col_since(res):\n    conds = dget(res, [\"res\", \"status\", \"conditions\"])\n    if conds:\n        ltt = [c[\"lastTransitionTime\"] for c in conds if c[\"type\"] == \"Available\"]\n        if ltt:\n            yfile_ts = dget(res, [\"yfile_ts\"])\n            return age(ltt[0], yfile_ts)\n    return \"Unknown\"\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"VERSION\": _col_version,\n    \"AVAILABLE\": _col_available,\n    \"PROGRESSING\": _col_progressing,\n    \"DEGRADED\": _col_degraded,\n    \"SINCE\": _col_since\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/ClusterServiceVersion.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_display(res):\n    return dget(res, [\"res\", \"spec\", \"displayName\"])\n\n\ndef _col_version(res):\n    return dget(res, [\"res\", \"spec\", \"version\"])\n\n\ndef _col_replaces(res):\n    return dget(res, [\"res\", \"spec\", \"replaces\"])\n\n\ndef _col_phase(res):\n    return dget(res, [\"res\", \"status\", \"phase\"])\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"DISPLAY\": _col_display,\n    \"VERSION\": _col_version,\n    \"REPLACES\": _col_replaces,\n    \"PHASE\": _col_phase\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/ClusterVersion.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\nfrom omg.utils.age import age\n\n\ndef _col_version(res):\n    hist = dget(res, [\"res\", \"status\", \"history\"])\n    if hist:\n        cluster_v = [h[\"version\"] for h in hist if h[\"state\"] == \"Completed\"]\n        if cluster_v:\n            return cluster_v[0]\n    return \"\"\n\n\ndef _col_available(res):\n    conds = dget(res, [\"res\", \"status\", \"conditions\"])\n    if conds:\n        available = [c[\"status\"] for c in conds if c[\"type\"] == \"Available\"]\n        if available:\n            return available[0]\n    return \"Unknown\"\n\n\ndef _col_progressing(res):\n    conds = dget(res, [\"res\", \"status\", \"conditions\"])\n    if conds:\n        prog = [c[\"status\"] for c in conds if c[\"type\"] == \"Progressing\"]\n        if prog:\n            return prog[0]\n    return \"Unknown\"\n\n\ndef _col_since(res):\n    conds = dget(res, [\"res\", \"status\", \"conditions\"])\n    if conds:\n        ltt = [c[\"lastTransitionTime\"] for c in conds if c[\"type\"] == \"Available\"]\n        if ltt:\n            yfile_ts = dget(res, [\"yfile_ts\"])\n            return age(ltt[0], yfile_ts)\n    return \"Unknown\"\n\n\ndef _col_status(res):\n    conds = dget(res, [\"res\", \"status\", \"conditions\"])\n    if conds:\n        status = [c[\"message\"] for c in conds if c[\"type\"] == \"Progressing\"]\n        if status:\n            return status[0]\n    return \"Unknown\"\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"VERSION\": _col_version,\n    \"AVAILABLE\": _col_available,\n    \"PROGRESSING\": _col_progressing,\n    \"SINCE\": _col_since,\n    \"STATUS\": _col_status\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/ConfigMap.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_data(res):\n    return len(dget(res, [\"res\", \"data\"], []))\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"DATA\": _col_data,\n    \"AGE\": None,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/CronJob.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\nfrom omg.utils.age import age\n\n\ndef _col_schedule(res):\n    return dget(res, [\"res\", \"spec\", \"schedule\"])\n\n\ndef _col_suspend(res):\n    return dget(res, [\"res\", \"spec\", \"suspend\"])\n\n\ndef _col_active(res):\n    return len(dget(res, [\"res\", \"status\", \"active\"], []))\n\n\ndef _col_last_schedule(res):\n    last_sched = dget(res, [\"res\", \"status\", \"lastScheduleTime\"])\n    if last_sched:\n        return age(\n            last_sched,\n            dget(res, [\"yfile_ts\"])\n        )\n    return \"\"\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"SCHEDULE\": _col_schedule,\n    \"SUSPEND\": _col_suspend,\n    \"ACTIVE\": _col_active,\n    \"LAST SCHEDULE\": _col_last_schedule,\n    \"AGE\": None\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/CustomResourceDefinition.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_created_at(res):\n    return dget(res, [\"res\", \"metadata\", \"creationTimestamp\"], \"Unknown\")\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"CREATED AT\": _col_created_at\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/DaemonSet.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_desired(res):\n    return dget(res, [\"res\", \"status\", \"desiredNumberScheduled\"])\n\n\ndef _col_current(res):\n    return dget(res, [\"res\", \"status\", \"currentNumberScheduled\"])\n\n\ndef _col_ready(res):\n    return dget(res, [\"res\", \"status\", \"numberReady\"])\n\n\ndef _col_uptodate(res):\n    return dget(res, [\"res\", \"status\", \"updatedNumberScheduled\"], \"0\")\n\n\ndef _col_available(res):\n    return dget(res, [\"res\", \"status\", \"numberAvailable\"], \"0\")\n\n\ndef _col_node_selector(res):\n    nselector = dget(res, [\"res\", \"spec\", \"template\", \"spec\", \"nodeSelector\"], {})\n    selector = []\n    for k, v in nselector.items():\n        selector.append(\"{}={}\".format(k, v))\n    if selector:\n        return \",\".join(selector)\n    else:\n        return \"\"\n\n\ndef _col_containers(res):\n    conts = [c[\"name\"] for c in dget(res, [\"res\", \"spec\", \"template\", \"spec\", \"containers\"])]\n    if conts:\n        return \",\".join(conts)\n    return \"\"\n\n\ndef _col_images(res):\n    images = [c[\"image\"] for c in dget(res, [\"res\", \"spec\", \"template\", \"spec\", \"containers\"])]\n    if images:\n        return \",\".join(images)\n    return \"\"\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"DESIRED\": _col_desired,\n    \"CURRENT\": _col_current,\n    \"READY\": _col_ready,\n    \"UP-TO-DATE\": _col_uptodate,\n    \"AVAILABLE\": _col_available,\n    \"NODE SELECTOR\": _col_node_selector,\n    \"AGE\": None,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n    \"CONTAINERS\": _col_containers,\n    \"IMAGES\": _col_images,\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/Deployment.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_ready(res):\n    replicas = dget(res, [\"res\", \"spec\", \"replicas\"], \"?\")\n    readyReplicas = dget(res, [\"res\", \"status\", \"readyReplicas\"], \"0\")\n    return \"{}/{}\".format(readyReplicas, replicas)\n\n\ndef _col_uptodate(res):\n    return dget(res, [\"res\", \"status\", \"updatedReplicas\"], \"0\")\n\n\ndef _col_available(res):\n    return dget(res, [\"res\", \"status\", \"availableReplicas\"], \"0\")\n\n\ndef _col_containers(res):\n    conts = [c[\"name\"] for c in dget(res, [\"res\", \"spec\", \"template\", \"spec\", \"containers\"])]\n    if conts:\n        return \",\".join(conts)\n    return \"\"\n\n\ndef _col_images(res):\n    images = [c[\"image\"] for c in dget(res, [\"res\", \"spec\", \"template\", \"spec\", \"containers\"])]\n    if images:\n        return \",\".join(images)\n    return \"\"\n\n\ndef _col_selector(res):\n    labels = dget(res, [\"res\", \"spec\", \"selector\", \"matchLabels\"])\n    selector = []\n    for k, v in labels.items():\n        selector.append(\"{}={}\".format(k, v))\n    return \",\".join(selector)\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"READY\": _col_ready,\n    \"UP-TO-DATE\": _col_uptodate,\n    \"AVAILABLE\": _col_available,\n    \"AGE\": None,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n    \"CONTAINERS\": _col_containers,\n    \"IMAGES\": _col_images,\n    \"SELECTOR\": _col_selector\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/DeploymentConfig.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_revision(res):\n    return dget(res, [\"res\", \"status\", \"latestVersion\"])\n\n\ndef _col_desired(res):\n    return dget(res, [\"res\", \"spec\", \"replicas\"])\n\n\ndef _col_current(res):\n    return dget(res, [\"res\", \"status\", \"readyReplicas\"])\n\n\ndef _col_triggered_by(res):\n    triggers = dget(res, [\"res\", \"spec\", \"triggers\"], [])\n    trig_list = []\n    for trig in triggers:\n        if trig[\"type\"] == \"ConfigChange\":\n            trig_list.append(\"config\")\n        elif trig[\"type\"] == \"ImageChange\":\n            img = dget(trig, [\"imageChangeParams\", \"from\", \"name\"])\n            trig_list.append(\"image({})\".format(img))\n        else:\n            trig_list.append(str(trig[\"type\"]))\n    return \",\".join(trig_list)\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"REVISION\": _col_revision,\n    \"DESIRED\": _col_desired,\n    \"CURRENT\": _col_current,\n    \"TRIGGERED BY\": _col_triggered_by,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/EndpointSlice.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_addresstype(res):\n    return dget(res, [\"res\", \"addressType\"])\n\n\ndef _col_ports(res):\n    ports = [\n        str(dget(p, [\"port\"]))\n        for p in dget(res, [\"res\", \"ports\"]) or []\n    ]\n    port_string = \"\"\n    if ports:\n        while len(ports) > 0:\n            port = ports.pop()\n            if len(port_string) + len(port) <= 30:\n                if port_string:\n                    port_string = \",\".join([port_string, port])\n                else:\n                    port_string = port\n            else:\n                port_string = \"{} + {} more...\".format(\n                    port_string,\n                    len(ports) + 1\n                )\n        return port_string\n    return \"<none>\"\n\n\ndef _col_endpoints(res):\n    addresses = [\n        addr\n        for ep in dget(res, [\"res\", \"endpoints\"]) or []\n        for addr in dget(ep, [\"addresses\"]) or []\n    ]\n    ep_string = \"\"\n    if addresses:\n        while len(addresses) > 0:\n            ep = addresses.pop()\n            if len(ep_string) + len(ep) <= 30:\n                if ep_string:\n                    ep_string = \",\".join([ep_string, ep])\n                else:\n                    ep_string = ep\n            else:\n                ep_string = \"{} + {} more...\".format(\n                    ep_string,\n                    len(addresses) + 1\n                )\n                break\n    return ep_string\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"ADDRESSTYPE\": _col_addresstype,\n    \"PORTS\": _col_ports,\n    \"ENDPOINTS\": _col_endpoints,\n    \"AGE\": None\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/Endpoints.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_endpoints(res):\n    endpoints = [\n        \"{}:{}\".format(\n            dget(addr, [\"ip\"]),\n            dget(port, [\"port\"])\n        )\n        for subset in dget(res, [\"res\", \"subsets\"], [])\n        for addr in dget(subset, [\"addresses\"], [])\n        for port in dget(subset, [\"ports\"], [])\n    ]\n    ep_string = \"\"\n    while len(endpoints) > 0:\n        ep = endpoints.pop()\n        if len(ep_string) + len(ep) <= 40:\n            if ep_string:\n                ep_string = \",\".join([ep_string, ep])\n            else:\n                ep_string = ep\n        else:\n            ep_string = \"{} + {} more...\".format(\n                ep_string,\n                len(endpoints) + 1\n            )\n            break\n    return ep_string\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"ENDPOINTS\": _col_endpoints,\n    \"AGE\": None\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/Event.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\nfrom omg.utils.age import age\n\n\ndef _col_last_seen(res):\n    return age(\n        dget(res, [\"res\", \"lastTimestamp\"]),\n        dget(res, [\"yfile_ts\"])\n    )\n\n\ndef _col_type(res):\n    return dget(res, [\"res\", \"type\"])\n\n\ndef _col_reason(res):\n    return dget(res, [\"res\", \"reason\"])\n\n\ndef _col_object(res):\n    obj = \"{}/{}\".format(\n        dget(res, [\"res\", \"involvedObject\", \"kind\"], \"\"),\n        dget(res, [\"res\", \"involvedObject\", \"name\"], \"\")\n    )\n    if obj == \"/\":\n        return \"<none>\"\n    else:\n        return obj\n\n\ndef _col_message(res):\n    return dget(res, [\"res\", \"message\"], \"<none>\")\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"LAST SEEN\": _col_last_seen,\n    \"TYPE\": _col_type,\n    \"REASON\": _col_reason,\n    \"OBJECT\": _col_object,\n    \"MESSAGE\": _col_message\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/HorizontalPodAutoscaler.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_reference(res):\n    return \"{}/{}\".format(\n        dget(res, [\"res\", \"spec\", \"scaleTargetRef\", \"kind\"], \"\"),\n        dget(res, [\"res\", \"spec\", \"scaleTargetRef\", \"name\"], \"\")\n    )\n\n\ndef _col_targets(res):\n    return \"{}%/{}%\".format(\n        dget(res, [\"res\", \"status\", \"currentCPUUtilizationPercentage\"], \"Unknown\"),\n        dget(res, [\"res\", \"spec\", \"targetCPUUtilizationPercentage\"], \"Unkown\")\n    )\n\n\ndef _col_minpods(res):\n    return dget(res, [\"res\", \"spec\", \"minReplicas\"])\n\n\ndef _col_maxpods(res):\n    return dget(res, [\"res\", \"spec\", \"maxReplicas\"])\n\n\ndef _col_replicas(res):\n    return dget(res, [\"res\", \"status\", \"currentReplicas\"])\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"REFERENCE\": _col_reference,\n    \"TARGETS\": _col_targets,\n    \"MINPODS\": _col_minpods,\n    \"MAXPODS\": _col_maxpods,\n    \"REPLICAS\": _col_replicas,\n    \"AGE\": None,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/HostSubnet.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_host(res):\n    return dget(res, [\"res\", \"host\"])\n\n\ndef _col_ip(res):\n    return dget(res, [\"res\", \"hostIP\"])\n\n\ndef _col_subnet(res):\n    return dget(res, [\"res\", \"subnet\"])\n\n\ndef _col_cidrs(res):\n    return dget(res, [\"res\", \"egressCIDRs\"])\n\n\ndef _col_egress_ips(res):\n    return dget(res, [\"res\", \"egressIPs\"])\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"HOST\": _col_host,\n    \"HOST IP\": _col_ip,\n    \"SUBNET\": _col_subnet,\n    \"EGRESS CIDRS\": _col_cidrs,\n    \"EGRESS IPS\": _col_egress_ips,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/ImageStream.py",
    "content": "# -*- coding: utf-8 -*-\nfrom datetime import datetime\nfrom omg.utils.dget import dget\nfrom dateutil.parser import parse\nfrom omg.utils.age import age\n\n\ndef _col_image_repository(res):\n    return dget(res, [\"res\", \"status\", \"publicDockerImageRepository\"])\n\n\ndef _col_tags(res):\n    tags = [\n        tag[\"tag\"]\n        for tag in\n        dget(res, [\"res\", \"status\", \"tags\"], [])\n        if \"tag\" in tag\n    ]\n    tag_string = \"\"\n    while len(tags) > 0:\n        t = tags.pop()\n        if len(tag_string) + len(t) <= 30:\n            if tag_string:\n                tag_string = \",\".join([tag_string, t])\n            else:\n                tag_string = t\n        else:\n            tag_string = \"{} + {} more...\".format(\n                tag_string,\n                len(tags) + 1\n            )\n            break\n    return tag_string\n\n\ndef _col_updated(res):\n    creation_ts = []\n    tags = dget(res, [\"res\", \"status\", \"tags\"], [])\n    if tags:\n        for tag in tags:\n            items = dget(tag, [\"items\"], [])\n            if items:\n                for item in items:\n                    created = dget(item, [\"created\"])\n                    if created:\n                        creation_ts.append(created)\n    latest = None\n    if creation_ts:\n        for cts in creation_ts:\n            if isinstance(cts, datetime):\n                cts = cts.isoformat()\n            p_cts = parse(cts)\n            if (\n                latest is None or\n                p_cts > latest\n            ):\n                latest = p_cts\n    if latest:\n        return age(latest.isoformat(), dget(res, [\"yfile_ts\"]))\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"IMAGE REPOSITORY\": _col_image_repository,\n    \"TAGS\": _col_tags,\n    \"UPDATED\": _col_updated\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/InstallPlan.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_csv(res):\n    csv = dget(res, [\"res\", \"spec\", \"clusterServiceVersionNames\"])\n    if csv:\n        return csv[0]\n\n\ndef _col_approval(res):\n    return dget(res, [\"res\", \"spec\", \"approval\"])\n\n\ndef _col_approved(res):\n    return dget(res, [\"res\", \"spec\", \"approved\"])\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"CSV\": _col_csv,\n    \"APPROVAL\": _col_approval,\n    \"APPROVED\": _col_approved\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/Job.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\nfrom omg.utils.age import age\n\n\ndef _col_completions(res):\n    return \"{}/{}\".format(\n        dget(res, [\"res\", \"status\", \"succeeded\"], 0),\n        dget(res, [\"res\", \"spec\", \"completions\"], 1)\n    )\n\n\ndef _col_duration(res):\n    st = dget(res, [\"res\", \"status\", \"startTime\"])\n    ct = dget(res, [\"res\", \"status\", \"completionTime\"])\n    if st and ct:\n        return age(st, ct, ts1_type=\"iso\", ts2_type=\"iso\")\n    else:\n        return \"\"\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"COMPLETIONS\": _col_completions,\n    \"DURATION\": _col_duration,\n    \"AGE\": None,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/Machine.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_phase(res):\n    return dget(res, [\"res\", \"status\", \"phase\"], \"\")\n\n\ndef _col_type(res):\n    return dget(res, [\"res\", \"metadata\", \"labels\", \"machine.openshift.io/instance-type\"], \"\")\n\n\ndef _col_region(res):\n    return dget(res, [\"res\", \"metadata\", \"labels\", \"machine.openshift.io/region\"], \"\")\n\n\ndef _col_zone(res):\n    return dget(res, [\"res\", \"metadata\", \"labels\", \"machine.openshift.io/zone\"], \"\")\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"PHASE\": _col_phase,\n    \"TYPE\": _col_type,\n    \"REGION\": _col_region,\n    \"ZONE\": _col_zone,\n    \"AGE\": None\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/MachineConfig.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_generatedbycontroller(res):\n    return dget(res, [\n        \"res\", \"metadata\", \"annotations\",\n        \"machineconfiguration.openshift.io/generated-by-controller-version\"],\n        \"\")\n\n\ndef _col_ignitionversion(res):\n    return dget(res, [\"res\", \"spec\", \"config\", \"ignition\", \"version\"], \"Unknown\")\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"GENERATEDBYCONTROLLER\": _col_generatedbycontroller,\n    \"IGNITIONVERSION\": _col_ignitionversion,\n    \"AGE\": None\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/MachineConfigPool.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_config(res):\n    return dget(res, [\"res\", \"spec\", \"configuration\", \"name\"], \"\")\n\n\ndef _col_updated(res):\n    conds = dget(res, [\"res\", \"status\", \"conditions\"])\n    if conds:\n        updated = [c[\"status\"] for c in conds if c[\"type\"] == \"Updated\"]\n        if updated:\n            return updated[0]\n    return \"Unknown\"\n\n\ndef _col_updating(res):\n    conds = dget(res, [\"res\", \"status\", \"conditions\"])\n    if conds:\n        updating = [c[\"status\"] for c in conds if c[\"type\"] == \"Updating\"]\n        if updating:\n            return updating[0]\n    return \"Unknown\"\n\n\ndef _col_degraded(res):\n    conds = dget(res, [\"res\", \"status\", \"conditions\"])\n    if conds:\n        degraded = [c[\"status\"] for c in conds if c[\"type\"] == \"Degraded\"]\n        if degraded:\n            return degraded[0]\n    return \"Unknown\"\n\n\ndef _col_machinecount(res):\n    return dget(res, [\"res\", \"status\", \"machineCount\"], \"Unknown\")\n\n\ndef _col_readymachinecount(res):\n    return dget(res, [\"res\", \"status\", \"readyMachineCount\"], \"Unknown\")\n\n\ndef _col_updatedmachinecount(res):\n    return dget(res, [\"res\", \"status\", \"updatedMachineCount\"], \"Unknown\")\n\n\ndef _col_degradedmachinecount(res):\n    return dget(res, [\"res\", \"status\", \"degradedMachineCount\"], \"Unknown\")\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"CONFIG\": _col_config,\n    \"UPDATED\": _col_updated,\n    \"UPDATING\": _col_updating,\n    \"DEGRADED\": _col_degraded,\n    \"MACHINECOUNT\": _col_machinecount,\n    \"READYMACHINECOUNT\": _col_readymachinecount,\n    \"UPDATEDMACHINECOUNT\": _col_updatedmachinecount,\n    \"DEGRADEDMACHINECOUNT\": _col_degradedmachinecount,\n    \"AGE\": None\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/MachineSet.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_desired(res):\n    return dget(res, [\"res\", \"spec\", \"replicas\"], \"\")\n\n\ndef _col_current(res):\n    return dget(res, [\"res\", \"status\", \"replicas\"], \"\")\n\n\ndef _col_ready(res):\n    return dget(res, [\"res\", \"status\", \"readyReplicas\"], \"\")\n\n\ndef _col_available(res):\n    return dget(res, [\"res\", \"status\", \"availableReplicas\"], \"\")\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"DESIRED\": _col_desired,\n    \"CURRENT\": _col_current,\n    \"READY\": _col_ready,\n    \"AVAILABLE\": _col_available,\n    \"AGE\": None\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/MutatingWebhookConfiguration.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_webhooks(res):\n    return len(dget(res, [\"res\", \"webhooks\"]))\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"WEBHOOKS\": _col_webhooks,\n    \"AGE\": None,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/Namespace.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_disp_name(res):\n    return dget(res, [\"res\", \"metadata\", \"annotations\", \"openshift.io/display-name\"], \"\")\n\n\ndef _col_status(res):\n    return dget(res, [\"res\", \"status\", \"phase\"], \"\")\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by _build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"DISPLAY NAME\": _col_disp_name,\n    \"STATUS\": _col_status,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/NetNamespace.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_netid(res):\n    return dget(res, [\"res\", \"netid\"])\n\n\ndef _col_egress_ips(res):\n    return dget(res, [\"res\", \"egressIPs\"])\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"NETID\": _col_netid,\n    \"EGRESS IPS\": _col_egress_ips\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/NetworkPolicy.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_pod_selector(res):\n    selectors = []\n    # matchExpressions\n    me = dget(res, [\"res\", \"spec\", \"podSelector\", \"matchExpressions\"], [])\n    for exp in me:\n        selectors.append(\n             \"{} {} ({})\".format(\n                 dget(exp, [\"key\"]),\n                 dget(exp, [\"operator\"]).lower(),\n                 \",\".join(dget(exp, [\"values\"], []))\n             )\n        )\n    # matchLabels\n    ml = dget(res, [\"res\", \"spec\", \"podSelector\", \"matchLabels\"], {})\n    for k, v in ml.items():\n        selectors.append(\"{}={}\".format(k, v))\n\n    if selectors:\n        return \",\".join(selectors)\n    else:\n        return \"<none>\"\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"POD-SELECTOR\": _col_pod_selector,\n    \"AGE\": None\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/Node.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_status(res):\n    status = \"Unknown\"\n    conds = dget(res, [\"res\", \"status\", \"conditions\"])\n    if conds:\n        for c in conds:\n            if dget(c, [\"type\"]) == \"Ready\":\n                if dget(c, [\"status\"]) == \"True\":\n                    status = \"Ready\"\n                elif dget(c, [\"status\"]) == \"False\":\n                    status = \"NotReady\"\n\n    if dget(res, [\"res\", \"spec\", \"unschedulable\"]):\n        status += \",SchedulingDisabled\"\n    return status\n\n\ndef _col_roles(res):\n    roles = []\n    labels = dget(res, [\"res\", \"metadata\", \"labels\"])\n    if labels:\n        for label in labels:\n            if label.startswith(\"node-role.kubernetes.io/\"):\n                roles.append(label.split(\"/\")[1])\n    return \",\".join(roles)\n\n\ndef _col_version(res):\n    return dget(\n        res,\n        [\"res\", \"status\", \"nodeInfo\", \"kubeletVersion\"],\n        \"Unknown\"\n    )\n\n\ndef _col_iip(res):\n    iip = \"<none>\"\n    addresses = dget(res, [\"res\", \"status\", \"addresses\"])\n    if addresses:\n        for adr in addresses:\n            if dget(adr, [\"type\"]) == \"InternalIP\":\n                iip = dget(adr, [\"address\"])\n                break\n    return iip\n\n\ndef _col_eip(res):\n    eip = \"<none>\"\n    addresses = dget(res, [\"res\", \"status\", \"addresses\"])\n    if addresses:\n        for adr in addresses:\n            if dget(adr, [\"type\"]) == \"ExternalIP\":\n                eip = dget(adr, [\"address\"])\n                break\n    return eip\n\n\ndef _col_osimg(res):\n    return dget(\n        res,\n        [\"res\", \"status\", \"nodeInfo\", \"osImage\"],\n        \"Unknown\"\n    )\n\n\ndef _col_kerver(res):\n    return dget(\n        res,\n        [\"res\", \"status\", \"nodeInfo\", \"kernelVersion\"],\n        \"Unknown\"\n    )\n\n\ndef _col_crt(res):\n    return dget(\n        res,\n        [\"res\", \"status\", \"nodeInfo\", \"containerRuntimeVersion\"],\n        \"Unknown\"\n    )\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"STATUS\": _col_status,\n    \"ROLES\": _col_roles,\n    \"AGE\": None,\n    \"VERSION\": _col_version\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n    \"INTERNAL-IP\": _col_iip,\n    \"EXTERNAL-IP\": _col_eip,\n    \"OS-IMAGE\": _col_osimg,\n    \"KERNEL-VERSION\": _col_kerver,\n    \"CONTAINER-RUNTIME\": _col_crt,\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/PersistentVolume.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_capacity(res):\n    return dget(res, [\"res\", \"spec\", \"capacity\", \"storage\"])\n\n\ndef _col_access_modes(res):\n    am = dget(res, [\"res\", \"spec\", \"accessModes\"], [])\n    return \",\".join([\n        a\n        .replace(\"Read\", \"R\")\n        .replace(\"Write\", \"W\")\n        .replace(\"Many\", \"X\")\n        .replace(\"Once\", \"O\")\n        for a in am\n    ])\n\n\ndef _col_reclaim_policy(res):\n    return dget(res, [\"res\", \"spec\", \"persistentVolumeReclaimPolicy\"], \"Unknown\")\n\n\ndef _col_status(res):\n    return dget(res, [\"res\", \"status\", \"phase\"], \"\")\n\n\ndef _col_claim(res):\n    claim = \"{}/{}\".format(\n        dget(res, [\"res\", \"spec\", \"claimRef\", \"namespace\"], \"\"),\n        dget(res, [\"res\", \"spec\", \"claimRef\", \"name\"], \"\")\n    )\n    if claim == \"/\":\n        return \"\"\n    else:\n        return claim\n\n\ndef _col_storageclass(res):\n    return dget(res, [\"res\", \"spec\", \"storageClassName\"], \"\")\n\n\ndef _col_reason(res):\n    return dget(res, [\"res\", \"status\", \"reason\"], \"\")\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"CAPACITY\": _col_capacity,\n    \"ACCESS MODES\": _col_access_modes,\n    \"RECLAIM POLICY\": _col_reclaim_policy,\n    \"STATUS\": _col_status,\n    \"CLAIM\": _col_claim,\n    \"STORAGECLASS\": _col_storageclass,\n    \"REASON\": _col_reason,\n    \"AGE\": None\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/PersistentVolumeClaim.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_status(res):\n    return dget(res, [\"res\", \"status\", \"phase\"], \"\")\n\n\ndef _col_volume(res):\n    return dget(res, [\"res\", \"spec\", \"volumeName\"], \"\")\n\n\ndef _col_capacity(res):\n    return dget(res, [\"res\", \"status\", \"capacity\", \"storage\"], \"Unkown\")\n\n\ndef _col_access_modes(res):\n    am = dget(res, [\"res\", \"spec\", \"accessModes\"], [])\n    return \",\".join([\n        a\n        .replace(\"Read\", \"R\")\n        .replace(\"Write\", \"W\")\n        .replace(\"Many\", \"X\")\n        .replace(\"Once\", \"O\")\n        for a in am\n    ])\n\n\ndef _col_storageclass(res):\n    return dget(res, [\"res\", \"spec\", \"storageClassName\"], \"\")\n\n\ndef _col_volumemode(res):\n    return dget(res, [\"res\", \"spec\", \"volumeMode\"], \"Unknow\")\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"STATUS\": _col_status,\n    \"VOLUME\": _col_volume,\n    \"CAPACITY\": _col_capacity,\n    \"ACCESS MODES\": _col_access_modes,\n    \"STORAGECLASS\": _col_storageclass,\n    \"AGE\": None\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n    \"VOLUMEMODE\": _col_volumemode\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/Pod.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_ready(res):\n    cont_total = len(dget(res, [\"res\", \"spec\", \"containers\"], \"\"))\n    cont_ready = len([\n            r for r in\n            dget(res, [\"res\", \"status\", \"containerStatuses\"], \"\")\n            if dget(r, [\"ready\"]) is True\n        ])\n    return \"{}/{}\".format(cont_ready, cont_total)\n\n\ndef _col_status(res):\n    return dget(res, [\"res\", \"status\", \"phase\"], \"\")\n\n\ndef _col_restarts(res):\n    con_statuses = dget(res, [\"res\", \"status\", \"containerStatuses\"])\n    if con_statuses:\n        return max([\n            dget(r, [\"restartCount\"], 0)\n            for r in con_statuses\n        ])\n    else:\n        return 0\n\n\ndef _col_ip(res):\n    return dget(res, [\"res\", \"status\", \"podIP\"], \"\")\n\n\ndef _col_node(res):\n    return dget(res, [\"res\", \"spec\", \"nodeName\"])\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"READY\": _col_ready,\n    \"STATUS\": _col_status,\n    \"RESTARTS\": _col_restarts,\n    \"AGE\": None\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n    \"IP\": _col_ip,\n    \"NODE\": _col_node\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/ReplicaSet.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_desired(res):\n    return dget(res, [\"res\", \"spec\", \"replicas\"], \"0\")\n\n\ndef _col_current(res):\n    return dget(res, [\"res\", \"status\", \"availableReplicas\"], \"0\")\n\n\ndef _col_ready(res):\n    replicas = dget(res, [\"res\", \"spec\", \"replicas\"], \"?\")\n    readyReplicas = dget(res, [\"res\", \"status\", \"readyReplicas\"], \"0\")\n    return \"{}/{}\".format(readyReplicas, replicas)\n\n\ndef _col_containers(res):\n    conts = [c[\"name\"] for c in dget(res, [\"res\", \"spec\", \"template\", \"spec\", \"containers\"])]\n    if conts:\n        return \",\".join(conts)\n    return \"\"\n\n\ndef _col_images(res):\n    images = [c[\"image\"] for c in dget(res, [\"res\", \"spec\", \"template\", \"spec\", \"containers\"])]\n    if images:\n        return \",\".join(images)\n    return \"\"\n\n\ndef _col_selector(res):\n    labels = dget(res, [\"res\", \"spec\", \"selector\", \"matchLabels\"], {})\n    selector = []\n    for k, v in labels.items():\n        selector.append(\"{}={}\".format(k, v))\n    return \",\".join(selector)\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"DESIRED\": _col_desired,\n    \"CURRENT\": _col_current,\n    \"READY\": _col_ready,\n    \"AGE\": None,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n    \"CONTAINERS\": _col_containers,\n    \"IMAGES\": _col_images,\n    \"SELECTOR\": _col_selector\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/ReplicationController.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_desired(res):\n    return dget(res, [\"res\", \"status\", \"replicas\"], \"0\")\n\n\ndef _col_current(res):\n    return dget(res, [\"res\", \"status\", \"fullyLabeledReplicas\"], \"0\")\n\n\ndef _col_ready(res):\n    return dget(res, [\"res\", \"status\", \"readyReplicas\"], \"0\")\n\n\ndef _col_containers(res):\n    conts = [c[\"name\"] for c in dget(res, [\"res\", \"spec\", \"template\", \"spec\", \"containers\"])]\n    if conts:\n        return \",\".join(conts)\n    return \"\"\n\n\ndef _col_images(res):\n    images = [c[\"image\"] for c in dget(res, [\"res\", \"spec\", \"template\", \"spec\", \"containers\"])]\n    if images:\n        return \",\".join(images)\n    return \"\"\n\n\ndef _col_selector(res):\n    labels = dget(res, [\"res\", \"spec\", \"selector\", \"matchLabels\"])\n    selector = []\n    for k, v in labels.items():\n        selector.append(\"{}={}\".format(k, v))\n    return \",\".join(selector)\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"DESIRED\": _col_desired,\n    \"CURRENT\": _col_current,\n    \"READY\": _col_ready,\n    \"AGE\": None,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n    \"CONTAINERS\": _col_containers,\n    \"IMAGES\": _col_images,\n    \"SELECTOR\": _col_selector\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/Route.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_host_port(res):\n    return dget(res, [\"res\", \"spec\", \"host\"])\n\n\ndef _col_path(res):\n    return dget(res, [\"res\", \"spec\", \"path\"])\n\n\ndef _col_services(res):\n    return dget(res, [\"res\", \"spec\", \"to\", \"name\"])\n\n\ndef _col_port(res):\n    return dget(res, [\"res\", \"spec\", \"port\", \"targetPort\"], \"<all>\")\n\n\ndef _col_termination(res):\n    return \"/\".join([\n        dget(res, [\"res\", \"spec\", \"tls\", \"termination\"], \"\"),\n        dget(res, [\"res\", \"spec\", \"tls\", \"insecureEdgeTerminationPolicy\"], \"\")\n    ])\n\n\ndef _col_wildcard(res):\n    return dget(res, [\"res\", \"spec\", \"wildcardPolicy\"])\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"HOST/PORT\": _col_host_port,\n    \"PATH\": _col_path,\n    \"SERVICES\": _col_services,\n    \"PORT\": _col_port,\n    \"TERMINATION\": _col_termination,\n    \"WILDCARD\": _col_wildcard,\n    \"AGE\": None,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/Secret.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_type(res):\n    return dget(res, [\"res\", \"type\"], \"Unkown\")\n\n\ndef _col_data(res):\n    return len(dget(res, [\"res\", \"data\"], \"\"))\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"TYPE\": _col_type,\n    \"DATA\": _col_data,\n    \"AGE\": None,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/Service.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_type(res):\n    return dget(res, [\"res\", \"spec\", \"type\"], \"Unkown\")\n\n\ndef _col_cluster_ip(res):\n    return dget(res, [\"res\", \"spec\", \"clusterIP\"], \"\")\n\n\ndef _col_external_ip(res):\n    en = dget(res, [\"res\", \"spec\", \"externalName\"])\n    if en:\n        return en\n    ei = dget(res, [\"res\", \"spec\", \"externalIP\"])\n    if ei:\n        return ei\n    return \"<none>\"\n\n\ndef _col_ports(res):\n    return \",\".join(\n        \"{}/{}\".format(p[\"port\"], p[\"protocol\"])\n        for p in dget(res, [\"res\", \"spec\", \"ports\"], [])\n    )\n\n\ndef _col_selector(res):\n    labels = dget(res, [\"res\", \"spec\", \"selector\"], {})\n    selector = []\n    for k, v in labels.items():\n        selector.append(\"{}={}\".format(k, v))\n    return \",\".join(selector) or \"<none>\"\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"TYPE\": _col_type,\n    \"CLUSTER-IP\": _col_cluster_ip,\n    \"EXTERNAL-IP\": _col_external_ip,\n    \"PORT(S)\": _col_ports,\n    \"AGE\": None,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n    \"SELECTOR\": _col_selector\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/StatefulSet.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_ready(res):\n    replicas = dget(res, [\"res\", \"status\", \"replicas\"], \"?\")\n    readyReplicas = dget(res, [\"res\", \"status\", \"readyReplicas\"], \"0\")\n    return \"{}/{}\".format(readyReplicas, replicas)\n\n\ndef _col_containers(res):\n    conts = [c[\"name\"] for c in dget(res, [\"res\", \"spec\", \"template\", \"spec\", \"containers\"])]\n    if conts:\n        return \",\".join(conts)\n    return \"\"\n\n\ndef _col_images(res):\n    images = [c[\"image\"] for c in dget(res, [\"res\", \"spec\", \"template\", \"spec\", \"containers\"])]\n    if images:\n        return \",\".join(images)\n    return \"\"\n\n\ndef _col_selector(res):\n    labels = dget(res, [\"res\", \"spec\", \"selector\", \"matchLabels\"])\n    selector = []\n    for k, v in labels.items():\n        selector.append(\"{}={}\".format(k, v))\n    return \",\".join(selector)\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"READY\": _col_ready,\n    \"AGE\": None,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n    \"CONTAINERS\": _col_containers,\n    \"IMAGES\": _col_images,\n    \"SELECTOR\": _col_selector\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/StorageClass.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_provisioner(res):\n    return dget(res, [\"res\", \"provisioner\"])\n\n\ndef _col_reclaimpolicy(res):\n    return dget(res, [\"res\", \"reclaimPolicy\"])\n\n\ndef _col_volumebindingmode(res):\n    return dget(res, [\"res\", \"volumeBindingMode\"])\n\n\ndef _col_allowvolumeexpansion(res):\n    return dget(res, [\"res\", \"allowVolumeExpansion\"], \"false\")\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"PROVISIONER\": _col_provisioner,\n    \"RECLAIMPOLICY\": _col_reclaimpolicy,\n    \"VOLUMEBINDINGMODE\": _col_volumebindingmode,\n    \"ALLOWVOLUMEEXPANSION\": _col_allowvolumeexpansion,\n    \"AGE\": None,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/Subscription.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_package(res):\n    return dget(res, [\"res\", \"spec\", \"name\"])\n\n\ndef _col_source(res):\n    return dget(res, [\"res\", \"spec\", \"source\"])\n\n\ndef _col_channel(res):\n    return dget(res, [\"res\", \"spec\", \"channel\"])\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"PACKAGE\": _col_package,\n    \"SOURCE\": _col_source,\n    \"CHANNEL\": _col_channel\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/ValidatingWebhookConfiguration.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_webhooks(res):\n    return len(dget(res, [\"res\", \"webhooks\"]))\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"WEBHOOKS\": _col_webhooks,\n    \"AGE\": None,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/VirtualMachine.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_ready(res):\n    conds = dget(res, [\"res\", \"status\", \"conditions\"])\n    if conds:\n        ready = [c[\"status\"] for c in conds if c[\"type\"] == \"Ready\"]\n        if ready:\n            return ready[0]\n    return \"Unknown\"\n\n\ndef _col_status(res):\n    return dget(res, [\"res\", \"status\", \"printableStatus\"], \"\")\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"AGE\": None,\n    \"STATUS\": _col_status,\n    \"READY\": _col_ready,\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n}\n"
  },
  {
    "path": "omg/get/output/table_modules/VirtualMachineInstance.py",
    "content": "# -*- coding: utf-8 -*-\nfrom omg.utils.dget import dget\n\n\ndef _col_ready(res):\n    conds = dget(res, [\"res\", \"status\", \"conditions\"])\n    if conds:\n        ready = [c[\"status\"] for c in conds if c[\"type\"] == \"Ready\"]\n        if ready:\n            return ready[0]\n\n\ndef _col_phase(res):\n    return dget(res, [\"res\", \"status\", \"phase\"], \"\")\n\n\ndef _col_ip(res):\n    interfaces = dget(res, [\"res\", \"status\", \"interfaces\"])\n    if interfaces:\n        return interfaces[0][\"ipAddresses\"][0]\n\n\ndef _col_node(res):\n    return dget(res, [\"res\", \"status\", \"nodeName\"])\n\n\ndef _col_live_migratable(res):\n    conds = dget(res, [\"res\", \"status\", \"conditions\"])\n    if conds:\n        LiveMigratable = [c[\"status\"] for c in conds if c[\"type\"] == \"LiveMigratable\"]\n        if LiveMigratable:\n            return LiveMigratable[0]\n\n\ndef _col_paused(res):\n    conds = dget(res, [\"res\", \"status\", \"conditions\"])\n    if conds:\n        Paused  = [c[\"status\"] for c in conds if c[\"type\"] == \"Paused\"]\n        if Paused:\n            return Paused[0]\n\n\n# Default columns (without -o wide)\n# NAME and AGE cols, if present, with None value,\n# will be handled by build_table function that will\n# fill them with the common name/age column functions\nDEFAULT_COLUMNS = {\n    \"NAME\": None,\n    \"AGE\": None,\n    \"PHASE\": _col_phase,\n    \"IP\": _col_ip,\n    \"NODE\": _col_node,\n    \"READY\": _col_ready\n}\n\n# Wide columns (with -o wide)\n# In addition to the default columns\nWIDE_COLUMNS = {\n    \"LIVE-MIGRATABLE\": _col_live_migratable,\n    \"PAUSED\" : _col_paused\n}\n"
  },
  {
    "path": "omg/get/parse.py",
    "content": "# This module handles parsing of the omg's `get` command\n# i.e, it normalizes whatever is passed after `omg get <....>`\n# Since omg get can be called in a variety of ways, following is a\n# detailed description of all the \"varities\" omg will handle:\n#\n# 1- SLASH Notation\n#   Syntax:\n#       omg get Type1/Name1 [Type2/Name2 Type3/Name3 ....]\n#   Examples:\n#       - omg get pod/httpd-sdf32\n#       - omg get svc/httpd route/httpd\n#\n# 2- COMMA Notation\n#   Syntax:\n#       omg get Type1,Type2[,Type3,...] [Name1 Name2 ...]\n#   Examples:\n#       - omg get pods,svc\n#       - omg get svc,route,deployment httpd nginx\n#\n# 3- PLAIN\n#   Syntax:\n#       omg get Type [Name1 Name2 Name3]\n#   Examples:\n#       - omg get pods\n#       - omg get nodes node1 node2\n#       - omg get all\n#\n# Note:\n#   Any get request can fall into either one of these syntaxes\n#   A mix of these types will not be supported\n\n\n# What resources to show when `omg get all` is called\nALL_TYPES = ['pod', 'rc', 'svc', 'ds', 'deployment',\n             'rs', 'statefulset', 'hpa', 'job', 'cronjob',\n             'dc', 'bc', 'build.build.openshift.io', 'is']\n\n\nclass ParseError(Exception):\n    \"\"\"\n    Error raised during parsing of `oc get` args.\n    \"\"\"\n    pass\n\n\ndef _parse_slash(args):\n    \"\"\"\n    Parses slash based get args\n    \"\"\"\n    objects = []\n    for arg in args:\n        if '/' not in arg:\n            raise ParseError(\"Invalid arguments to get\")\n        o_split = arg.split('/')\n        r_type = o_split[0]\n        r_name = o_split[1]\n        objects.append((r_type, r_name))\n    return objects\n\n\ndef _parse_comma(args):\n    \"\"\"\n    Parses comma based get args\n    \"\"\"\n    objects = []\n    # The first arg contains comma sperated types\n    first = args[0]\n    types = first.split(\",\")\n    if 'all' in types:\n        types.extend(ALL_TYPES)\n        types.remove(\"all\")\n\n    # If more than one args are present these are names of objects to get\n    if len(args) > 1:\n        names = args[1:]\n    else:\n        names = []\n\n    for t in types:\n        if names:\n            for n in names:\n                objects.append((t, n))\n        else:\n            objects.append((t, []))\n\n    return objects\n\n\ndef _parse_plain(args):\n    \"\"\"\n    Parses plain get args (e.g, without comma or slash)\n    \"\"\"\n    objects = []\n    # The first arg should be the type\n    first = args[0]\n    if first == 'all':\n        types = tuple(ALL_TYPES)\n    else:\n        types = (first,)\n\n    # If more than one args are present these are names of objects to get\n    if len(args) > 1:\n        # names are not allowed with \"all\"\n        if first == 'all':\n            raise ParseError(\"Resource names not allowed with 'all'\")\n        names = args[1:]\n    else:\n        names = []\n\n    for t in types:\n        if names:\n            for n in names:\n                objects.append((t, n))\n        else:\n            objects.append((t, None))\n\n    return objects\n\n\ndef parse_get_args(objects):\n    \"\"\"\n    Takes a tuple (examples below) of arguments passed to `omg get ...` and parses it.\n    Returns a dict (key: \"resource type\", value: list(\"resource names\")).\n\n    Raises ResourceParseError if it runs into any issues.\n\n    Example input -> output:\n    ('pod', 'httpd')                -> {'pod': ['httpd']}\n    ('pods', 'httpd1', 'httpd2')    -> {'pod': ['httpd1', 'httpd2']}\n    ('dc/httpd', 'pod/httpd1')      -> {'dc': ['httpd'], 'pod': ['httpd1']}\n    ('routes')                      -> {'routes': []}\n    ('pod,svc')                     -> {'pod': [], 'svc': []}\n    ('svc,route','httpd','nginx')   -> {'svc': ['httpd', 'nginx'], 'route': ['httpd', 'nginx']}\n    \"\"\"\n\n    parsed_resources = {}\n\n    if not objects:\n        raise ParseError(\"Empty arguments to get\")\n\n    # Determine the type of args from the first arg\n    first = objects[0]\n    if '/' in first:\n        parsed_objects = _parse_slash(objects)\n    elif ',' in first:\n        parsed_objects = _parse_comma(objects)\n    else:\n        parsed_objects = _parse_plain(objects)\n\n    for r_type, r_name in parsed_objects:\n        if r_type not in parsed_resources:\n            parsed_resources[r_type] = []\n        if r_name:\n            parsed_resources[r_type].append(r_name)\n\n    return parsed_resources\n"
  },
  {
    "path": "omg/log/__init__.py",
    "content": ""
  },
  {
    "path": "omg/log/complete.py",
    "content": "from omg.config import config\nfrom omg.utils.dget import dget\nimport os\nfrom loguru import logger as lg\n\n\ndef complete_pods(ctx, args, incomplete):\n    \"\"\"\n    Callback for pod name (within a ns) autocompletion\n    :return: List of matching pod names or empty list.\n    \"\"\"\n    lg.remove()\n    cfg = config.get()\n    c_paths = dget(cfg, [\"paths\"])\n    c_project = dget(cfg, [\"project\"])\n\n    ns = ctx.params.get(\"namespace\") or c_project\n    suggestions = []\n    for path in c_paths:\n        pod_dir = os.path.join(path, \"namespaces\", ns, \"pods\")\n        if os.path.isdir(pod_dir):\n            pod_listing = os.listdir(pod_dir)\n            if pod_listing:\n                suggestions.extend([pod for pod in pod_listing if incomplete in pod])\n    return suggestions\n\n\ndef complete_containers(ctx, args, incomplete):\n    \"\"\"\n    Callback for container name (within a pod and ns) autocompletion\n    :return: List of matching container names or empty list\n    \"\"\"\n    lg.remove()\n    cfg = config.get()\n    c_paths = dget(cfg, [\"paths\"])\n    c_project = dget(cfg, [\"project\"])\n\n    if (\n        len(ctx.args) != 1\n    ):\n        # If there's no pod specified yet, can't autocomplete a container name\n        return []\n\n    ns = ctx.params.get(\"namespace\") or c_project\n\n    pod = ctx.args[0]\n\n    container_listing = []\n    for path in c_paths:\n        container_dir = os.path.join(path, \"namespaces\", ns, \"pods\", pod)\n        if os.path.isdir(container_dir):\n            containers = os.listdir(container_dir)\n            if containers:\n                container_listing.extend(containers)\n\n    suggestions = [\n        c for c in container_listing if incomplete in c and not c.endswith(\".yaml\")\n    ]  # skip .yaml files\n    return suggestions\n"
  },
  {
    "path": "omg/log/log.py",
    "content": "import os\nfrom loguru import logger as lg\nfrom omg.config import config\nfrom omg.utils.dget import dget\n\n\ndef cmd(resource, container, previous):\n    lg.debug(\"FUNC_INIT: {}\".format(locals()))\n\n    cfg = config.get()\n    paths = dget(cfg, [\"paths\"])\n    ns = dget(cfg, [\"project\"])\n\n    if not paths:\n        lg.error(\"No must-gather selected\")\n        raise SystemExit(1)\n\n    if ns == \"_all\":\n        lg.error(\"All Namespaces is not supported with `omg log ...` \")\n        raise SystemExit(1)\n    elif ns is None:\n        lg.error(\"No namespace/project selected\")\n        raise SystemExit(1)\n\n    if \"/\" in resource:\n        r_type = resource.split(\"/\")[0]\n        pod = resource.split(\"/\")[1]\n        if r_type not in [\"pod\", \"pods\"]:\n            lg.error(\"Can not print logs of type:\", r_type)\n            raise SystemExit(1)\n    else:\n        pod = resource\n\n    if not ns:\n        lg.error(\"Namespace/Project not set\")\n        raise SystemExit(1)\n\n    log_files = []\n    for path in paths:\n\n        proj_path = os.path.join(path, \"namespaces\", ns)\n        if not os.path.isdir(proj_path):\n            continue\n\n        pod_dir = os.path.join(proj_path, \"pods\", pod)\n        if not os.path.isdir(pod_dir):\n            # lg.warning(\"Pod directory not found: {}\".format(pod_dir))\n            continue\n\n        con_dirs = [\n            c for c in os.listdir(pod_dir)\n            if os.path.isdir(os.path.join(pod_dir, c))\n        ]\n\n        if not con_dirs:\n            lg.warning(\"No container directory not found in {}\".format(pod_dir))\n            continue\n        elif len(con_dirs) == 1:\n            con_dir = con_dirs[0]\n            if container and container != con_dir:\n                lg.warning(\"Container directory {} not found in {}\".format(\n                    container, pod_dir))\n                continue\n        elif len(con_dirs) > 1:\n            if container is None:\n                lg.error(\n                    \"This pod has more than one containers:\" +\n                    str(con_dirs) + \"\\n\"\n                    \"Use -c/--container to specify the container\"\n                )\n                raise SystemExit(1)\n            elif container not in con_dirs:\n                lg.warning(\"Container directory {} not found in {}\".format(\n                    container, pod_dir))\n                continue\n            else:\n                con_dir = container\n\n        if previous:\n            log_files.append(\n                os.path.join(pod_dir, con_dir, con_dir, \"logs\", \"previous.log\")\n            )\n        else:\n            log_files.append(\n                os.path.join(pod_dir, con_dir, con_dir, \"logs\", \"current.log\")\n            )\n\n    if not log_files:\n        lg.error(\"No log files found\")\n\n    for logfile in log_files:\n        if not os.path.isfile(logfile):\n            lg.warning(\"Log file not found: {}\".format(logfile))\n        else:\n            lg.info(logfile)\n            with open(logfile, \"r\") as lf:\n                print(lf.read())\n        if len(log_files) > 1:\n            print(\"\")\n            print(\"~~~\")\n            print(\"\")\n"
  },
  {
    "path": "omg/machine_config/__init__.py",
    "content": ""
  },
  {
    "path": "omg/machine_config/compare.py",
    "content": "import difflib\nfrom loguru import logger as lg\n\nfrom omg.get.get_resources import get_all_resources\nfrom omg.machine_config.decode_content import decode\n\n\ndef mc_compare(m, show_contents):\n    # NOTE TO SELF: Recursion has gone out of hand,\n    # probably re-impelement the comparison logic without\n    # using recursion\n\n    if len(m) != 2:\n        lg.error(\"Provide two machine-configs to compare\")\n        raise SystemExit(1)\n\n    try:\n        two_mcs = []\n        for mc_name in m:\n            all_mcs = get_all_resources({\"mc\": [mc_name]})\n            matched_mcs = []\n            for i, mc_res in all_mcs.items():\n                for _, mc_data_l in mc_res.items():\n                    if mc_data_l:\n                        for mc_data in mc_data_l:\n                            matched_mcs.append(mc_data[\"res\"])\n            if not matched_mcs:\n                raise Exception(\"MachineConfig {} not found\".format(mc_name))\n            elif len(matched_mcs) > 1:\n                raise Exception(\n                    \"More than one MachineConfig matched for {}\\n\"\n                    \"Use --path/-P to select a single must-gather path\"\n                    .format(mc_name)\n                )\n            else:\n                two_mcs.append(matched_mcs[0])\n        mc1 = two_mcs[0]\n        mc2 = two_mcs[1]\n    except Exception as e:\n        lg.error(e)\n        raise SystemExit(1)\n\n    # Recursive function to show diff when --show-contents is set\n    # We either get both strings in d1 and d2 ([*CHANGE]), or\n    # we get on empty string on one and a dict on other ([+ADDED], [-REMOVED])\n    def show_diff(d1, d2, indent=1, show_contents=show_contents):\n        # print(type(d1))\n        # print(type(d2))\n        if show_contents:\n            if type(d1) in [str, int, bool] and type(d2) in [str, int, bool]:\n                if str(d1).startswith(\"data:\"):\n                    data1 = decode(str(d1))\n                else:\n                    data1 = str(d1)\n                if str(d2).startswith(\"data:\"):\n                    data2 = decode(str(d2))\n                else:\n                    data2 = str(d2)\n                # Add new line at the end if missing\n                if data1[-1:] != \"\\n\" or data2[-1:] != \"\\n\":\n                    if data1 != \"\":\n                        data1 += \"\\n\"\n                    if data2 != \"\":\n                        data2 += \"\\n\"\n                diff = \"\".join(\n                    difflib.ndiff(\n                        data1.splitlines(keepends=True), data2.splitlines(keepends=True)\n                    )\n                )\n                for x in diff.splitlines():\n                    print(\"    \" * indent + x)\n                print(\"\")\n            elif type(d1) is dict and d2 == \"\":\n                if len(d1) == 0:\n                    show_diff(\"{}\", \"\", indent)\n                for key in d1:\n                    print(\"    \" * indent + \"-> \" + key)\n                    show_diff(d1[key], \"\", indent + 1)\n            elif type(d2) is dict and d1 == \"\":\n                if len(d2) == 0:\n                    show_diff(\"\", \"{}\", indent)\n                else:\n                    for key in d2:\n                        print(\"    \" * indent + \"-> \" + key)\n                        show_diff(\"\", d2[key], indent + 1)\n\n    # Recursive function to walk through two machine-configs,\n    # and find differences between them\n    def mc_diff(d1, d2, path=[]):\n        # The two values are equal, nothing to do\n        if d1 == d2:\n            return\n        # One of the two values is None\n        elif d1 is None:\n            print(\"[+ADDED]\", \" -> \".join(path), \"\\n\")\n            show_diff(\"\", d2)\n        elif d2 is None:\n            print(\"[-REMOVED]\", \" -> \".join(path), \"\\n\")\n            show_diff(d1, \"\")\n        # The two values are string/int/bool which are not equal\n        elif (\n            (type(d1) is str and type(d2) is str)\n            or (type(d1) is int and type(d2) is int)\n            or (type(d1) is bool and type(d2) is bool)\n        ):\n            print(\"[*CHANGE]\", \" -> \".join(path), \"\\n\")\n            show_diff(str(d1), str(d2))\n        # The two values are dict which are not equal\n        elif type(d1) is dict and type(d2) is dict:\n            for k in set(list(d1.keys()) + list(d2.keys())):\n                path.append(k)\n                if k not in d2:\n                    mc_diff(d1[k], None, path)\n                elif k not in d1:\n                    mc_diff(None, d2[k])\n                else:\n                    mc_diff(d1[k], d2[k], path)\n                path.pop()\n        # The two values are lists which are not equal\n        # We need to compare the two lists with some extended logic\n        elif type(d1) is list and type(d2) is list:\n            # The two lists contain different types of data\n            ltypes = set([type(x) for x in d1 + d2])\n            if len(ltypes) != 1:\n                print(\"[WARNING] skipping inconsistent list: \", path)\n                print(\"          Found mix types in list: \", ltypes)\n                return\n\n            done_lod_keys = []\n            # Traverse on both the list items\n            for l in d1 + d2: # noqa\n                # If \"list of dict\" with kind/name/path keys,\n                # we compare based on kind/name/path keys in the dicts\n                if type(l) is dict and (\"name\" in l or \"path\" in l or \"kind\" in l):\n                    if \"kind\" in l:\n                        lod_key = \"kind\"\n                    elif \"name\" in l:\n                        lod_key = \"name\"\n                    elif \"path\" in l:\n                        lod_key = \"path\"\n                    path.append(l[lod_key])\n                    ld1 = [x for x in d1 if x[lod_key] == l[lod_key]]\n                    ld2 = [x for x in d2 if x[lod_key] == l[lod_key]]\n                    if len(ld1) > 1 and l[lod_key] not in done_lod_keys:\n                        print(\n                            \"    [WARNING] Duplicate (%i) entries found in \"\n                            \"1st MachineConfig for %s:%s\"\n                            % (len(ld1), lod_key, l[lod_key])\n                        )\n                    if len(ld2) > 1 and l[lod_key] not in done_lod_keys:\n                        print(\n                            \"    [WARNING] Duplicate (%i) entries found in \"\n                            \"2nd MachineConfig for %s:%s\"\n                            % (len(ld2), lod_key, l[lod_key])\n                        )\n\n                    if len(ld1) == 0:\n                        mc_diff(None, ld2[-1], path)\n                    elif len(ld2) == 0:\n                        mc_diff(ld1[-1], None, path)\n                    elif l[lod_key] not in done_lod_keys:\n                        mc_diff(ld1[-1], ld2[-1], path)\n                        done_lod_keys.append(l[lod_key])\n                    path.pop()\n                else:\n                    if l not in d2:\n                        mc_diff(l, None, path)\n                    if l not in d1:\n                        mc_diff(None, l, path)\n        else:\n            print(\"[WARNING] Unhandled condition at\", path)\n\n    mc_diff(mc1, mc2)\n"
  },
  {
    "path": "omg/machine_config/decode_content.py",
    "content": "from base64 import b64decode\nfrom cryptography import x509\nfrom cryptography.hazmat.backends import default_backend\nfrom urllib.parse import unquote\n\n\ndef decode(content):\n    \"\"\"\n    Decodes url/bas64 encoded content found in machine-configs\n    Certificate data is also converted to human readable format\n    \"\"\"\n    split = content.split(\",\", 1)\n    head = split[0]\n    data = split[1]\n    if head.startswith(\"data:\"):\n        if len(data) == 0:\n            return \"\"\n        form = head[5:].split(\";\")\n        if \"base64\" in form:\n            charset = next((x[8:] for x in form if x[0:8] == \"charset=\"), \"utf-8\")\n            dec_data = b64decode(data).decode(charset)\n        else:\n            dec_data = unquote(data)\n\n        if dec_data.startswith(\"-----BEGIN CERTIFICATE-----\"):\n            certs = []\n            cert = []\n            for cert_line in dec_data.splitlines():\n                if cert_line != \"-----END CERTIFICATE-----\":\n                    cert.append(cert_line)\n                else:\n                    cert.append(cert_line)\n                    certs.append(\"\\n\".join(cert))\n                    cert = []\n            dec_certs = []\n            for c in certs:\n                dec_cert = []\n                parse_cert = x509.load_pem_x509_certificate(\n                    str.encode(c), default_backend()\n                )\n                dec_cert.append(\"~~~~~BEGIN CERTIFICATE~~~~~\")\n                dec_cert.append(\"SUBJECT    : \" + parse_cert.subject.rfc4514_string())\n                dec_cert.append(\"ISSUER     : \" + parse_cert.issuer.rfc4514_string())\n                dec_cert.append(\"SERIAL     : \" + str(parse_cert.serial_number))\n                dec_cert.append(\n                    \"NOT BEFORE : \" + parse_cert.not_valid_before.isoformat()\n                )\n                dec_cert.append(\n                    \"NOT AFTER  : \" + parse_cert.not_valid_after.isoformat()\n                )\n                dec_cert.append(\"~~~~~END CERTIFICATE~~~~~\")\n                dec_certs.append(\"\\n\".join(dec_cert))\n            return \"\\n\".join(dec_certs)\n        else:\n            return dec_data\n    else:\n        print('[Warning] Unable to recognize content (not starting with \"data:\")')\n        return content\n"
  },
  {
    "path": "omg/machine_config/extract.py",
    "content": "import os\nimport yaml\nfrom loguru import logger as lg\n\nfrom omg.config import config\nfrom omg.utils.dget import dget\nfrom omg.get.get_resources import get_all_resources\nfrom omg.machine_config.decode_content import decode\n\n\ndef _write_unit(systemd_path, unit):\n    os.makedirs(systemd_path, exist_ok=True)\n    name = unit[\"name\"]\n    if \"enabled\" in unit:\n        if unit[\"enabled\"] is not True:\n            name += \".disabled\"\n    if \"content\" in unit:\n        abs_fil = os.path.join(systemd_path, name)\n        with open(abs_fil, \"w\") as fh:\n            print(abs_fil)\n            fh.write(unit[\"contents\"])\n\n\ndef _write_mc(emc_path, mc):\n    lg.debug(\"Writing MC with keys: {}\".format(mc.keys()))\n    lg.trace(\"{}\".format(mc))\n\n    mc_name = dget(mc, [\"metadata\", \"name\"])\n    mc_config = dget(mc, [\"spec\", \"config\"])\n\n    if not (mc_name and mc_config):\n        lg.warning(\"Skipping invalid MachineConfig\")\n        return\n\n    mc_path = os.path.join(emc_path, mc_name)\n    os.makedirs(mc_path, exist_ok=True)\n\n    # storage\n    storage = dget(mc, [\"spec\", \"config\", \"storage\"])\n    if storage:\n        storage_path = os.path.join(mc_path, \"storage\")\n        if \"files\" in storage:\n            for fi in storage[\"files\"]:\n                path = fi[\"path\"]\n                rel_fil = path[1:]\n                rel_dir = os.path.dirname(rel_fil)\n                abs_dir = os.path.join(storage_path, rel_dir)\n                abs_fil = os.path.join(storage_path, rel_fil)\n                os.makedirs(abs_dir, exist_ok=True)\n                with open(abs_fil, \"w\") as fh:\n                    print(abs_fil)\n                    fh.write(decode(fi[\"contents\"][\"source\"]))\n    # systemd\n    systemd_u = dget(mc, [\"spec\", \"config\", \"systemd\", \"units\"])\n    if systemd_u:\n        for unit in systemd_u:\n            dropins = dget(systemd_u, [\"dropins\"])\n            if dropins:\n                systemd_path = os.path.join(\n                    mc_path,\n                    \"systemd/\" + dget(unit, [\"name\"], \"\") + \".d\"\n                )\n                for d_unit in dropins:\n                    _write_unit(systemd_path, d_unit)\n            if dget(unit, [\"name\"]) and dget(unit, [\"contents\"]):\n                systemd_path = os.path.join(mc_path, \"systemd\")\n                _write_unit(systemd_path, unit)\n    # passwd\n    passwd = dget(mc, [\"spec\", \"config\", \"passwd\"])\n    if passwd:\n        passwd_path = os.path.join(mc_path, \"passwd\")\n        if \"users\" in passwd:\n            for user in passwd[\"users\"]:\n                os.makedirs(passwd_path, exist_ok=True)\n                name = user[\"name\"]\n                abs_fil = os.path.join(passwd_path, name)\n                with open(abs_fil, \"w\") as fh:\n                    print(abs_fil)\n                    fh.write(yaml.dump(user))\n        # TODO groups\n    # TODO networkd\n    # TODO directories, links, disks, raid, filesystems\n\n\ndef mc_extract(m):\n\n    cfg = config.get()\n    paths = cfg[\"paths\"]\n\n    if m:\n        mc_names = list(m)\n    else:\n        mc_names = []\n\n    all_mcs = get_all_resources({\"mc\": mc_names})\n\n    # {1: {\"mc\": [...]}, 2: {\"mc\": [...] }}\n    for i, mc_res in all_mcs.items():\n\n        mg_path = paths[i-1]\n        emc_path = os.path.join(mg_path, \"extracted-machine-configs\")\n\n        # {\"mc\": [{\"res\": {}, \"yfile_ts\": \"...\"}, ... ]}\n        for _, mc_data in mc_res.items():\n            if mc_data:\n                try:\n                    os.makedirs(emc_path, exist_ok=True)\n                except PermissionError as e:\n                    lg.warning(e)\n                    continue\n                for mc in mc_data:\n                    mc_rd = mc[\"res\"]\n                    _write_mc(emc_path, mc_rd)\n"
  },
  {
    "path": "omg/must_gather/RDEFS.py",
    "content": "# Built-in Resource Definitions (rdefs)\nRDEFS = [\n    {\n        \"kind\": \"Binding\",\n        \"singular\": \"binding\",\n        \"plural\": \"bindings\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"core\"\n    },\n    {\n        \"kind\": \"ComponentStatus\",\n        \"singular\": \"componentstatuse\",\n        \"plural\": \"componentstatuses\",\n        \"scope\": \"Cluster\",\n        \"shortNames\": [\"cs\"],\n        \"group\": \"core\"\n    },\n    {\n        \"kind\": \"ConfigMap\",\n        \"singular\": \"configmap\",\n        \"plural\": \"configmaps\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"cm\"],\n        \"group\": \"core\"\n    },\n    {\n        \"kind\": \"Endpoints\",\n        \"singular\": \"endpoint\",\n        \"plural\": \"endpoints\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"ep\"],\n        \"group\": \"core\"\n    },\n    {\n        \"kind\": \"Event\",\n        \"singular\": \"event\",\n        \"plural\": \"events\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"ev\"],\n        \"group\": \"core\"\n    },\n    {\n        \"kind\": \"LimitRange\",\n        \"singular\": \"limitrange\",\n        \"plural\": \"limitranges\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"limits\"],\n        \"group\": \"core\"\n    },\n    {\n        \"kind\": \"Namespace\",\n        \"singular\": \"namespace\",\n        \"plural\": \"namespaces\",\n        \"scope\": \"Cluster\",\n        \"shortNames\": [\"ns\"],\n        \"group\": \"core\"\n    },\n    {\n        \"kind\": \"Node\",\n        \"singular\": \"node\",\n        \"plural\": \"nodes\",\n        \"scope\": \"Cluster\",\n        \"shortNames\": [\"no\"],\n        \"group\": \"core\"\n    },\n    {\n        \"kind\": \"PersistentVolumeClaim\",\n        \"singular\": \"persistentvolumeclaim\",\n        \"plural\": \"persistentvolumeclaims\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"pvc\"],\n        \"group\": \"core\"\n    },\n    {\n        \"kind\": \"PersistentVolume\",\n        \"singular\": \"persistentvolume\",\n        \"plural\": \"persistentvolumes\",\n        \"scope\": \"Cluster\",\n        \"shortNames\": [\"pv\"],\n        \"group\": \"core\"\n    },\n    {\n        \"kind\": \"Pod\",\n        \"singular\": \"pod\",\n        \"plural\": \"pods\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"po\"],\n        \"group\": \"core\"\n    },\n    {\n        \"kind\": \"PodTemplate\",\n        \"singular\": \"podtemplate\",\n        \"plural\": \"podtemplates\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"core\"\n    },\n    {\n        \"kind\": \"ReplicationController\",\n        \"singular\": \"replicationcontroller\",\n        \"plural\": \"replicationcontrollers\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"rc\"],\n        \"group\": \"core\"\n    },\n    {\n        \"kind\": \"ResourceQuota\",\n        \"singular\": \"resourcequota\",\n        \"plural\": \"resourcequotas\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"quota\"],\n        \"group\": \"core\"\n    },\n    {\n        \"kind\": \"Secret\",\n        \"singular\": \"secret\",\n        \"plural\": \"secrets\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"core\"\n    },\n    {\n        \"kind\": \"ServiceAccount\",\n        \"singular\": \"serviceaccount\",\n        \"plural\": \"serviceaccounts\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"sa\"],\n        \"group\": \"core\"\n    },\n    {\n        \"kind\": \"Service\",\n        \"singular\": \"service\",\n        \"plural\": \"services\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"svc\"],\n        \"group\": \"core\"\n    },\n    {\n        \"kind\": \"MutatingWebhookConfiguration\",\n        \"singular\": \"mutatingwebhookconfiguration\",\n        \"plural\": \"mutatingwebhookconfigurations\",\n        \"scope\": \"Cluster\",\n        \"group\": \"admissionregistration.k8s.io\"\n    },\n    {\n        \"kind\": \"ValidatingWebhookConfiguration\",\n        \"singular\": \"validatingwebhookconfiguration\",\n        \"plural\": \"validatingwebhookconfigurations\",\n        \"scope\": \"Cluster\",\n        \"group\": \"admissionregistration.k8s.io\"\n    },\n    {\n        \"kind\": \"CustomResourceDefinition\",\n        \"singular\": \"customresourcedefinition\",\n        \"plural\": \"customresourcedefinitions\",\n        \"scope\": \"Cluster\",\n        \"shortNames\": [\"crd\", \"crds\"],\n        \"group\": \"apiextensions.k8s.io\"\n    },\n    {\n        \"kind\": \"APIService\",\n        \"singular\": \"apiservice\",\n        \"plural\": \"apiservices\",\n        \"scope\": \"Cluster\",\n        \"group\": \"apiregistration.k8s.io\"\n    },\n    {\n        \"kind\": \"APIRequestCount\",\n        \"singular\": \"apirequestcount\",\n        \"plural\": \"apirequestcounts\",\n        \"scope\": \"Cluster\",\n        \"group\": \"apiserver.openshift.io\"\n    },\n    {\n        \"kind\": \"ControllerRevision\",\n        \"singular\": \"controllerrevision\",\n        \"plural\": \"controllerrevisions\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"apps\"\n    },\n    {\n        \"kind\": \"DaemonSet\",\n        \"singular\": \"daemonset\",\n        \"plural\": \"daemonsets\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"ds\"],\n        \"group\": \"apps\"\n    },\n    {\n        \"kind\": \"Deployment\",\n        \"singular\": \"deployment\",\n        \"plural\": \"deployments\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"deploy\"],\n        \"group\": \"apps\"\n    },\n    {\n        \"kind\": \"ReplicaSet\",\n        \"singular\": \"replicaset\",\n        \"plural\": \"replicasets\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"rs\"],\n        \"group\": \"apps\"\n    },\n    {\n        \"kind\": \"StatefulSet\",\n        \"singular\": \"statefulset\",\n        \"plural\": \"statefulsets\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"sts\"],\n        \"group\": \"apps\"\n    },\n    {\n        \"kind\": \"DeploymentConfig\",\n        \"singular\": \"deploymentconfig\",\n        \"plural\": \"deploymentconfigs\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"dc\"],\n        \"group\": \"apps.openshift.io\"\n    },\n    {\n        \"kind\": \"TokenReview\",\n        \"singular\": \"tokenreview\",\n        \"plural\": \"tokenreviews\",\n        \"scope\": \"Cluster\",\n        \"group\": \"authentication.k8s.io\"\n    },\n    {\n        \"kind\": \"LocalSubjectAccessReview\",\n        \"singular\": \"localsubjectaccessreview\",\n        \"plural\": \"localsubjectaccessreviews\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"authorization.k8s.io\"\n    },\n    {\n        \"kind\": \"SelfSubjectAccessReview\",\n        \"singular\": \"selfsubjectaccessreview\",\n        \"plural\": \"selfsubjectaccessreviews\",\n        \"scope\": \"Cluster\",\n        \"group\": \"authorization.k8s.io\"\n    },\n    {\n        \"kind\": \"SelfSubjectRulesReview\",\n        \"singular\": \"selfsubjectrulesreview\",\n        \"plural\": \"selfsubjectrulesreviews\",\n        \"scope\": \"Cluster\",\n        \"group\": \"authorization.k8s.io\"\n    },\n    {\n        \"kind\": \"SubjectAccessReview\",\n        \"singular\": \"subjectaccessreview\",\n        \"plural\": \"subjectaccessreviews\",\n        \"scope\": \"Cluster\",\n        \"group\": \"authorization.k8s.io\"\n    },\n    {\n        \"kind\": \"ClusterRoleBinding\",\n        \"singular\": \"clusterrolebinding\",\n        \"plural\": \"clusterrolebindings\",\n        \"scope\": \"Cluster\",\n        \"group\": \"authorization.openshift.io\"\n    },\n    {\n        \"kind\": \"ClusterRole\",\n        \"singular\": \"clusterrole\",\n        \"plural\": \"clusterroles\",\n        \"scope\": \"Cluster\",\n        \"group\": \"authorization.openshift.io\"\n    },\n    {\n        \"kind\": \"LocalResourceAccessReview\",\n        \"singular\": \"localresourceaccessreview\",\n        \"plural\": \"localresourceaccessreviews\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"authorization.openshift.io\"\n    },\n    {\n        \"kind\": \"LocalSubjectAccessReview\",\n        \"singular\": \"localsubjectaccessreview\",\n        \"plural\": \"localsubjectaccessreviews\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"authorization.openshift.io\"\n    },\n    {\n        \"kind\": \"ResourceAccessReview\",\n        \"singular\": \"resourceaccessreview\",\n        \"plural\": \"resourceaccessreviews\",\n        \"scope\": \"Cluster\",\n        \"group\": \"authorization.openshift.io\"\n    },\n    {\n        \"kind\": \"RoleBindingRestriction\",\n        \"singular\": \"rolebindingrestriction\",\n        \"plural\": \"rolebindingrestrictions\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"authorization.openshift.io\"\n    },\n    {\n        \"kind\": \"RoleBinding\",\n        \"singular\": \"rolebinding\",\n        \"plural\": \"rolebindings\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"authorization.openshift.io\"\n    },\n    {\n        \"kind\": \"Role\",\n        \"singular\": \"role\",\n        \"plural\": \"roles\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"authorization.openshift.io\"\n    },\n    {\n        \"kind\": \"SelfSubjectRulesReview\",\n        \"singular\": \"selfsubjectrulesreview\",\n        \"plural\": \"selfsubjectrulesreviews\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"authorization.openshift.io\"\n    },\n    {\n        \"kind\": \"SubjectAccessReview\",\n        \"singular\": \"subjectaccessreview\",\n        \"plural\": \"subjectaccessreviews\",\n        \"scope\": \"Cluster\",\n        \"group\": \"authorization.openshift.io\"\n    },\n    {\n        \"kind\": \"SubjectRulesReview\",\n        \"singular\": \"subjectrulesreview\",\n        \"plural\": \"subjectrulesreviews\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"authorization.openshift.io\"\n    },\n    {\n        \"kind\": \"HorizontalPodAutoscaler\",\n        \"singular\": \"horizontalpodautoscaler\",\n        \"plural\": \"horizontalpodautoscalers\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"hpa\"],\n        \"group\": \"autoscaling\"\n    },\n    {\n        \"kind\": \"ClusterAutoscaler\",\n        \"singular\": \"clusterautoscaler\",\n        \"plural\": \"clusterautoscalers\",\n        \"scope\": \"Cluster\",\n        \"shortNames\": [\"ca\"],\n        \"group\": \"autoscaling.openshift.io\"\n    },\n    {\n        \"kind\": \"MachineAutoscaler\",\n        \"singular\": \"machineautoscaler\",\n        \"plural\": \"machineautoscalers\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"ma\"],\n        \"group\": \"autoscaling.openshift.io\"\n    },\n    {\n        \"kind\": \"CronJob\",\n        \"singular\": \"cronjob\",\n        \"plural\": \"cronjobs\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"cj\"],\n        \"group\": \"batch\"\n    },\n    {\n        \"kind\": \"Job\",\n        \"singular\": \"job\",\n        \"plural\": \"jobs\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"batch\"\n    },\n    {\n        \"kind\": \"BuildConfig\",\n        \"singular\": \"buildconfig\",\n        \"plural\": \"buildconfigs\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"bc\"],\n        \"group\": \"build.openshift.io\"\n    },\n    {\n        \"kind\": \"Build\",\n        \"singular\": \"build\",\n        \"plural\": \"builds\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"build.openshift.io\"\n    },\n    {\n        \"kind\": \"CertificateSigningRequest\",\n        \"singular\": \"certificatesigningrequest\",\n        \"plural\": \"certificatesigningrequests\",\n        \"scope\": \"Cluster\",\n        \"shortNames\": [\"csr\"],\n        \"group\": \"certificates.k8s.io\"\n    },\n    {\n        \"kind\": \"CredentialsRequest\",\n        \"singular\": \"credentialsrequest\",\n        \"plural\": \"credentialsrequests\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"cloudcredential.openshift.io\"\n    },\n    {\n        \"kind\": \"APIServer\",\n        \"singular\": \"apiserver\",\n        \"plural\": \"apiservers\",\n        \"scope\": \"Cluster\",\n        \"group\": \"config.openshift.io\"\n    },\n    {\n        \"kind\": \"Authentication\",\n        \"singular\": \"authentication\",\n        \"plural\": \"authentications\",\n        \"scope\": \"Cluster\",\n        \"group\": \"config.openshift.io\"\n    },\n    {\n        \"kind\": \"Build\",\n        \"singular\": \"build\",\n        \"plural\": \"builds\",\n        \"scope\": \"Cluster\",\n        \"group\": \"config.openshift.io\"\n    },\n    {\n        \"kind\": \"ClusterOperator\",\n        \"singular\": \"clusteroperator\",\n        \"plural\": \"clusteroperators\",\n        \"scope\": \"Cluster\",\n        \"shortNames\": [\"co\"],\n        \"group\": \"config.openshift.io\"\n    },\n    {\n        \"kind\": \"ClusterVersion\",\n        \"singular\": \"clusterversion\",\n        \"plural\": \"clusterversions\",\n        \"scope\": \"Cluster\",\n        \"group\": \"config.openshift.io\"\n    },\n    {\n        \"kind\": \"Console\",\n        \"singular\": \"console\",\n        \"plural\": \"consoles\",\n        \"scope\": \"Cluster\",\n        \"group\": \"config.openshift.io\"\n    },\n    {\n        \"kind\": \"DNS\",\n        \"singular\": \"dnse\",\n        \"plural\": \"dnses\",\n        \"scope\": \"Cluster\",\n        \"group\": \"config.openshift.io\"\n    },\n    {\n        \"kind\": \"FeatureGate\",\n        \"singular\": \"featuregate\",\n        \"plural\": \"featuregates\",\n        \"scope\": \"Cluster\",\n        \"group\": \"config.openshift.io\"\n    },\n    {\n        \"kind\": \"Image\",\n        \"singular\": \"image\",\n        \"plural\": \"images\",\n        \"scope\": \"Cluster\",\n        \"group\": \"config.openshift.io\"\n    },\n    {\n        \"kind\": \"Infrastructure\",\n        \"singular\": \"infrastructure\",\n        \"plural\": \"infrastructures\",\n        \"scope\": \"Cluster\",\n        \"group\": \"config.openshift.io\"\n    },\n    {\n        \"kind\": \"Ingress\",\n        \"singular\": \"ingresse\",\n        \"plural\": \"ingresses\",\n        \"scope\": \"Cluster\",\n        \"group\": \"config.openshift.io\"\n    },\n    {\n        \"kind\": \"Network\",\n        \"singular\": \"network\",\n        \"plural\": \"networks\",\n        \"scope\": \"Cluster\",\n        \"group\": \"config.openshift.io\"\n    },\n    {\n        \"kind\": \"OAuth\",\n        \"singular\": \"oauth\",\n        \"plural\": \"oauths\",\n        \"scope\": \"Cluster\",\n        \"group\": \"config.openshift.io\"\n    },\n    {\n        \"kind\": \"OperatorHub\",\n        \"singular\": \"operatorhub\",\n        \"plural\": \"operatorhubs\",\n        \"scope\": \"Cluster\",\n        \"group\": \"config.openshift.io\"\n    },\n    {\n        \"kind\": \"Project\",\n        \"singular\": \"project\",\n        \"plural\": \"projects\",\n        \"scope\": \"Cluster\",\n        \"group\": \"config.openshift.io\"\n    },\n    {\n        \"kind\": \"Proxy\",\n        \"singular\": \"proxie\",\n        \"plural\": \"proxies\",\n        \"scope\": \"Cluster\",\n        \"group\": \"config.openshift.io\"\n    },\n    {\n        \"kind\": \"Scheduler\",\n        \"singular\": \"scheduler\",\n        \"plural\": \"schedulers\",\n        \"scope\": \"Cluster\",\n        \"group\": \"config.openshift.io\"\n    },\n    {\n        \"kind\": \"ConsoleCLIDownload\",\n        \"singular\": \"consoleclidownload\",\n        \"plural\": \"consoleclidownloads\",\n        \"scope\": \"Cluster\",\n        \"group\": \"console.openshift.io\"\n    },\n    {\n        \"kind\": \"ConsoleExternalLogLink\",\n        \"singular\": \"consoleexternalloglink\",\n        \"plural\": \"consoleexternalloglinks\",\n        \"scope\": \"Cluster\",\n        \"group\": \"console.openshift.io\"\n    },\n    {\n        \"kind\": \"ConsoleLink\",\n        \"singular\": \"consolelink\",\n        \"plural\": \"consolelinks\",\n        \"scope\": \"Cluster\",\n        \"group\": \"console.openshift.io\"\n    },\n    {\n        \"kind\": \"ConsoleNotification\",\n        \"singular\": \"consolenotification\",\n        \"plural\": \"consolenotifications\",\n        \"scope\": \"Cluster\",\n        \"group\": \"console.openshift.io\"\n    },\n    {\n        \"kind\": \"ConsolePlugin\",\n        \"singular\": \"consoleplugin\",\n        \"plural\": \"consoleplugins\",\n        \"scope\": \"Cluster\",\n        \"group\": \"console.openshift.io\"\n    },\n    {\n        \"kind\": \"ConsoleQuickStart\",\n        \"singular\": \"consolequickstart\",\n        \"plural\": \"consolequickstarts\",\n        \"scope\": \"Cluster\",\n        \"group\": \"console.openshift.io\"\n    },\n    {\n        \"kind\": \"ConsoleYAMLSample\",\n        \"singular\": \"consoleyamlsample\",\n        \"plural\": \"consoleyamlsamples\",\n        \"scope\": \"Cluster\",\n        \"group\": \"console.openshift.io\"\n    },\n    {\n        \"kind\": \"PodNetworkConnectivityCheck\",\n        \"singular\": \"podnetworkconnectivitycheck\",\n        \"plural\": \"podnetworkconnectivitychecks\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"controlplane.operator.openshift.io\"\n    },\n    {\n        \"kind\": \"Lease\",\n        \"singular\": \"lease\",\n        \"plural\": \"leases\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"coordination.k8s.io\"\n    },\n    {\n        \"kind\": \"EndpointSlice\",\n        \"singular\": \"endpointslice\",\n        \"plural\": \"endpointslices\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"discovery.k8s.io\"\n    },\n    {\n        \"kind\": \"Event\",\n        \"singular\": \"event\",\n        \"plural\": \"events\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"ev\"],\n        \"group\": \"events.k8s.io\"\n    },\n    {\n        \"kind\": \"Ingress\",\n        \"singular\": \"ingresse\",\n        \"plural\": \"ingresses\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"ing\"],\n        \"group\": \"extensions\"\n    },\n    {\n        \"kind\": \"FlowSchema\",\n        \"singular\": \"flowschema\",\n        \"plural\": \"flowschemas\",\n        \"scope\": \"Cluster\",\n        \"group\": \"flowcontrol.apiserver.k8s.io\"\n    },\n    {\n        \"kind\": \"PriorityLevelConfiguration\",\n        \"singular\": \"prioritylevelconfiguration\",\n        \"plural\": \"prioritylevelconfigurations\",\n        \"scope\": \"Cluster\",\n        \"group\": \"flowcontrol.apiserver.k8s.io\"\n    },\n    {\n        \"kind\": \"HelmChartRepository\",\n        \"singular\": \"helmchartrepositorie\",\n        \"plural\": \"helmchartrepositories\",\n        \"scope\": \"Cluster\",\n        \"group\": \"helm.openshift.io\"\n    },\n    {\n        \"kind\": \"Image\",\n        \"singular\": \"image\",\n        \"plural\": \"images\",\n        \"scope\": \"Cluster\",\n        \"group\": \"image.openshift.io\"\n    },\n    {\n        \"kind\": \"ImageSignature\",\n        \"singular\": \"imagesignature\",\n        \"plural\": \"imagesignatures\",\n        \"scope\": \"Cluster\",\n        \"group\": \"image.openshift.io\"\n    },\n    {\n        \"kind\": \"ImageStreamImage\",\n        \"singular\": \"imagestreamimage\",\n        \"plural\": \"imagestreamimages\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"isimage\"],\n        \"group\": \"image.openshift.io\"\n    },\n    {\n        \"kind\": \"ImageStreamImport\",\n        \"singular\": \"imagestreamimport\",\n        \"plural\": \"imagestreamimports\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"image.openshift.io\"\n    },\n    {\n        \"kind\": \"ImageStreamMapping\",\n        \"singular\": \"imagestreammapping\",\n        \"plural\": \"imagestreammappings\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"image.openshift.io\"\n    },\n    {\n        \"kind\": \"ImageStream\",\n        \"singular\": \"imagestream\",\n        \"plural\": \"imagestreams\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"is\"],\n        \"group\": \"image.openshift.io\"\n    },\n    {\n        \"kind\": \"ImageStreamTag\",\n        \"singular\": \"imagestreamtag\",\n        \"plural\": \"imagestreamtags\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"istag\"],\n        \"group\": \"image.openshift.io\"\n    },\n    {\n        \"kind\": \"ImageTag\",\n        \"singular\": \"imagetag\",\n        \"plural\": \"imagetags\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"itag\"],\n        \"group\": \"image.openshift.io\"\n    },\n    {\n        \"kind\": \"Config\",\n        \"singular\": \"config\",\n        \"plural\": \"configs\",\n        \"scope\": \"Cluster\",\n        \"group\": \"imageregistry.operator.openshift.io\"\n    },\n    {\n        \"kind\": \"ImagePruner\",\n        \"singular\": \"imagepruner\",\n        \"plural\": \"imagepruners\",\n        \"scope\": \"Cluster\",\n        \"group\": \"imageregistry.operator.openshift.io\"\n    },\n    {\n        \"kind\": \"DNSRecord\",\n        \"singular\": \"dnsrecord\",\n        \"plural\": \"dnsrecords\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"ingress.operator.openshift.io\"\n    },\n    {\n        \"kind\": \"NetworkAttachmentDefinition\",\n        \"singular\": \"network-attachment-definition\",\n        \"plural\": \"network-attachment-definitions\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"net-attach-def\"],\n        \"group\": \"k8s.cni.cncf.io\"\n    },\n    {\n        \"kind\": \"MachineHealthCheck\",\n        \"singular\": \"machinehealthcheck\",\n        \"plural\": \"machinehealthchecks\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"mhc\", \"mhcs\"],\n        \"group\": \"machine.openshift.io\"\n    },\n    {\n        \"kind\": \"Machine\",\n        \"singular\": \"machine\",\n        \"plural\": \"machines\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"machine.openshift.io\"\n    },\n    {\n        \"kind\": \"MachineSet\",\n        \"singular\": \"machineset\",\n        \"plural\": \"machinesets\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"machine.openshift.io\"\n    },\n    {\n        \"kind\": \"ContainerRuntimeConfig\",\n        \"singular\": \"containerruntimeconfig\",\n        \"plural\": \"containerruntimeconfigs\",\n        \"scope\": \"Cluster\",\n        \"shortNames\": [\"ctrcfg\"],\n        \"group\": \"machineconfiguration.openshift.io\"\n    },\n    {\n        \"kind\": \"ControllerConfig\",\n        \"singular\": \"controllerconfig\",\n        \"plural\": \"controllerconfigs\",\n        \"scope\": \"Cluster\",\n        \"group\": \"machineconfiguration.openshift.io\"\n    },\n    {\n        \"kind\": \"KubeletConfig\",\n        \"singular\": \"kubeletconfig\",\n        \"plural\": \"kubeletconfigs\",\n        \"scope\": \"Cluster\",\n        \"group\": \"machineconfiguration.openshift.io\"\n    },\n    {\n        \"kind\": \"MachineConfigPool\",\n        \"singular\": \"machineconfigpool\",\n        \"plural\": \"machineconfigpools\",\n        \"scope\": \"Cluster\",\n        \"shortNames\": [\"mcp\"],\n        \"group\": \"machineconfiguration.openshift.io\"\n    },\n    {\n        \"kind\": \"MachineConfig\",\n        \"singular\": \"machineconfig\",\n        \"plural\": \"machineconfigs\",\n        \"scope\": \"Cluster\",\n        \"shortNames\": [\"mc\"],\n        \"group\": \"machineconfiguration.openshift.io\"\n    },\n    {\n        \"kind\": \"BareMetalHost\",\n        \"singular\": \"baremetalhost\",\n        \"plural\": \"baremetalhosts\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"bmh\", \"bmhost\"],\n        \"group\": \"metal3.io\"\n    },\n    {\n        \"kind\": \"Provisioning\",\n        \"singular\": \"provisioning\",\n        \"plural\": \"provisionings\",\n        \"scope\": \"Cluster\",\n        \"group\": \"metal3.io\"\n    },\n    {\n        \"kind\": \"NodeMetrics\",\n        \"singular\": \"node\",\n        \"plural\": \"nodes\",\n        \"scope\": \"Cluster\",\n        \"group\": \"metrics.k8s.io\"\n    },\n    {\n        \"kind\": \"PodMetrics\",\n        \"singular\": \"pod\",\n        \"plural\": \"pods\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"metrics.k8s.io\"\n    },\n    {\n        \"kind\": \"StorageState\",\n        \"singular\": \"storagestate\",\n        \"plural\": \"storagestates\",\n        \"scope\": \"Cluster\",\n        \"group\": \"migration.k8s.io\"\n    },\n    {\n        \"kind\": \"StorageVersionMigration\",\n        \"singular\": \"storageversionmigration\",\n        \"plural\": \"storageversionmigrations\",\n        \"scope\": \"Cluster\",\n        \"group\": \"migration.k8s.io\"\n    },\n    {\n        \"kind\": \"AlertmanagerConfig\",\n        \"singular\": \"alertmanagerconfig\",\n        \"plural\": \"alertmanagerconfigs\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"monitoring.coreos.com\"\n    },\n    {\n        \"kind\": \"Alertmanager\",\n        \"singular\": \"alertmanager\",\n        \"plural\": \"alertmanagers\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"monitoring.coreos.com\"\n    },\n    {\n        \"kind\": \"PodMonitor\",\n        \"singular\": \"podmonitor\",\n        \"plural\": \"podmonitors\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"monitoring.coreos.com\"\n    },\n    {\n        \"kind\": \"Probe\",\n        \"singular\": \"probe\",\n        \"plural\": \"probes\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"monitoring.coreos.com\"\n    },\n    {\n        \"kind\": \"Prometheus\",\n        \"singular\": \"prometheuse\",\n        \"plural\": \"prometheuses\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"monitoring.coreos.com\"\n    },\n    {\n        \"kind\": \"PrometheusRule\",\n        \"singular\": \"prometheusrule\",\n        \"plural\": \"prometheusrules\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"monitoring.coreos.com\"\n    },\n    {\n        \"kind\": \"ServiceMonitor\",\n        \"singular\": \"servicemonitor\",\n        \"plural\": \"servicemonitors\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"monitoring.coreos.com\"\n    },\n    {\n        \"kind\": \"ThanosRuler\",\n        \"singular\": \"thanosruler\",\n        \"plural\": \"thanosrulers\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"monitoring.coreos.com\"\n    },\n    {\n        \"kind\": \"ClusterNetwork\",\n        \"singular\": \"clusternetwork\",\n        \"plural\": \"clusternetworks\",\n        \"scope\": \"Cluster\",\n        \"group\": \"network.openshift.io\"\n    },\n    {\n        \"kind\": \"EgressNetworkPolicy\",\n        \"singular\": \"egressnetworkpolicie\",\n        \"plural\": \"egressnetworkpolicies\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"network.openshift.io\"\n    },\n    {\n        \"kind\": \"HostSubnet\",\n        \"singular\": \"hostsubnet\",\n        \"plural\": \"hostsubnets\",\n        \"scope\": \"Cluster\",\n        \"group\": \"network.openshift.io\"\n    },\n    {\n        \"kind\": \"NetNamespace\",\n        \"singular\": \"netnamespace\",\n        \"plural\": \"netnamespaces\",\n        \"scope\": \"Cluster\",\n        \"group\": \"network.openshift.io\"\n    },\n    {\n        \"kind\": \"EgressRouter\",\n        \"singular\": \"egressrouter\",\n        \"plural\": \"egressrouters\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"network.operator.openshift.io\"\n    },\n    {\n        \"kind\": \"OperatorPKI\",\n        \"singular\": \"operatorpki\",\n        \"plural\": \"operatorpkis\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"network.operator.openshift.io\"\n    },\n    {\n        \"kind\": \"IngressClass\",\n        \"singular\": \"ingressclasse\",\n        \"plural\": \"ingressclasses\",\n        \"scope\": \"Cluster\",\n        \"group\": \"networking.k8s.io\"\n    },\n    {\n        \"kind\": \"Ingress\",\n        \"singular\": \"ingresse\",\n        \"plural\": \"ingresses\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"ing\"],\n        \"group\": \"networking.k8s.io\"\n    },\n    {\n        \"kind\": \"NetworkPolicy\",\n        \"singular\": \"networkpolicie\",\n        \"plural\": \"networkpolicies\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"netpol\"],\n        \"group\": \"networking.k8s.io\"\n    },\n    {\n        \"kind\": \"RuntimeClass\",\n        \"singular\": \"runtimeclasse\",\n        \"plural\": \"runtimeclasses\",\n        \"scope\": \"Cluster\",\n        \"group\": \"node.k8s.io\"\n    },\n    {\n        \"kind\": \"OAuthAccessToken\",\n        \"singular\": \"oauthaccesstoken\",\n        \"plural\": \"oauthaccesstokens\",\n        \"scope\": \"Cluster\",\n        \"group\": \"oauth.openshift.io\"\n    },\n    {\n        \"kind\": \"OAuthAuthorizeToken\",\n        \"singular\": \"oauthauthorizetoken\",\n        \"plural\": \"oauthauthorizetokens\",\n        \"scope\": \"Cluster\",\n        \"group\": \"oauth.openshift.io\"\n    },\n    {\n        \"kind\": \"OAuthClientAuthorization\",\n        \"singular\": \"oauthclientauthorization\",\n        \"plural\": \"oauthclientauthorizations\",\n        \"scope\": \"Cluster\",\n        \"group\": \"oauth.openshift.io\"\n    },\n    {\n        \"kind\": \"OAuthClient\",\n        \"singular\": \"oauthclient\",\n        \"plural\": \"oauthclients\",\n        \"scope\": \"Cluster\",\n        \"group\": \"oauth.openshift.io\"\n    },\n    {\n        \"kind\": \"TokenReview\",\n        \"singular\": \"tokenreview\",\n        \"plural\": \"tokenreviews\",\n        \"scope\": \"Cluster\",\n        \"group\": \"oauth.openshift.io\"\n    },\n    {\n        \"kind\": \"UserOAuthAccessToken\",\n        \"singular\": \"useroauthaccesstoken\",\n        \"plural\": \"useroauthaccesstokens\",\n        \"scope\": \"Cluster\",\n        \"group\": \"oauth.openshift.io\"\n    },\n    {\n        \"kind\": \"Authentication\",\n        \"singular\": \"authentication\",\n        \"plural\": \"authentications\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"CloudCredential\",\n        \"singular\": \"cloudcredential\",\n        \"plural\": \"cloudcredentials\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"ClusterCSIDriver\",\n        \"singular\": \"clustercsidriver\",\n        \"plural\": \"clustercsidrivers\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"Config\",\n        \"singular\": \"config\",\n        \"plural\": \"configs\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"Console\",\n        \"singular\": \"console\",\n        \"plural\": \"consoles\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"CSISnapshotController\",\n        \"singular\": \"csisnapshotcontroller\",\n        \"plural\": \"csisnapshotcontrollers\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"DNS\",\n        \"singular\": \"dnse\",\n        \"plural\": \"dnses\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"Etcd\",\n        \"singular\": \"etcd\",\n        \"plural\": \"etcds\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"ImageContentSourcePolicy\",\n        \"singular\": \"imagecontentsourcepolicie\",\n        \"plural\": \"imagecontentsourcepolicies\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"IngressController\",\n        \"singular\": \"ingresscontroller\",\n        \"plural\": \"ingresscontrollers\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"KubeAPIServer\",\n        \"singular\": \"kubeapiserver\",\n        \"plural\": \"kubeapiservers\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"KubeControllerManager\",\n        \"singular\": \"kubecontrollermanager\",\n        \"plural\": \"kubecontrollermanagers\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"KubeScheduler\",\n        \"singular\": \"kubescheduler\",\n        \"plural\": \"kubeschedulers\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"KubeStorageVersionMigrator\",\n        \"singular\": \"kubestorageversionmigrator\",\n        \"plural\": \"kubestorageversionmigrators\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"Network\",\n        \"singular\": \"network\",\n        \"plural\": \"networks\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"OpenShiftAPIServer\",\n        \"singular\": \"openshiftapiserver\",\n        \"plural\": \"openshiftapiservers\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"OpenShiftControllerManager\",\n        \"singular\": \"openshiftcontrollermanager\",\n        \"plural\": \"openshiftcontrollermanagers\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"ServiceCA\",\n        \"singular\": \"serviceca\",\n        \"plural\": \"servicecas\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"Storage\",\n        \"singular\": \"storage\",\n        \"plural\": \"storages\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operator.openshift.io\"\n    },\n    {\n        \"kind\": \"CatalogSource\",\n        \"singular\": \"catalogsource\",\n        \"plural\": \"catalogsources\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"catsrc\"],\n        \"group\": \"operators.coreos.com\"\n    },\n    {\n        \"kind\": \"ClusterServiceVersion\",\n        \"singular\": \"clusterserviceversion\",\n        \"plural\": \"clusterserviceversions\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"csv\", \"csvs\"],\n        \"group\": \"operators.coreos.com\"\n    },\n    {\n        \"kind\": \"InstallPlan\",\n        \"singular\": \"installplan\",\n        \"plural\": \"installplans\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"ip\"],\n        \"group\": \"operators.coreos.com\"\n    },\n    {\n        \"kind\": \"OperatorCondition\",\n        \"singular\": \"operatorcondition\",\n        \"plural\": \"operatorconditions\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"condition\"],\n        \"group\": \"operators.coreos.com\"\n    },\n    {\n        \"kind\": \"OperatorGroup\",\n        \"singular\": \"operatorgroup\",\n        \"plural\": \"operatorgroups\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"og\"],\n        \"group\": \"operators.coreos.com\"\n    },\n    {\n        \"kind\": \"Operator\",\n        \"singular\": \"operator\",\n        \"plural\": \"operators\",\n        \"scope\": \"Cluster\",\n        \"group\": \"operators.coreos.com\"\n    },\n    {\n        \"kind\": \"Subscription\",\n        \"singular\": \"subscription\",\n        \"plural\": \"subscriptions\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"sub\", \"subs\"],\n        \"group\": \"operators.coreos.com\"\n    },\n    {\n        \"kind\": \"PackageManifest\",\n        \"singular\": \"packagemanifest\",\n        \"plural\": \"packagemanifests\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"packages.operators.coreos.com\"\n    },\n    {\n        \"kind\": \"PodDisruptionBudget\",\n        \"singular\": \"poddisruptionbudget\",\n        \"plural\": \"poddisruptionbudgets\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"pdb\"],\n        \"group\": \"policy\"\n    },\n    {\n        \"kind\": \"PodSecurityPolicy\",\n        \"singular\": \"podsecuritypolicie\",\n        \"plural\": \"podsecuritypolicies\",\n        \"scope\": \"Cluster\",\n        \"shortNames\": [\"psp\"],\n        \"group\": \"policy\"\n    },\n    {\n        \"kind\": \"ProjectRequest\",\n        \"singular\": \"projectrequest\",\n        \"plural\": \"projectrequests\",\n        \"scope\": \"Cluster\",\n        \"group\": \"project.openshift.io\"\n    },\n    {\n        \"kind\": \"Project\",\n        \"singular\": \"project\",\n        \"plural\": \"projects\",\n        \"scope\": \"Cluster\",\n        \"group\": \"project.openshift.io\"\n    },\n    {\n        \"kind\": \"AppliedClusterResourceQuota\",\n        \"singular\": \"appliedclusterresourcequota\",\n        \"plural\": \"appliedclusterresourcequotas\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"quota.openshift.io\"\n    },\n    {\n        \"kind\": \"ClusterResourceQuota\",\n        \"singular\": \"clusterresourcequota\",\n        \"plural\": \"clusterresourcequotas\",\n        \"scope\": \"Cluster\",\n        \"shortNames\": [\"clusterquota\"],\n        \"group\": \"quota.openshift.io\"\n    },\n    {\n        \"kind\": \"ClusterRoleBinding\",\n        \"singular\": \"clusterrolebinding\",\n        \"plural\": \"clusterrolebindings\",\n        \"scope\": \"Cluster\",\n        \"group\": \"rbac.authorization.k8s.io\"\n    },\n    {\n        \"kind\": \"ClusterRole\",\n        \"singular\": \"clusterrole\",\n        \"plural\": \"clusterroles\",\n        \"scope\": \"Cluster\",\n        \"group\": \"rbac.authorization.k8s.io\"\n    },\n    {\n        \"kind\": \"RoleBinding\",\n        \"singular\": \"rolebinding\",\n        \"plural\": \"rolebindings\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"rbac.authorization.k8s.io\"\n    },\n    {\n        \"kind\": \"Role\",\n        \"singular\": \"role\",\n        \"plural\": \"roles\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"rbac.authorization.k8s.io\"\n    },\n    {\n        \"kind\": \"Route\",\n        \"singular\": \"route\",\n        \"plural\": \"routes\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"route.openshift.io\"\n    },\n    {\n        \"kind\": \"Config\",\n        \"singular\": \"config\",\n        \"plural\": \"configs\",\n        \"scope\": \"Cluster\",\n        \"group\": \"samples.operator.openshift.io\"\n    },\n    {\n        \"kind\": \"PriorityClass\",\n        \"singular\": \"priorityclasse\",\n        \"plural\": \"priorityclasses\",\n        \"scope\": \"Cluster\",\n        \"shortNames\": [\"pc\"],\n        \"group\": \"scheduling.k8s.io\"\n    },\n    {\n        \"kind\": \"RangeAllocation\",\n        \"singular\": \"rangeallocation\",\n        \"plural\": \"rangeallocations\",\n        \"scope\": \"Cluster\",\n        \"group\": \"security.internal.openshift.io\"\n    },\n    {\n        \"kind\": \"PodSecurityPolicyReview\",\n        \"singular\": \"podsecuritypolicyreview\",\n        \"plural\": \"podsecuritypolicyreviews\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"security.openshift.io\"\n    },\n    {\n        \"kind\": \"PodSecurityPolicySelfSubjectReview\",\n        \"singular\": \"podsecuritypolicyselfsubjectreview\",\n        \"plural\": \"podsecuritypolicyselfsubjectreviews\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"security.openshift.io\"\n    },\n    {\n        \"kind\": \"PodSecurityPolicySubjectReview\",\n        \"singular\": \"podsecuritypolicysubjectreview\",\n        \"plural\": \"podsecuritypolicysubjectreviews\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"security.openshift.io\"\n    },\n    {\n        \"kind\": \"RangeAllocation\",\n        \"singular\": \"rangeallocation\",\n        \"plural\": \"rangeallocations\",\n        \"scope\": \"Cluster\",\n        \"group\": \"security.openshift.io\"\n    },\n    {\n        \"kind\": \"SecurityContextConstraints\",\n        \"singular\": \"securitycontextconstraint\",\n        \"plural\": \"securitycontextconstraints\",\n        \"scope\": \"Cluster\",\n        \"shortNames\": [\"scc\"],\n        \"group\": \"security.openshift.io\"\n    },\n    {\n        \"kind\": \"VolumeSnapshotClass\",\n        \"singular\": \"volumesnapshotclasse\",\n        \"plural\": \"volumesnapshotclasses\",\n        \"scope\": \"Cluster\",\n        \"group\": \"snapshot.storage.k8s.io\"\n    },\n    {\n        \"kind\": \"VolumeSnapshotContent\",\n        \"singular\": \"volumesnapshotcontent\",\n        \"plural\": \"volumesnapshotcontents\",\n        \"scope\": \"Cluster\",\n        \"group\": \"snapshot.storage.k8s.io\"\n    },\n    {\n        \"kind\": \"VolumeSnapshot\",\n        \"singular\": \"volumesnapshot\",\n        \"plural\": \"volumesnapshots\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"snapshot.storage.k8s.io\"\n    },\n    {\n        \"kind\": \"CSIDriver\",\n        \"singular\": \"csidriver\",\n        \"plural\": \"csidrivers\",\n        \"scope\": \"Cluster\",\n        \"group\": \"storage.k8s.io\"\n    },\n    {\n        \"kind\": \"CSINode\",\n        \"singular\": \"csinode\",\n        \"plural\": \"csinodes\",\n        \"scope\": \"Cluster\",\n        \"group\": \"storage.k8s.io\"\n    },\n    {\n        \"kind\": \"CSIStorageCapacity\",\n        \"singular\": \"csistoragecapacitie\",\n        \"plural\": \"csistoragecapacities\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"storage.k8s.io\"\n    },\n    {\n        \"kind\": \"StorageClass\",\n        \"singular\": \"storageclasse\",\n        \"plural\": \"storageclasses\",\n        \"scope\": \"Cluster\",\n        \"shortNames\": [\"sc\"],\n        \"group\": \"storage.k8s.io\"\n    },\n    {\n        \"kind\": \"VolumeAttachment\",\n        \"singular\": \"volumeattachment\",\n        \"plural\": \"volumeattachments\",\n        \"scope\": \"Cluster\",\n        \"group\": \"storage.k8s.io\"\n    },\n    {\n        \"kind\": \"BrokerTemplateInstance\",\n        \"singular\": \"brokertemplateinstance\",\n        \"plural\": \"brokertemplateinstances\",\n        \"scope\": \"Cluster\",\n        \"group\": \"template.openshift.io\"\n    },\n    {\n        \"kind\": \"Template\",\n        \"singular\": \"processedtemplate\",\n        \"plural\": \"processedtemplates\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"template.openshift.io\"\n    },\n    {\n        \"kind\": \"TemplateInstance\",\n        \"singular\": \"templateinstance\",\n        \"plural\": \"templateinstances\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"template.openshift.io\"\n    },\n    {\n        \"kind\": \"Template\",\n        \"singular\": \"template\",\n        \"plural\": \"templates\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"template.openshift.io\"\n    },\n    {\n        \"kind\": \"Profile\",\n        \"singular\": \"profile\",\n        \"plural\": \"profiles\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"tuned.openshift.io\"\n    },\n    {\n        \"kind\": \"Tuned\",\n        \"singular\": \"tuned\",\n        \"plural\": \"tuneds\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"tuned.openshift.io\"\n    },\n    {\n        \"kind\": \"Group\",\n        \"singular\": \"group\",\n        \"plural\": \"groups\",\n        \"scope\": \"Cluster\",\n        \"group\": \"user.openshift.io\"\n    },\n    {\n        \"kind\": \"Identity\",\n        \"singular\": \"identitie\",\n        \"plural\": \"identities\",\n        \"scope\": \"Cluster\",\n        \"group\": \"user.openshift.io\"\n    },\n    {\n        \"kind\": \"UserIdentityMapping\",\n        \"singular\": \"useridentitymapping\",\n        \"plural\": \"useridentitymappings\",\n        \"scope\": \"Cluster\",\n        \"group\": \"user.openshift.io\"\n    },\n    {\n        \"kind\": \"User\",\n        \"singular\": \"user\",\n        \"plural\": \"users\",\n        \"scope\": \"Cluster\",\n        \"group\": \"user.openshift.io\"\n    },\n    {\n        \"kind\": \"IPPool\",\n        \"singular\": \"ippool\",\n        \"plural\": \"ippools\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"whereabouts.cni.cncf.io\"\n    },\n    {\n        \"kind\": \"OverlappingRangeIPReservation\",\n        \"singular\": \"overlappingrangeipreservation\",\n        \"plural\": \"overlappingrangeipreservations\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"whereabouts.cni.cncf.io\"\n    },\n    {\n        \"kind\": \"CephBlockPool\",\n        \"singular\": \"cephblockpool\",\n        \"plural\": \"cephblockpools\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"ceph.rook.io\"\n    },\n    {\n        \"kind\": \"CephClient\",\n        \"singular\": \"cephclient\",\n        \"plural\": \"cephclients\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"ceph.rook.io\"\n    },\n    {\n        \"kind\": \"CephCluster\",\n        \"singular\": \"cephcluster\",\n        \"plural\": \"cephclusters\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"ceph.rook.io\"\n    },\n    {\n        \"kind\": \"CephFilesystemMirror\",\n        \"singular\": \"cephfilesystemmirror\",\n        \"plural\": \"cephfilesystemmirrors\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"ceph.rook.io\"\n    },\n    {\n        \"kind\": \"CephFilesystem\",\n        \"singular\": \"cephfilesystem\",\n        \"plural\": \"cephfilesystems\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"ceph.rook.io\"\n    },\n    {\n        \"kind\": \"CephNFS\",\n        \"singular\": \"cephnfse\",\n        \"plural\": \"cephnfses\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"nfs\"],\n        \"group\": \"ceph.rook.io\"\n    },\n    {\n        \"kind\": \"CephObjectRealm\",\n        \"singular\": \"cephobjectrealm\",\n        \"plural\": \"cephobjectrealms\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"ceph.rook.io\"\n    },\n    {\n        \"kind\": \"CephObjectStore\",\n        \"singular\": \"cephobjectstore\",\n        \"plural\": \"cephobjectstores\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"ceph.rook.io\"\n    },\n    {\n        \"kind\": \"CephObjectStoreUser\",\n        \"singular\": \"cephobjectstoreuser\",\n        \"plural\": \"cephobjectstoreusers\",\n        \"scope\": \"Namespaced\",\n        \"shortNames\": [\"rcou\", \"objectuser\"],\n        \"group\": \"ceph.rook.io\"\n    },\n    {\n        \"kind\": \"CephObjectZoneGroup\",\n        \"singular\": \"cephobjectzonegroup\",\n        \"plural\": \"cephobjectzonegroups\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"ceph.rook.io\"\n    },\n    {\n        \"kind\": \"CephObjectZone\",\n        \"singular\": \"cephobjectzone\",\n        \"plural\": \"cephobjectzones\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"ceph.rook.io\"\n    },\n    {\n        \"kind\": \"CephRBDMirror\",\n        \"singular\": \"cephrbdmirror\",\n        \"plural\": \"cephrbdmirrors\",\n        \"scope\": \"Namespaced\",\n        \"group\": \"ceph.rook.io\"\n    },\n\n    # {\n    #     \"kind\": \"\",\n    #     \"singular\": \"\",\n    #     \"plural\": \"\",\n    #     \"scope\": \"\",\n    #     \"shortNames\": [],\n    #     \"group\": \"\"\n    # },\n\n]\n\n\n# RDEFS Generated by the following script:\n\n\"\"\"\n#!/bin/bash\nwhile read apiresline; do\n    cols=$(echo ${apiresline} | tr -s ' ' | tr ' ' '\\n' | wc -l)\n    name=$(echo ${apiresline} | awk '{print $1}')\n    if [ \"${cols}\" == \"4\" ]; then\n        short=\"\"\n        api=$(echo ${apiresline} | awk '{print $2}')\n        nsed=$(echo ${apiresline} | awk '{print $3}')\n        kind=$(echo ${apiresline} | awk '{print $4}')\n    elif [ \"${cols}\" == \"5\" ]; then\n        short=$(echo ${apiresline} | awk '{print $2}')\n        api=$(echo ${apiresline} | awk '{print $3}')\n        nsed=$(echo ${apiresline} | awk '{print $4}')\n        kind=$(echo ${apiresline} | awk '{print $5}')\n    else\n        echo \"WARNING: Invalid line: ${apiresline}\"\n        continue\n    fi\n\n    sing=$(echo \"${name}\" | sed 's/s$//')\n\n    if [ \"${nsed}\" == \"true\" ]; then\n        scope=\"Namespaced\"\n    else\n        scope=\"Cluster\"\n    fi\n\n    if [[ \"{$api}\" == *\"/\"* ]]; then\n        group=$(echo ${api} | cut -d '/' -f 1)\n        apiver=$(echo ${api} | cut -d '/' -f 2)\n    else\n        group=\"core\"\n        apiver=${api}\n    fi\n\n    if [ -n \"${short}\" ]; then\n        shortNames='['\n        for sn in $(echo ${short} | tr ',' '\\n'); do\n            shortNames=\"${shortNames}\\\"${sn}\\\", \"\n        done\n        shortNames=$(echo ${shortNames} | sed 's/,$/]/')\n    else\n        shortNames=\"\"\n    fi\n\nif [ -n \"${shortNames}\" ]; then\n\ncat <<EOF\n    {\n        \"kind\": \"${kind}\",\n        \"singular\": \"${sing}\",\n        \"plural\": \"${name}\",\n        \"scope\": \"${scope}\",\n        \"shortNames\": ${shortNames},\n        \"group\": \"${group}\"\n    },\nEOF\n\nelse\n\ncat <<EOF\n    {\n        \"kind\": \"${kind}\",\n        \"singular\": \"${sing}\",\n        \"plural\": \"${name}\",\n        \"scope\": \"${scope}\",\n        \"group\": \"${group}\"\n    },\nEOF\n\nfi\n\ndone < <(oc api-resources --no-headers)\n\"\"\"\n"
  },
  {
    "path": "omg/must_gather/__init__.py",
    "content": ""
  },
  {
    "path": "omg/must_gather/exceptions.py",
    "content": "class NoValidMgFound(Exception):\n    \"\"\"\n    Error raised when no valid must-gather directory is found\n    \"\"\"\n    pass\n\n\nclass NameSpaceRequired(Exception):\n    \"\"\"\n    Error raised when no must-gather is selected\n    \"\"\"\n    pass\n\n\nclass UnkownResourceType(Exception):\n    \"\"\"\n    Error raised when rdef for resource type is not found\n    \"\"\"\n    pass\n\n\nclass InvalidResource(Exception):\n    \"\"\"\n    Error raised when a loaded resource is invalid\n    \"\"\"\n    pass\n\n\nclass NamespaceDirWithoutYaml(Exception):\n    \"\"\"\n    Error raised namespace directory is present without its yaml\n    \"\"\"\n    pass\n"
  },
  {
    "path": "omg/must_gather/generate_rdefs.py",
    "content": "import os\nimport yaml\nfrom loguru import logger as lg\nfrom omg.utils.dget import dget\nfrom omg.must_gather.load_resources import load_res\n\n\ndef generate_rdefs(path):\n    \"\"\"Generate resource definitions from the crds present in path\n\n    Args:\n        path (str): must-gather path\n\n        dest (str, optional): Optional destination directory for the rdef file.\n                              By default .rdef.yaml file is placed in must-gather\n    \"\"\"\n    lg.debug(\"FUNC_INIT: {}\".format(locals()))\n\n    rdefs_f = os.path.join(os.getenv(\"HOME\"), \".omg.rdefs\")\n\n    lg.debug(\"Generating rdef: {}\".format(rdefs_f))\n\n    rdefs = []\n    # Load existing rdefs\n    if os.path.isfile(rdefs_f):\n        try:\n            with open(rdefs_f, \"r\") as r_f:\n                rdefs.extend(yaml.safe_load(r_f))\n        except Exception:\n            pass\n\n    try:\n        crds = load_res(path, \"crd\")\n\n        if crds:\n            for crd in crds:\n\n                res = dget(crd, [\"res\"])\n\n                rdef = {}\n                rdef[\"kind\"] = dget(res, [\"spec\", \"names\", \"kind\"])\n                rdef[\"singular\"] = dget(res, [\"spec\", \"names\", \"singular\"])\n                rdef[\"plural\"] = dget(res, [\"spec\", \"names\", \"plural\"])\n                rdef[\"group\"] = dget(res, [\"spec\", \"group\"])\n                rdef[\"scope\"] = dget(res, [\"spec\", \"scope\"])\n                rdef[\"shortNames\"] = dget(res, [\"spec\", \"names\", \"shortNames\"], [])\n\n                if rdef not in rdefs:\n                    rdefs.append(rdef)\n\n            with open(rdefs_f, \"w\") as rdf:\n                yaml.dump(rdefs, rdf, default_flow_style=False)\n                lg.debug(\"{} rdefs written to: {}\".format(len(rdefs), rdefs_f))\n\n    except Exception:\n        # lg.warning(\"Unable to generate rdef file {}: {}\".format(rdefs_f, e))\n        pass\n"
  },
  {
    "path": "omg/must_gather/get_rdef.py",
    "content": "\"\"\" get_rdef.py\n\nRDEFS is a built-in list of dictionaries containing resource definitions.\nWe also generate rdefs for crds in .rdefs.yaml in each must-gather path.\n\nIf an rdef is found in built-in RDEF, we don't have to lookup for\ngenerated rdefs in .rdefs.yaml. Hence the more definitions we have in\nbuilt-in RDEFS the better (perfromance wise).\n\nAn rdef dict consists of the following keys:\n\n    kind:       Case-sensitive \"kind\" that is found in the k8 object.\n                This is matched when loading resource from the yaml.\n\n    singular:   Singular name of the resource.\n\n    plural:     Plural name of the resource.\n\n    shortNames: (Optional) List of short names for the resource.\n\n    scope:      Scope of the object (\"Cluster\" or \"Namespaced\").\n\n    group:      API Group of the resource.\n\nget_rdef() function finds, matches and returns the matching dict for\na specific resource type, searching built-in rdefs first.\n\n\"\"\"\n\nimport os\nfrom loguru import logger as lg\n\nfrom omg.must_gather.RDEFS import RDEFS\nfrom omg.utils.load_yaml import load_yaml\nfrom omg.utils.dget import dget\n\n\ndef _match_rdef(r_type, rdef):\n    if isinstance(r_type, str) and isinstance(rdef, dict):\n        # kind = dget(rdef, [\"kind\"])\n        singular = dget(rdef, [\"singular\"])\n        plural = dget(rdef, [\"plural\"])\n        group = dget(rdef, [\"group\"])\n        shortNames = dget(rdef, [\"shortNames\"])\n\n        if \".\" in r_type:\n            r_type_kind = r_type.split(\".\")[0]\n            r_type_group_list = r_type.split(\".\")[1:]\n            r_def_group_list = group.split(\".\")\n            if r_type_kind.lower() in [str(singular), str(plural)]:\n                for rtgl in r_type_group_list:\n                    if rtgl != r_def_group_list[r_type_group_list.index(rtgl)]:\n                        return False\n                return True\n        else:\n            if (\n                r_type == singular or\n                r_type == plural or\n                (shortNames and r_type in shortNames)\n            ):\n                return True\n    return False\n\n\ndef _find_rdef(r_type, rdefs):\n    if rdefs:\n        for rdef in rdefs:\n            if _match_rdef(r_type, rdef):\n                return rdef\n    return None\n\n\ndef get_generated_rdefs():\n    rdefs_f = os.path.join(os.getenv(\"HOME\") or \"/tmp/\", \".omg.rdefs\")\n\n    try:\n        if os.path.isfile(rdefs_f):\n            rdefs_y = load_yaml(rdefs_f)\n            if rdefs_y and type(rdefs_y) is list:\n                return rdefs_y\n    except FileNotFoundError:\n        lg.warning(\"Unable to load rdefs file from {}\".format(rdefs_f))\n\n    return []\n\n\ndef get_rdef(r_type):\n    \"\"\"Find Resource Definition (rdef) for a resource type.\n\n    Args:\n        r_type (str): Resource type to lookup\n\n    Returns:\n        dict: rdef dictionary of the resource type\n    \"\"\"\n    lg.debug(\"FUNC_INIT: {}\".format(locals()))\n\n    r_type = r_type.lower()\n\n    # Lookup rdef in internal RDEFS\n    rdef = _find_rdef(r_type, RDEFS)\n    if rdef:\n        lg.debug(\"rdef for {} found internally: {}\".format(r_type, rdef))\n        return rdef\n\n    lg.debug(\"rdef for {} not found internally. Trying generated ones\".format(\n        r_type\n    ))\n\n    # Find rdefs from generated rdefs file\n\n    rdef = _find_rdef(r_type, get_generated_rdefs())\n\n    if rdef:\n        lg.debug(\"rdef for {} found in generated rdef: {}\".format(r_type, rdef))\n        return rdef\n\n    lg.debug(\"rdef for {} was not found!\".format(r_type))\n    return None\n"
  },
  {
    "path": "omg/must_gather/load_resources.py",
    "content": "\"\"\" load_resources.py \"\"\"\n\nfrom os.path import getmtime\nfrom loguru import logger as lg\n\nfrom omg.must_gather.locate_yamls import locate_yamls\nfrom omg.must_gather.exceptions import InvalidResource\nfrom omg.utils.load_yaml import load_yaml\nfrom omg.utils.dget import dget\n\n\ndef _is_valid_k8_res(res):\n    if isinstance(res, dict):\n        if dget(res, [\"metadata\"]) or dget(res, [\"items\"]):\n            return True\n    return False\n\n\ndef load_res_from_yaml(yfile, rdef=None):\n    \"\"\"Load k8 resources from a single yaml file\n\n    The yaml file is expected to be a dict when loaded with yaml.load\n\n    Args:\n        yfile (str): Path to a yaml file.\n\n        rdef (dict, optional): If a yaml file has multiple kind=xx resources,\n                              this can be used to filter a specific one.\n                              Generally must-gather, yamls only have one type\n                              per file, this is just as a precaution.\n    Return:\n        list[dict]: list of dictionary [ {'res': <>, 'yfile_ts': <>, rdef}, ...]\n                        res:       k8 resource\n                        yfile_ts:   timestamp of the yaml file from\n                                    which the resource was loaded\n                                    (used for age calculation)\n                        rdef:       resrouce definition of the resource\n    \"\"\"\n    lg.debug(\"FUNC_INIT: {}\".format(locals()))\n\n    ydata = load_yaml(yfile)\n\n    if not _is_valid_k8_res(ydata):\n        raise InvalidResource(\n            \"Resource loaded from {} is not valid\".format(yfile))\n\n    lg.debug(\"ydata.keys(): {}\".format(ydata.keys()))\n\n    yfile_ts = getmtime(yfile)\n    lg.debug(\"Yaml file's timestamp: {}\".format(yfile_ts))\n\n    kind = dget(rdef, [\"kind\"])\n\n    res = []\n    # List in yaml (kind: List)\n    if \"items\" in ydata:\n        lg.debug(\"'items' in ydata (we got a list)\")\n        lg.debug(\"len of items: {}\".format(len(ydata[\"items\"] or [])))\n\n        if ydata[\"items\"] is not None and len(ydata[\"items\"]) > 0:\n            res.extend(\n                [\n                    {\"res\": r, \"yfile_ts\": yfile_ts, \"rdef\": rdef}\n                    for r in ydata[\"items\"]\n                    if kind is None or (\"kind\" in r and r[\"kind\"] == kind)\n                ])\n        # else:\n        #     lg.warning(\"No items in yaml file {}, skipping\".format(yfile))\n\n    # Single resource in yaml\n    elif \"metadata\" in ydata:\n\n        lg.debug(\"'metadata' in ydata (we got a single item)\")\n        lg.debug(\"ydata.keys(): {}\".format(ydata.keys()))\n\n        if kind is None or (\"kind\" in ydata and ydata[\"kind\"] == kind):\n            res.extend([{\"res\": ydata, \"yfile_ts\": yfile_ts, \"rdef\": rdef}])\n        else:\n            lg.warning(\"Yaml file {} didnt contain kind {}\".format(yfile, kind))\n    else:\n        raise InvalidResource(\n            \"Invalid yaml file {}. Didn't get 'items' or 'metadata'\".format(yfile))\n\n    lg.debug(\"resources loaded length: {}\".format(len(res)))\n    lg.trace(\"res: {}\".format(res))\n\n    return res\n\n\ndef load_res(path, r_type, r_name=None, ns=None):\n    \"\"\"Load specific resource type from a must-gather path\n\n    This function first calls locate yamls to locate the yamls of the\n    r_type object. Then it calls load_res_from_yaml to load the\n    k8 resources from these yamls. Finally it filters for r_name if is\n    not None, and returns the array.\n\n    Args:\n        path (str): Absolute must-gather path\n\n        r_type (str): Resource type e.g, pod, node.\n\n        r_name (list[str], optional): Resource names to filter.\n                                      All names are returned if None (Default).\n\n        ns (str): Namespace if the the object is namespace scoped.\n                  If the r_type is ns-scoped but ns is None, we use Config().project\n                  '_all' would mean all namespaces.\n                  Ignored for cluster scoped resource types.\n\n    Returns:\n        list[dict]: list of dictionary [ {'res': <>, 'yfile_ts': <>, rdef}, ...]\n                        res:       k8 resource\n                        yfile_ts:   timestamp of the yaml file from\n                                    which the resource was loaded\n                                    (used for age calculation)\n                        rdef:       resrouce definition of the resource\n    \"\"\"\n    lg.debug(\"FUNC_INIT: {}\".format(locals()))\n\n    rdef, yamls = locate_yamls(path, r_type, ns=ns)\n\n    lg.debug(\"Found {} yamls\".format(len(yamls)))\n\n    # Load resources from these yamls and save in res\n    # after filtering names if r_name is set\n    res = []\n\n    # total counters\n    t_matched = 0\n    t_not_matched = 0\n\n    for y in yamls:\n\n        # per yaml counters\n        matched = 0\n        not_matched = 0\n\n        # Handling Partial namespace directory with missing yaml\n        if (\n                dget(rdef, [\"kind\"]) == \"Namespace\"\n                and type(y) is dict\n                and dget(y, [\"yaml_missing\"])\n           ):\n            ns_name = dget(y, [\"yaml_missing\"])\n            res_yd = [{\n                \"res\": {\n                    \"apiVersion\": \"v1\",\n                    \"kind\": \"Namespace\",\n                    \"metadata\": {\n                        \"name\": ns_name\n                    }\n                }\n            }]\n        else:\n            try:\n                res_yd = load_res_from_yaml(y, rdef)\n            except InvalidResource as e:\n                lg.warning(e)\n                continue\n\n        if not r_name:\n            # res name is not set, get all from yaml\n            lg.debug(\"Matching all resource names\")\n            matched += len(res_yd)\n            t_matched += matched\n            res.extend(res_yd)\n        else:\n            # res name is set, filter name from yaml\n            lg.debug(\"Matching resources with name: {}\".format(r_name))\n            for r in res_yd:\n                if (\n                    \"res\" in r\n                    and \"metadata\" in r[\"res\"]\n                    and \"name\" in r[\"res\"][\"metadata\"]\n                    and r[\"res\"][\"metadata\"][\"name\"] in r_name\n                ):\n                    matched += 1\n                    res.append(r)\n                else:\n                    not_matched += 1\n            t_matched += matched\n            t_not_matched += not_matched\n\n        lg.info(\"{}/{} from yaml file: {}\".format(matched, matched+not_matched, y))\n\n    return res\n"
  },
  {
    "path": "omg/must_gather/locate_yamls.py",
    "content": "\"\"\" locate_yamls.py\n\nThis module helps in locating yaml files as we expect them to be\nin a must-gather. We don't look whats inside. Simply return the\npaths to relevant yaml files for a specific resource type.\n\nThe main function is locate_yamls. It uses locate_project if\nresource type is project.\n\nyaml files are located calculated as per following pattern:\n\n    <must-gather>/\n        [namespaces|cluster-scoped-resources]/\n            group/\n                [plural.yaml | plural/*.yaml]\n\n_detect_yamls \"detects\" if plural.yaml is present or plural/*.yaml\n\"\"\"\n\nfrom os.path import join, isdir, isfile\nfrom os import listdir\nfrom loguru import logger as lg\nfrom omg.must_gather.get_rdef import get_rdef\nfrom omg.must_gather.exceptions import UnkownResourceType, NameSpaceRequired\n\n\ndef _detect_yamls(path, plural):\n    \"\"\"Detects if yaml file(s) are present as plural.yaml or plural/*.yaml.\n\n    First priority is given to plural.yaml and if its not present,\n    plural/*.yaml files are scanned. TODO: Ensure this order is correct\n\n    Args:\n        path (str): Path where yaml needs to be detected\n        plural (str): Plural name of the resrouce we are detecting\n\n    Returns:\n        list[str]: List of yaml paths that were detected\n                   Returns None if none were detected\n    \"\"\"\n    lg.debug(\"FUNC_INIT: {}\".format(locals()))\n    # potential yaml file\n    pot_y = join(path, plural+\".yaml\")\n    # potential yaml dir\n    pot_d = join(path, plural)\n    if isfile(pot_y):\n        lg.debug(\"detected yaml file: {}\".format(pot_y))\n        return [pot_y]\n    if isdir(pot_d):\n        lg.debug(\"detected yaml dir {}\".format(pot_d))\n        y_in_d = [join(pot_d, y) for y in listdir(pot_d) if y.endswith(\".yaml\")]\n        lg.debug(\"{} yamls found\".format(len(y_in_d)))\n        lg.trace(\"yamls_in_dir: {}\".format(y_in_d))\n        return y_in_d\n    return None\n\n\ndef locate_project(path, tell):\n    \"\"\"Special function to locate project yamls\n\n    project yamls are present in must-gather/namespaces/<ns-name>/<ns-name>.yaml,\n    unlike for other res_types, project type needs separate/special function to\n    locate the yamls.\n\n    This function can return yamls, paths or just the project names. depending on\n    what is asked in arg tell=\"\"\n\n    Args:\n        path (str)): Absolute must-gather path\n\n        tell (str): What to tell/return? Possible options are:\n                        \"yamls\": yaml files of the projects\n                        \"paths\": paths of project directories\n                        \"names\": names of the projects present\n\n    Returns:\n        list: List of requested item (yamls/paths/names)\n    \"\"\"\n    lg.debug(\"FUNC_INIT: {}\".format(locals()))\n    result = []\n    lg.debug(\"Looking for projects in {}\".format(path))\n    p_nss = join(path, \"namespaces\")\n    if isdir(p_nss):\n        lg.debug(\"Found namspaces in {}\".format(path))\n        for proj in listdir(p_nss):\n            p_nss_proj = join(p_nss, proj)\n            if isdir(p_nss_proj):\n                if tell == \"names\" and proj not in result:\n                    if proj not in result:\n                        result.append(proj)\n                elif tell == \"paths\":\n                    result.append(p_nss_proj)\n                elif tell == \"yamls\":\n                    p_nss_proj_y = join(p_nss_proj, proj+\".yaml\")\n                    if isfile(p_nss_proj_y):\n                        result.append(p_nss_proj_y)\n                    else:\n                        # ns dir exists but yaml is missing\n                        # we will append a special dict with ns name\n                        # instead of the path of the yaml\n                        result.append({\"yaml_missing\": proj})\n                else:\n                    raise ValueError(\"Invalid arg(tell): {}\".format(tell))\n    lg.trace(\"result: {}\".format(result))\n    return result\n\n\ndef locate_yamls(path, r_type, ns=None):\n    \"\"\"Find yaml for a particular resource type in paths.\n\n    Args:\n        path (str): Absolute must-gather path\n\n        r_type (str): Resource type e.g, pod, node.\n\n        ns (str): Namespace. Required if r_type is namespace scoped.\n                  Value of '_all' denotes all namespaces.\n                  Ignored for cluster scoped resource types.\n\n    Returns:\n        dict, list: rdef and List of paths of yamls located in paths.\n    \"\"\"\n    lg.debug(\"FUNC_INIT: {}\".format(locals()))\n\n    yaml_paths = []\n\n    # r_type == project | namespace\n    if r_type.lower() in [\"project\", \"projects\", \"namespace\", \"ns\"]:\n        yaml_paths = locate_project(path, \"yamls\")\n        rdef = {\n            \"kind\": \"Namespace\",\n            \"group\": \"core\",\n            \"singular\": \"namespace\",\n            \"plugral\": \"namespaces\"\n        }\n    # r_type != project\n    else:\n        rdef = get_rdef(r_type)\n        if not rdef:\n            raise UnkownResourceType(\"Unknown resource type: {}\".format(r_type))\n\n        lg.debug(\"rdef: {}\".format(rdef))\n        # kind = rdef[\"kind\"]\n        plural = rdef[\"plural\"]\n        group = rdef[\"group\"]\n        scope = rdef[\"scope\"]\n\n        if scope == \"Namespaced\":\n            if not ns:\n                raise NameSpaceRequired(\n                    \"{} is Namespaced but ns/project is not set\".format(r_type))\n            if ns == \"_all\":  # all namespaces\n                all_proj_paths = locate_project(path, tell=\"paths\")\n                for app in all_proj_paths:\n                    ymls = _detect_yamls(join(app, group), plural)\n                    if ymls:\n                        yaml_paths.extend(ymls)\n            else:  # specific ns\n                ymls = _detect_yamls(join(path, \"namespaces\", ns, group), plural)\n                if ymls:\n                    yaml_paths.extend(ymls)\n        else:\n            # scope == \"Cluster\"\n            ymls = _detect_yamls(join(path, \"cluster-scoped-resources\", group), plural)\n            if ymls:\n                yaml_paths.extend(ymls)\n    lg.trace(\"rdef: {}, yaml_paths: {}\".format(rdef, yaml_paths))\n    return rdef, yaml_paths\n"
  },
  {
    "path": "omg/must_gather/scan_mg.py",
    "content": "import os\nfrom loguru import logger as lg\nfrom omg.must_gather.exceptions import NoValidMgFound\n\n\ndef scan_mg(tdirs):\n    \"\"\"Scan directories for valid must-gather/inspect directories\n\n    Args:\n        tdirs (tuple[str]): Non-empty tuple of directory paths to scan\n\n    Returns:\n        list: List of valid (absolute) must-gather/inspect directories\n    \"\"\"\n    lg.debug(\"FUNC_INIT: {}\".format(locals()))\n\n    valid_dirs = []\n    for tdir in tdirs:\n        vdirs = []\n        if os.path.isdir(tdir):\n            scan_q = [tdir]\n            while len(scan_q) > 0:\n                lg.debug('scan_q: ' + str(scan_q))\n                wdir = scan_q.pop()\n                subdirs = [d for d in os.listdir(wdir)\n                           if os.path.isdir(os.path.join(wdir, d))]\n                if (\"cluster-scoped-resources\" in subdirs or \"namespaces\" in subdirs):\n                    lg.debug('Valid dir found: ' + str(wdir))\n                    vdirs.append(os.path.abspath(wdir))\n\n                    # if there are any other subdirs we will scan those as well\n                    try:\n                        subdirs.remove(\"cluster-scoped-resources\")\n                    except ValueError:\n                        pass\n                    try:\n                        subdirs.remove(\"namespaces\")\n                    except ValueError:\n                        pass\n                    for sd in subdirs:\n                        scan_q.append(os.path.join(wdir, sd))\n\n                    # if namespaces/all/namespaces exists we will mark it valid as well\n                    if os.path.isdir(os.path.join(wdir, \"namespaces\", \"all\", \"namespaces\")):\n                        vdirs.append(os.path.abspath(os.path.join(wdir, \"namespaces\", \"all\")))\n\n                else:\n                    lg.debug('Not valid dir scanning deeper: ' + str(wdir))\n                    scan_q.extend([os.path.join(wdir, d) for d in subdirs])\n        if vdirs:\n            valid_dirs.extend(vdirs)\n        else:\n            lg.warning('Not a valid must-gather: ' + str(tdir))\n    if len(valid_dirs) > 0:\n        lg.debug(\"valid_dirs: {}\".format(valid_dirs))\n        try:\n            # Put the primary must-gather path on top of the paths list\n            # Optional but good to do in multidir mode\n            pmgs = [\n                pmg for pmg in valid_dirs\n                if \"quay-io-openshift-release-dev-ocp-v4-0-art-dev-sha256\" in pmg\n            ]\n            lg.debug(\"primary mgs: {}\".format(pmgs))\n            if len(pmgs) > 1:\n                lg.warning(\"Multiple primary must-gather directories selected\")\n            # if not pmgs:\n            #     lg.warning(\"No primary must-gather directory selected\")\n            for pmg in pmgs:\n                valid_dirs.insert(\n                    0, valid_dirs.pop(\n                        valid_dirs.index(pmg)\n                    )\n                )\n        except Exception:\n            pass\n        return valid_dirs\n    else:\n        raise NoValidMgFound(\"No valid must-gather(s) found!\")\n"
  },
  {
    "path": "omg/project/__init__.py",
    "content": ""
  },
  {
    "path": "omg/project/complete.py",
    "content": "from omg.must_gather.locate_yamls import locate_project\nfrom omg.config import config\nfrom omg.utils.dget import dget\nfrom loguru import logger as lg\n\n\ndef complete_projects(ctx, args, incomplete):\n    \"\"\"\n    Callback for project name autocompletion\n    :return: List of matching namespace names or empty list.\n    \"\"\"\n    lg.remove()\n\n    def _get_all_projects():\n        cfg = config.get()\n        c_paths = dget(cfg, [\"paths\"])\n        if c_paths:\n            projects = []\n            for path in c_paths:\n                projects.extend(locate_project(path, tell=\"names\"))\n            return projects\n        return []\n\n    if incomplete is not None:\n        projects = _get_all_projects()\n        suggestions = [ns for ns in projects if ns.startswith(incomplete)]\n        return suggestions\n    return []\n"
  },
  {
    "path": "omg/project/project.py",
    "content": "from loguru import logger as lg\nfrom omg.config import config\nfrom omg.utils.dget import dget\nfrom omg.must_gather.locate_yamls import locate_project\n\n\ndef cmd(name):\n    cfg = config.get()\n    c_paths = dget(cfg, [\"paths\"])\n    c_project = dget(cfg, [\"project\"])\n\n    # print current project\n    if name is None:\n        if c_project is None:\n            print(\"No project selected\")\n        else:\n            print(\"Using project {}\".format(c_project))\n    # set current project\n    else:\n        if name == c_project:\n            print(\"Already using project {}\".format(c_project))\n        else:\n            select_project = None\n            for path in c_paths:\n                projs_in_path = locate_project(path, tell=\"names\")\n                if name in projs_in_path:\n                    select_project = name\n                    break\n            if select_project:\n                print(\"Now using project {}\".format(select_project))\n                config.save(project=name)\n            else:\n                lg.error(\"Project {} not found in {} must-gather paths\".format(\n                    name, len(c_paths)))\n"
  },
  {
    "path": "omg/project/projects.py",
    "content": "from loguru import logger as lg\nfrom omg.config import config\nfrom omg.utils.dget import dget\nfrom omg.must_gather.locate_yamls import locate_project\n\n\ndef cmd():\n    lg.debug(\"FUNC_INIT: {}\".format(locals()))\n\n    cfg = config.get()\n    c_paths = dget(cfg, [\"paths\"])\n    c_project = dget(cfg, [\"project\"])\n\n    if c_paths:\n        for path in c_paths:\n            projs_in_path = locate_project(path, tell=\"names\")\n            print(\"{} projects in {}\".format(\n                len(projs_in_path), path))\n        print(\"\")\n        print(\"Selected project: {}\".format(c_project))\n"
  },
  {
    "path": "omg/show/__init__.py",
    "content": ""
  },
  {
    "path": "omg/use/__init__.py",
    "content": ""
  },
  {
    "path": "omg/use/show_mg_info.py",
    "content": "import re\nfrom loguru import logger as lg\nfrom omg.config import config\nfrom omg.must_gather.load_resources import load_res\nfrom omg.must_gather.locate_yamls import locate_project\nfrom omg.utils.dget import dget\n\n\ndef _hide_hash(path):\n    \"\"\"Hide the image hash in the path for better readability.\"\"\"\n    return re.sub(\"sha256-[a-z0-9]*\", \"sha256*\", path)\n\n\ndef _show_info(path):\n\n    out = lg.opt(colors=True).success\n\n    proj_count = len(locate_project(path, \"yamls\"))\n    out(\"            <e>Projects:</> {}\".format(proj_count))\n\n    try:\n        infra = load_res(path, \"infrastructure\")\n        if infra:\n            api_url = [\n                dget(i, [\"res\", \"status\", \"apiServerURL\"]) for i in infra\n            ]\n            platform = [\n                dget(i, [\"res\", \"status\", \"platform\"]) for i in infra\n            ]\n            out(\"             <e>API URL:</> {}\".format(api_url))\n            out(\"            <e>Platform:</> {}\".format(platform))\n\n        c_ver = load_res(path, \"clusterversion\")\n        if c_ver:\n            cluster_id = [\n                dget(cv, [\"res\", \"spec\", \"clusterID\"]) for cv in c_ver\n            ]\n            desired_v = [\n                dget(cv, [\"res\", \"status\", \"desired\", \"version\"]) for cv in c_ver\n            ]\n            out(\"          <e>Cluster ID:</> {}\".format(cluster_id))\n            out(\"     <e>Desired Version:</> {}\".format(desired_v))\n        out(\"\")\n    except Exception as e:\n        lg.warning(\"Error loading cluster info: {}\".format(e))\n\n\ndef show_mg_info(cfile=None):\n    \"\"\"\n    Shows the info of current selected must-gather(s)\n    \"\"\"\n    lg.debug(\"FUNC_INIT: {}\".format(locals()))\n\n    cfg = config.get(cfile=cfile)\n    lg.debug(\"Loaded config file: {}\".format(cfg))\n\n    paths = cfg[\"paths\"]\n    project = cfg[\"project\"]\n\n    out = lg.opt(colors=True).success\n\n    if \"cwd\" in cfg and cfg[\"cwd\"]:\n        out(\"<e>-=[CWD Mode]=-</>\")\n        out(\"\")\n\n    if len(paths) > 1:\n        out(\"<e>-=[MultiDir Mode]=-</>\")\n        out(\"\")\n        out(\"<e>Selected must-gather paths:</>\")\n        i = 1\n        for path in paths:\n            out(\" <e>[{}]</> {}\".format(i, _hide_hash(path)))\n            i = i + 1\n            _show_info(path)\n        out(\"\")\n        out(\"<e>Current Project:</> {}\".format(project))\n\n    elif len(paths) == 1:\n        out(\"<e>Selected must-gather:</> {}\".format(_hide_hash(paths[0])))\n        _show_info(paths[0])\n        out(\"     <e>Current Project:</> {}\".format(project))\n"
  },
  {
    "path": "omg/use/use.py",
    "content": "from omg.must_gather.generate_rdefs import generate_rdefs\nfrom loguru import logger as lg\nfrom omg.config import config\nfrom omg.must_gather.exceptions import NoValidMgFound\nfrom omg.use.show_mg_info import show_mg_info\nfrom omg.must_gather.scan_mg import scan_mg\n\n\ndef cmd(mg_paths=None, cwd=False, cfile=None):\n    \"\"\"Landing function for `omg use`\n\n    Args:\n        mg_paths (string, optional): Path to extracted must-gather.\n                                     Defaults to None.\n        cwd (bool, optional): --cwd flag.\n                              Defaults to False.\n\n    Returns:\n        int: return code 0/1 (success/failure)\n    \"\"\"\n    lg.debug(str(locals()))\n    if not mg_paths:\n        # --cwd\n        if cwd:\n            try:\n                config.save(paths=['.'], cfile=cfile)\n            except Exception as e:\n                lg.error(e)\n                return 1\n            else:\n                lg.opt(colors=True).success(\n                    \"<e>[CWD Mode]</> Assuming your working directory as must-gather\")\n                return 0\n        # No args passed\n        else:\n            show_mg_info(cfile)\n            return 0\n    else:\n        # One or more dirs are passed via mg_paths,\n        # scan and save the valid directories\n        try:\n            valid_mg_paths = scan_mg(mg_paths)\n        except NoValidMgFound as e:\n            lg.error(e)\n            return 1\n\n        # Foce re-generate rdefs for all discovered paths\n        for path in valid_mg_paths:\n            try:\n                generate_rdefs(path)\n            except Exception:\n                # lg.warning(\"Failed generating rdef for {}: {}\".format(path, e))\n                pass\n\n        # Save paths in config\n        config.save(paths=valid_mg_paths, cfile=cfile)\n\n        # Show selected must-gather paths to user\n        show_mg_info(cfile)\n\n        return 0\n"
  },
  {
    "path": "omg/utils/__init__.py",
    "content": ""
  },
  {
    "path": "omg/utils/age.py",
    "content": "from datetime import datetime\nfrom dateutil.parser import parse\nfrom dateutil.relativedelta import relativedelta\nfrom loguru import logger as lg\n\n\ndef age(ts1, ts2, ts1_type=\"iso\", ts2_type=\"epoch\"):\n    \"\"\"Calculate age of the objects\n\n    This function is used to calculate age of the objects\n    We compare the time reported in the yaml definition,\n    with the timestamp of the yaml file (i.e, when it was generated).\n    This should give us age of the object at the time of must-gather\n    By default, ts1 is considered in iso-8601 e.g: '2020-06-04T22:10:41Z'\n    and ts2 is considered in unix/epoch format e.g: 1590912494.0 (returned by os.path.getmtime)\n\n\n    Args:\n        ts1 (str): First timestamp\n        ts2 (str): Second timestamp\n        ts1_type (str, optional): Type of fist timestamp. Defaults to \"iso\".\n        ts2_type (str, optional): Type of second timestamp. Defaults to \"epoch\".\n\n    Returns:\n        str:    Human readable age e.g: 1d, 3m, 6h, 20s etc.\n                Biggest unit is days (d) and smallest is (s)\n    \"\"\"\n    try:\n        if ts1_type == \"iso\":\n            if isinstance(ts1, datetime):\n                ts1 = ts1.isoformat()\n            dt1 = parse(ts1, ignoretz=True)\n        elif ts1_type == \"epoch\":\n            dt1 = datetime.utcfromtimestamp(ts1)\n\n        if ts2_type == \"iso\":\n            if isinstance(ts2, datetime):\n                ts2 = ts2.isoformat()\n            dt2 = parse(ts2, ignoretz=True)\n        elif ts2_type == \"epoch\":\n            dt2 = datetime.utcfromtimestamp(ts2)\n\n        rd = relativedelta(dt2, dt1)\n    except Exception as e:\n        lg.debug(\"error parsing timestamps: {}\".format(e))\n        return \"Unknown\"\n\n    if rd.days > 0 or rd.months > 0 or rd.years > 0:\n        days = int(rd.years * 365) + int(rd.months * 30) + int(rd.days)\n        return str(days) + \"d\"\n    elif rd.hours > 9:\n        return str(rd.hours) + \"h\"\n    elif rd.hours > 0 and rd.hours < 10:\n        return str(rd.hours) + \"h\" + str(rd.minutes) + \"m\"\n    elif rd.minutes > 9:\n        return str(rd.minutes) + \"m\"\n    elif rd.minutes > 0 and rd.minutes < 10:\n        return str(rd.minutes) + \"m\" + str(rd.seconds) + \"s\"\n    else:\n        return str(rd.seconds) + \"s\"\n"
  },
  {
    "path": "omg/utils/dget.py",
    "content": "def dget(_dict, keys, default=None):\n    \"\"\"Safely get key values from nested dictionary\n\n    Args:\n        _dict (dict): Dictionary to get the key from\n        keys (list): Iterable list of keys to get\n        default (any optional): Value to return if key is missing. Defaults to None.\n\n    Returns:\n        any: Value found at the key or the default value if key is not found\n    \"\"\"\n    for key in keys:\n        if isinstance(_dict, dict):\n            _dict = _dict.get(key, default)\n        else:\n            return default\n    return _dict\n"
  },
  {
    "path": "omg/utils/extract_labels.py",
    "content": "def extract_labels(obj):\n    \"\"\"Receives an object/resource and returns the labels in flat/string format.\n    Helper function to print labels when --show-labels is passed\n\n    Args:\n        o (dict): object\n\n    Returns:\n        str: Labels in plain string e.g: \"app=console,component=ui\"\n             Returns '<none>' if 'labels' is absent in object -> metadata\n\n    \"\"\"\n    if \"labels\" in obj[\"metadata\"]:\n        try:\n            lab = obj[\"metadata\"][\"labels\"]\n            l_str = \",\".join([\"%s=%s\" % (k, v) for k, v in lab.items()])\n            return l_str\n        except Exception:\n            return \"<error parsing labels>\"\n    else:\n        return \"<none>\"\n"
  },
  {
    "path": "omg/utils/load_json.py",
    "content": "import json\nfrom loguru import logger as lg\n\n\ndef load_json(jfile):\n    try:\n        with open(jfile, \"r\") as j_f:\n            j_d = j_f.read()\n            j_data = json.loads(j_d)\n            return j_data\n    except Exception as e:\n        lg.warning(\"Error loading json file ({}): {}\".format(jfile, e))\n    return None\n"
  },
  {
    "path": "omg/utils/load_yaml.py",
    "content": "\"\"\" load_resources_from_yaml.py \"\"\"\n\nimport yaml\nimport os\nfrom loguru import logger as lg\n\ntry:\n    from yaml import CSafeLoader as SafeLoader\nexcept ImportError:\n    lg.warning(\"yaml.CSafeLoader failed to load, using SafeLoader\")\n    from yaml import SafeLoader\n\n\ndef load_yaml(yfile):\n    \"\"\"Load yaml file and return python object\n\n    Args:\n        yfile (str): Yaml file path\n\n    Returns:\n        (str|list|dict): Python object loaded from yaml\n    \"\"\"\n    lg.debug(\"yfile: {}\".format(yfile))\n\n    if not os.path.isfile(yfile):\n        raise Exception(\"File not found: {}\".format(yfile))\n\n    ydata = None\n    with open(yfile, \"r\") as y_f:\n        lg.debug(\"Opened yaml file: \" + yfile)\n        y_d = y_f.read()\n        try:\n            ydata = yaml.load(y_d, Loader=SafeLoader)\n        except (yaml.scanner.ScannerError, yaml.parser.ParserError):\n            # yaml load/parse failed\n            # try skipping lines from the bottom\n            # Until we are able to load the yaml file\n            # We will try until > 1 lines are left\n            lines_total = y_d.count(\"\\n\")\n            lines_skipped = 0\n            while y_d.count(\"\\n\") > 1:\n                # skip last line\n                y_d = y_d[:y_d.rfind(\"\\n\")]\n                lines_skipped += 1\n                try:\n                    ydata = yaml.load(y_d, Loader=SafeLoader)\n                except (yaml.scanner.ScannerError, yaml.parser.ParserError):\n                    pass\n                else:\n                    lg.warning(\"Skipped \" +\n                               str(lines_skipped) + \"/\" + str(lines_total) +\n                               \" lines from the end of \" + yfile +\n                               \" to the load the yaml file properly\")\n                    break\n\n    lg.debug(\"yaml file loaded in ydata. type: \" + str(type(ydata)))\n    lg.trace(\"ydata: \" + str(ydata))\n\n    # if not ydata:\n    #     raise Exception(\"Unable to load yaml file: {}\".format(yfile))\n\n    return ydata\n"
  },
  {
    "path": "omg/utils/size.py",
    "content": "\ndef num2human(\n    num,\n    form=\"{n:.2f} {u}B\",\n    factor=1024,\n    unit_list=[\"\", \"K\", \"M\", \"G\", \"T\", \"P\", \"E\", \"Z\", \"Y\"]\n):\n    for unit in unit_list:\n        if factor > num or unit == unit_list[-1]:\n            return form.format(n=num, u=unit)\n        num /= factor\n"
  },
  {
    "path": "omg/whoami/__init__.py",
    "content": ""
  },
  {
    "path": "omg/whoami/whoami.py",
    "content": "def cmd():\n    print()\n    print('You are awesome :)')\n    print()\n"
  },
  {
    "path": "setup.cfg",
    "content": "[wheel]\nuniversal = 1\n[metadata]\ndescription_file = README.md\n"
  },
  {
    "path": "setup.py",
    "content": "\"\"\"\noc like tool that works with must-gather rather than OpenShift API\n\"\"\"\nfrom setuptools import find_packages, setup\nimport omg\n\n#dependencies = ['tabulate', 'pyyaml', 'python-dateutil', 'cryptography>=2.5,<=3.3.2', 'click==7.1.2']\ndependencies = ['tabulate', 'pyyaml', 'python-dateutil', 'cryptography>=2.5', 'click==8.0.1', 'loguru==0.6.0']\n\nsetup(\n    name='o-must-gather',\n    version=omg.version,\n    url='https://github.com/kxr/o-must-gather',\n    license='GPLv3',\n    author='Khizer Naeem',\n    author_email='khizernaeem@gmail.com',\n    description='oc like tool that works with must-gather rather than OpenShift API',\n    long_description=__doc__,\n    packages=find_packages(),\n    include_package_data=True,\n    zip_safe=False,\n    platforms='any',\n    install_requires=dependencies,\n    entry_points={\n        'console_scripts': [\n            'omg = omg.cli:cli',\n        ],\n    },\n    classifiers=[\n        # As from http://pypi.python.org/pypi?%3Aaction=list_classifiers\n        'Development Status :: 5 - Production/Stable',\n        'Environment :: Console',\n        'Intended Audience :: System Administrators',\n        'License :: OSI Approved :: BSD License',\n        'Operating System :: POSIX',\n        'Operating System :: MacOS',\n        'Operating System :: Unix',\n        'Programming Language :: Python :: 3',\n        'Topic :: Utilities',\n    ]\n)\n"
  },
  {
    "path": "tests/__init__.py",
    "content": ""
  },
  {
    "path": "tests/conftest.py",
    "content": "import os\nimport logging\nimport pytest\nimport tarfile\nfrom _pytest.logging import caplog as _caplog\nfrom loguru import logger\n\n\n_ = _caplog  # to satisfy flake8\n\n\n@pytest.fixture\ndef caplog(_caplog):\n    class PropogateHandler(logging.Handler):\n        def emit(self, record):\n            logging.getLogger(record.name).handle(record)\n\n    handler_id = logger.add(PropogateHandler(), level=25, format=\"{message}\")\n    yield _caplog\n    logger.remove(handler_id)\n\n\n@pytest.fixture\ndef simple_must_gather(tmpdir):\n    mg_tar = tarfile.open(\"samples/must-gather.46i.tgz\")\n    mg_tar.extractall(tmpdir)\n    mg_tar.close()\n    return os.path.join(tmpdir)\n\n\n@pytest.fixture\ndef omgconfig(tmpdir):\n    return os.path.join(str(tmpdir), \".omgconfig\")\n"
  },
  {
    "path": "tests/dev_testing.py",
    "content": "from omg.config.logging import setup_logging\nfrom omg.must_gather.load_resources import load_res\n\n\nsetup_logging(\"info\")\n\npaths = [\n    '/home/knaeem/Desktop/mgs/must-gather.etism/registry-redhat-io-openshift-service-mesh-istio-must-gather-rhel7-sha256-b73931d591587f34e94fd79de84b557417b817616a04631e6c741268b47d9d05',\n    '/home/knaeem/Desktop/mgs/must-gather.etism/quay-io-openshift-release-dev-ocp-v4-0-art-dev-sha256-2f3d142d13081954fc73e1d5e6ee96a04ba7c5714e9193f985d0a6962d325841'\n]\n\n# config = Config()\n# config.paths = paths\n# config.project = \"openshift-apiserver\"\n\nres = load_res(paths, \"configmap\", ns=\"openshift-config\")\n\nfor r in res:\n    rs = r[\"res\"]\n    print(rs[\"metadata\"][\"name\"])\n"
  },
  {
    "path": "tests/test_config.py",
    "content": "import pytest\nfrom omg.config import config\nfrom omg.config.logging import setup_logging\n\n\nsetup_logging(loglevel=\"normal\")\n\n\ndef test_config_load_no_config(caplog):\n    with pytest.raises(config.NoMgSelected):\n        config._load_config(\"/non/exitent/file\")\n\n\ndef test_config_dump(tmpdir):\n    dump_file = tmpdir.join(\"dump_file.txt\")\n    config._dump_config(\n        {'testkey': 'testvalue'},\n        dump_file\n    )\n    assert dump_file.read() == \"testkey: testvalue\\n\"\n\n\ndef test_config_get_no_config(caplog):\n    with pytest.raises(SystemExit):\n        config.get(\"/non/exitent/file\")\n    assert \"You have not selected a must-gather\" in caplog.text\n\n\ndef test_config_save_get(tmpdir):\n    omg_config = tmpdir.join(\".omgconfig\")\n    config.save(\n        paths=[\"/test/path\"],\n        project=\"testproject\",\n        cfile=omg_config\n    )\n    cfg = config.get(cfile=omg_config)\n\n    assert cfg[\"paths\"] == [\"/test/path\"]\n    assert cfg[\"project\"] == \"testproject\"\n"
  },
  {
    "path": "tests/test_mg_ops.py",
    "content": "import pytest\nimport os\nfrom omg.lib.mg_ops.locate_yamls import locate_yamls\nfrom omg.lib.mg_ops.scan_mg import scan_mg, NoValidMgFound\nfrom omg.config.logging import setup_logging\n\n\nsetup_logging(loglevel=\"normal\")\n\n\ndef test_scan_mg_invalid(tmpdir):\n    with pytest.raises(NoValidMgFound):\n        scan_mg(\n            (str(tmpdir),)\n        )\n\n\ndef test_scan_mg_valid(simple_must_gather, omgconfig):\n    paths = scan_mg(\n        (str(simple_must_gather),)\n    )\n    assert len(paths) == 1\n    for path in paths:\n        assert os.path.isdir(path)\n        assert (\n            os.path.isdir(\n                os.path.join(path, \"namespaces\"))\n            or\n            os.path.isdir(\n                os.path.join(path, \"cluster-scoped-resources\"))\n        )\n\n\ndef test_locate_yamls(simple_must_gather):\n    paths = scan_mg(\n        (str(simple_must_gather),)\n    )\n    kind, yamls = locate_yamls(\n        paths=paths,\n        r_type=\"infrastructure\"\n    )\n    assert kind == \"Infrastructure\"\n    assert yamls == [\n        paths[0] + \"/cluster-scoped-resources/config.openshift.io/infrastructures.yaml\"\n    ]\n"
  },
  {
    "path": "tests/test_use.py",
    "content": "import os\nimport yaml\nfrom omg.use import use\nfrom omg.config.logging import setup_logging\n\n\nsetup_logging(loglevel=\"normal\")\n\n\ndef test_use_invalid_paths(caplog):\n    use.cmd(\n        mg_paths=('/non/exitent/path',)\n    )\n    assert \"No valid must-gather(s) found in ('/non/exitent/path',)\" in caplog.text\n\n\ndef test_use_simple_must_gather(caplog, omgconfig, simple_must_gather):\n    use.cmd(\n        mg_paths=(simple_must_gather,),\n        cfile=omgconfig\n    )\n    with open(omgconfig, \"r\") as omgcfg:\n        cfg = yaml.load(omgcfg.read(), Loader=yaml.SafeLoader)\n    for path in cfg[\"paths\"]:\n        assert os.path.isdir(path)\n        assert (\n            os.path.isdir(\n                os.path.join(path, \"namespaces\"))\n            or\n            os.path.isdir(\n                os.path.join(path, \"cluster-scoped-resources\"))\n        )\n\n    assert \"quay-io-openshift-release-dev-ocp-v4-0-art-dev-sha256*\" in caplog.text\n    assert \"Cluster API URL: ['https://api.ocp46.v.kxr.me:6443']\" in caplog.text\n    assert \"Cluster Platform: ['VSphere']\" in caplog.text\n    assert \"Cluster ID: ['51611b91-5e45-4246-8b64-b3da2ed6ad22']\" in caplog.text\n    assert \"Desired Version: ['4.6.16']\" in caplog.text\n\n\n# TODO: test_use_multidir_must_gather\n\n\ndef test_use_cwd(caplog, omgconfig):\n    use.cmd(\n        cwd=True,\n        cfile=omgconfig\n    )\n    assert \"[CWD Mode] Assuming your working directory as must-gather\" in caplog.text\n    with open(omgconfig, \"r\") as omgcfg:\n        assert omgcfg.read() == \"paths:\\n- .\\nproject: null\\n\"\n"
  }
]