From 57a6c6a84ecb28e84be468a46102fb3d6e27723a Mon Sep 17 00:00:00 2001 From: Felipe Monteiro Date: Mon, 24 Sep 2018 19:24:52 +0100 Subject: [PATCH] Implement global lint and lint by site logic With the implementation of revisioned repository to the CLI in https://review.openstack.org/#/c/577886 there was a change to the lint command [0], which changed it from being a global lint to a site-level (targetted lint)... kind of: Only the CLI logic was modified to support targetted single-site linting. Thus, the first issue this patch set addresses is implementing the back-end logic to realize targetted, single-site linting. The second issue this patch set addresses is re-supporting global linting (linting all sites within a repository) which means that this partially reverts [0] which had (kind of) replaced global linting with per-site linting. So, this patch set: 1) Implements targetted, single-site linting back-end logic 2) Re-implements global linting for all sites in a repo 3) Adds unit tests for both 4) Adds some helper functions to util.engine.definition to help with 1) and 2) [0] https://review.openstack.org/#/c/577886/4/src/bin/pegleg/pegleg/cli.py@191 Change-Id: I5147282556763d93dfaf06912d2c4c876e1bd69f --- Makefile | 4 +- doc/source/{ => cli}/cli.rst | 130 +++++++++----- doc/source/images/architecture-pegleg.png | Bin 37597 -> 37600 bytes doc/source/index.rst | 2 +- pegleg/cli.py | 176 +++++++++++++------ pegleg/engine/lint.py | 152 ++++++++++++---- pegleg/engine/util/definition.py | 58 +++++- tests/unit/engine/test_selectable_linting.py | 157 ++++++++++------- tests/unit/engine/util/test_definition.py | 66 +++++++ tests/unit/test_cli.py | 142 ++++++++++++++- tools/gate/build-docs.sh | 8 +- 11 files changed, 686 insertions(+), 209 deletions(-) rename doc/source/{ => cli}/cli.rst (83%) create mode 100644 tests/unit/engine/util/test_definition.py diff --git a/Makefile b/Makefile index 8a9b7091..c25a124c 100644 --- a/Makefile +++ b/Makefile @@ -99,8 +99,8 @@ clean: .PHONY: py_lint py_lint: - cd pegleg;tox -e pep8 + tox -e pep8 .PHONY: py_format py_format: - cd pegleg;tox -e fmt + tox -e fmt diff --git a/doc/source/cli.rst b/doc/source/cli/cli.rst similarity index 83% rename from doc/source/cli.rst rename to doc/source/cli/cli.rst index 0b8d8516..5b00d057 100644 --- a/doc/source/cli.rst +++ b/doc/source/cli/cli.rst @@ -83,17 +83,13 @@ Enable debug logging. .. _site: -Site ----- +Repo +==== -This allows you to set the primary and auxiliary repositories. - -:: - - ./pegleg.sh site -r -e +Allows you to perform repository-level operations. Options -^^^^^^^ +------- **-r / --site-repository** (Required). @@ -101,6 +97,46 @@ Path to the root of the site repository (containing site_definition.yaml) repo. For example: /opt/aic-site-clcp-manifests. +The revision can also be specified via (for example): + +:: + + -r /opt/aic-site-clcp-manifests@revision + +.. _cli-repo-lint: + +Lint +---- + +Sanity checks for repository content (all sites in the repository). To lint +a specific site, see :ref:`site-level linting `. + +See :ref:`linting` for more information. + +Site +==== + +Allows you to perform site-level operations. + +:: + + ./pegleg.sh site -r -e + +Options +------- + +**-r / --site-repository** (Required). + +Path to the root of the site repository (containing site_definition.yaml) repo. + +For example: /opt/aic-site-clcp-manifests. + +The revision can also be specified via (for example): + +:: + + -r /opt/aic-site-clcp-manifests@revision + **-e / --extra-repository** (Optional). Path to the root of extra repositories used for overriding those specified @@ -112,6 +148,9 @@ These should be named per the site-definition file, e.g.: -e global=/opt/global -e secrets=/opt/secrets +Repository Overrides +^^^^^^^^^^^^^^^^^^^^ + By default, the revision specified in the :file:`site-definition.yaml` for the site will be leveraged but can be :ref:`overridden ` using: @@ -172,8 +211,8 @@ Will warn of lint failures from the specified lint options. **--validate** (Optional, validation only). False by default. -Perform validation of documents prior to collection. See :ref:`linting` for -additional information on document linting. It is recommended that document +Perform validation of documents prior to collection. See :ref:`cli-site-lint` +for additional information on document linting. It is recommended that document linting be executed prior to document collection. However, ``--validate`` is False by default for backwards compatibility concerns. @@ -283,43 +322,18 @@ Example: ./pegleg site -r /opt/aic-clcp-site-manifests render site_name -o output -.. _linting: +.. _cli-site-lint: Lint ---- -Sanity checks for repository content. Validations for linting are done -utilizing `Deckhand Validations`_. +Sanity checks for repository content (for a specific site in the repository). +Validations for linting are done utilizing `Deckhand Validations`_. -**-f / --fail-on-missing-sub-src** (Optional). +To lint all sites in the repository, see +:ref:`repository-level linting `. -Raise Deckhand exception on missing substitution sources. Defaults to True. - -**-x ** (Optional). - -Will exclude the specified lint option. -w takes priority over -x. - -**-w ** (Optional). - -Will warn of lint failures from the specified lint options. - -:: - - If you expect certain lint failures, then those lint options can be - excluded or you can choose to be warned about those failures using the - codes below. - - P001 - Document has storagePolicy cleartext (expected is encrypted) yet - its schema is a mandatory encrypted type. - - Where mandatory encrypted schema type is one of: - * deckhand/CertificateAuthorityKey/v1 - * deckhand/CertificateKey/v1 - * deckhand/Passphrase/v1 - * deckhand/PrivateKey/v1 - - P002 - Deckhand rendering is expected to complete without errors. - P003 - All repos contain expected directories. +See :ref:`linting` for more information. Examples ^^^^^^^^ @@ -421,5 +435,39 @@ Valid Git references for checking out repositories include: * refs/changes/79/47079/12 (ref) * master (branch name) +.. _linting: + +Linting +======= + +**-f / --fail-on-missing-sub-src** (Optional). + +Raise Deckhand exception on missing substitution sources. Defaults to True. + +**-x ** (Optional). + +Will exclude the specified lint option. -w takes priority over -x. + +**-w ** (Optional). + +Will warn of lint failures from the specified lint options. + +If you expect certain lint failures, then those lint options can be +excluded or you can choose to be warned about those failures using the +codes below. + +P001 - Document has storagePolicy cleartext (expected is encrypted) yet +its schema is a mandatory encrypted type. + +Where mandatory encrypted schema type is one of: + +* deckhand/CertificateAuthorityKey/v1 +* deckhand/CertificateKey/v1 +* deckhand/Passphrase/v1 +* deckhand/PrivateKey/v1 + +P002 - Deckhand rendering is expected to complete without errors. +P003 - All repos contain expected directories. + .. _Deckhand: https://airship-deckhand.readthedocs.io/en/latest/rendering.html .. _Deckhand Validations: https://airship-deckhand.readthedocs.io/en/latest/validation.html diff --git a/doc/source/images/architecture-pegleg.png b/doc/source/images/architecture-pegleg.png index 173c7aef4cac90ce225f918cf1db61a4b57ab89a..ed0a368d7dc2d6c20368e0d49c1c24f9d6e05e70 100644 GIT binary patch delta 531 zcmV+u0_^?Wr2^ok0+3mM_py0%5 z#KDS;-Fy_QZgJd$Wkm~2$SSaFEsI;L>VNO70mqRdq}9&Hd;8`wx3%HgG*#&^`|->u z4eo62It--|<^b;fYPCEIlOOR}^eef0a4qsh^9l)x+1o3ZxeI@P9R{$8lr&nETk!n} zZ052M61NWfcLrHvQDV^p+6bcfp~G~EPodv;C=jBdG}@6{R=R-)o4lLyIZu0#b;*_*>j)*g z3wYk-{RLQvJTLKoH`n&DPt!+$g*wchma_Md5S6)|w63k6e4Nd} zn|$!wjzM?w1+*w$jU9M44`GJ8QXMKXx1&OB7a(tY9d=9Saf8^h^VqTBMC3f+2h4dk#Mv zTDJ;Au+d<(7(z1dlcZ@cw31dIdt5KtCb(B7*(q~uzP|FN!alD_7pxa8>AKYzlE^Rq z#q((FrNNldN@;F{EFhtugH;Hzkj)=9!x!F^)`3jrR1Qh~SMP?!Tow&4NE=EPDbl15 VR7==@{xSpw;4-KbWwTcThL95Z1Lpt$ delta 528 zcmV+r0`L9cr2^fh0+3mM^?FoTbZ~58Zgh2RYybdwoNZFeYU3~z-3$B=7q60qLtUmb z#fwn#m_Ei~(mKg3LMXCz>x$S?kma;tn17!u+euR>0-^gjN9P{trn21Fx-2~A7SF6U z;7_K$$52^m58&S|7W1<(d5q7ZKgsRA?~pHsmqJea3u9gGv?5j2k!ZwCDl@J+nglb0 z7805dVMLGsmDn_$zwl65{Xs6c`LL2O=dWtX!U_Gl`p6@-J! zi|~37hACPe_Lgd^^qYc=UP~4TR+iXjz1w*Vm99;OAY^5KjZAAx=stVkdk#;va(xlF zsJEE)A(