Commit Graph

23 Commits

Author SHA1 Message Date
Sergiy Markin 5470976d4a Airflow stable 2.8.1
Change-Id: I5e78501487e0e1cd3ec1be657f96b80ce951637c
2024-02-23 19:57:08 +00:00
Apurva Gokani 22e6df0870 adding site_type to deployment-data schema
This change adds the site_type parameter in deployment_data
The value will be taken from respective site-definition.yaml

Change-Id: I8e65b39c73c94caf3ed4cc517520b9577160b20d
2020-06-26 12:35:22 -05:00
Carter, Matt (mc981n) 55d0961410 Handle Pegleg-generated commits in deployment data
It is possible for Pegleg to generate a commit on top of a repo if
the repo is dirty (aka, has uncommited/untracked files). This
effectively makes the repo appear "clean", and also changes the head
of the repo. This can potentially interfere with the deployment_data
generation that analyzes the cleanliness of the repo as well as the
commit at the head of the repo.

This patch set updates the deployment_data generation logic, to be
able to detect Pegleg-generated commits at the head of a repo, and
instead go off of the Pegleg-generated commit's parent commit when
generating the data. It also ensures the repo in the data is always
marked dirty if a Pegleg-generated commit is seen, because the
Pegleg-generated commit would not exist unless the repo was dirty.

Change-Id: I863b3f2f661f11c36ba939ee3023f78733021b96
2019-09-12 13:38:54 -05:00
Alexander Hughes 1c8d92ef6b Standardize Pegleg code with YAPF
This patch addresses inconsistent code style and enforces it with a
gate for future submissions.

Separate work will be done in the future to address several of the
PEP8 ignores for docstrings, and attempt to bring the tests directory
to PEP8 compliance.

This patch:
1. Updates .style.yapf to set the knobs desired for YAPF.
2. Updates tox.ini to allow one of the knobs to work.
3. Removes unused code from several __init__.py files.
4. Updates the YAPF version in test-requirements.txt to latest (this
   is needed for several knobs to work).
5. Stylistic changes to the python codebase in Pegleg.
6. Updates to tox.ini to run YAPF during PEP8 check.

Change-Id: Ieaa0fdef2b601d01c875d64b840986e54df73abf
2019-07-25 17:28:18 +00:00
Zuul 1c3e511934 Merge "Align git exception messages" 2019-07-11 03:51:40 +00:00
Matt McEuen 5d5a27a237 Align git exception messages
There were some inconsistencies around whether string parameter passed
into Git exceptions is called repo_path or repo_url, causing the
exception detail to occasionally not get rendered.  This change
standardizes on repo_url.

Change-Id: Ibc78b33cc0e1fcd67820954b715f480a5b1f6496
2019-07-10 14:47:28 -05:00
HUGHES, ALEXANDER (ah8742) c7d745fdbe Bugfix: Get absolute path when making directories
Previously Pegleg would attempt to create directories using the path
specified directly. This path wasn't always an absolute path,
resulting in errors such as:

  File "/opt/pegleg/pegleg/engine/util/files.py", line 265, in dump_all
    os.makedirs(os.path.dirname(path), exist_ok=True)
  File "/usr/local/lib/python3.6/os.py", line 220, in makedirs
    mkdir(name, mode)
FileNotFoundError: [Errno 2] No such file or directory: ''

This bugfix determines an absolute path before attempting to create
any directories.

Change-Id: I84a0e7bc63d6f56a56b9c5c41de1ede99dfbacc7
2019-07-10 13:23:07 -05:00
Lev Morgan 3da63c306b Clarify which refs can be used when
Clarify that refpaths are for unmerged changes in Gerrit and hexsha refs
are for merged commits.

Change-Id: Ib963c3b1a03c1e2751e0661ed7961697670fe190
2019-03-27 12:33:03 -05:00
pallav b79d5b7a98 CLI capability to generate and encrypt passphrases
1. Adds the passphrases generation capability in Pegleg CLI,
so that pegleg can generation random passwords based on a
specification declared in pegleg/PassphrasesCatalog documents
2. Pegleg also wraps the generated passphrase documents in
pegleg managed documents, and encrypts the data.
3. Adds unit test cases for passphrase generation.
4. Updates pegleg CLI document.

Change-Id: I21d7668788cc24a8e0cc9cb0fb11df97600d0090
2019-01-29 16:24:31 -06:00
Felipe Monteiro 2a8d2638b3 pki: Port Promenade's PKI catalog into Pegleg
This patch set implements the PKICatalog [0] requirements
as well as PeglegManagedDocument [1] generation requirements
outlined in the spec [2].

Included in this patch set:

* New CLI entry point called "pegleg site secrets generate-pki"
* PeglegManagedDocument generation logic in
  engine.cache.managed_document
* Refactored PKICatalog logic in engine.cache.pki_catalog derived
  from the Promenade PKI implementation [3], responsible for
  generating certificates, CAs, and keypairs
* Refactored PKIGenerator logic in engine.cache.pki_generator
  derived from Promenade Generator implementation [4],
  responsible for reading in pegleg/PKICatalog/v1 documents (as
  well as promenade/PKICatalog/v1 documents for backwards
  compatibility) and generating required secrets and storing
  them into the paths specified under [0]
* Unit tests for all of the above [5]
* Example pki-catalog.yaml document under pegleg/site_yamls
* Validation schema for pki-catalog.yaml (TODO: implement
  validation logic here: [6])
* Updates to CLI documentation and inclusion of PKICatalog
  and PeglegManagedDocument documentation
* Documentation updates with PKI information [7]

TODO (in follow-up patch sets):

* Expand on overview documentation to include new Pegleg
  responsibilities
* Allow the original repository (not the copied one) to
  be the destination where the secrets are written to
* Finish up cert expiry/revocation logic

[0] https://airship-specs.readthedocs.io/en/latest/specs/approved/pegleg-secrets.html#document-generation
[1] https://airship-specs.readthedocs.io/en/latest/specs/approved/pegleg-secrets.html#peglegmanageddocument
[2] https://airship-specs.readthedocs.io/en/latest/specs/approved/pegleg-secrets.html
[3] https://github.com/openstack/airship-promenade/blob/master/promenade/pki.py
[4] https://github.com/openstack/airship-promenade/blob/master/promenade/generator.py
[5] https://review.openstack.org/#/c/611739/
[6] https://review.openstack.org/#/c/608159/
[7] https://review.openstack.org/#/c/611738/

Change-Id: I3010d04cac6d22c656d144f0dafeaa5e19a13068
2019-01-15 13:29:21 -06:00
Tin Lam a3da86e311 Flake8 fix
This removes all PEP8 ignores and places in default settings for flake8.

Change-Id: I3c4df02dea959dfe58f44e7c0e0ac58078a81abc
Signed-off-by: Tin Lam <tin@irrational.io>
2018-11-13 14:50:42 -06:00
Tin Lam ae81ade94d Refactor Pegleg exceptions
This patch set cleans up the current implementation of pegleg.  As
all the git exceptions inconsistently inits or override the message.
This also cleans up a handful of incorrect kwarg keywords, and improve
handling of the exception messages.

Change-Id: I438eb032728c71cbf972c2120a76d06106cb1580
Signed-off-by: Tin Lam <tin@irrational.io>
2018-11-13 08:58:54 -06:00
Zuul 420f7ae281 Merge "refactor: Add convenient callback for processing site repos" 2018-10-29 16:47:26 +00:00
Felipe Monteiro 2e51779d57 refactor: Exchange NotADirectoryError for better exception
This patch set replaces raising NotADirectoryError after trying
to parse a repository for its root path (normalize_repo_path in
pegleg.engine.util.git) with a better exception
(exceptions.GitInvalidRepoException). It is better because a
folder can still not be a repo, so raising the first exception
isn't apropos.

Next, this patch set changes where the exception is raised --
which is in normalize_repo_path itself, which is more appropriate
as the function is used in many places and so there should be
intrinsic error handling so as to avoid having to wrap it every
time.

Change-Id: I918d8c293f1140eb80c83499dba2c23af232b79e
2018-10-26 10:37:17 -04:00
Felipe Monteiro c498bfee81 fix: Parse revision out of SSH repo url
This patch set adds additional logic to properly handle parsing
out the revision from an SSH repo url. The issue was being
masked by unit tests whose automated logic for calculating
the expected revision mirrored the actual implementation.
Thus, the unit tests have also been refactored to take in
hardcoded expected values to ensure that the assertions are
foolproof around validating expected revisions.

Change-Id: I7aacb4792f6b2dfc08d3a7bb4c3f18bbcfc95b8a
2018-10-25 15:38:28 -04:00
Felipe Monteiro 0fcca0bcdb refactor: Add convenient callback for processing site repos
This patch set adds a callback that can be passed to

    @click.argument(site_name, callback=process_repositories_callback)

This makes it easy to have Pegleg automatically clone done repositories
for the specified site and check out all specified references for
each repository.

Change-Id: I7726a8aec1b1689bffbdbfe81204ed2a14ac4b87
2018-10-23 11:03:22 -04:00
Rick Bartra e3d37db45e Allow the repository clone path to be specified in the CLI
As it currently stands, Pegleg clones site repositories into the /tmp
directory. Even if the site repository already exists in the /tmp
directory it is still cloned there which results in wasted disk space.

This commit allows users to pass in a `clone_path` (-p) option to Pegleg
CLI commands that specify where to clone a site repository. If the clone
path matches the path of an existing repository, then a error message is
logged stating so. If the repository already exists in the clone path, the
user can either specify to use that local repo by passing it as the site
repository or they proceed by passing in a different clone path.

This commit also updates the logic that deletes the copy of the repo that
is created in the temporary folder to also delete the parent folder that
contains the copied repo. This scenario happens when using a local
repository as the site repository.

Addionally, this commit adds a cleanup fixture that removes files and
directories created in the temporary folder by the unit tests.

Change-Id: I1b2943493b8f201f337ea60006c009973dd941b3
2018-10-20 15:21:07 -04:00
Felipe Monteiro ed5251e0e4 fix: Enable Pegleg to support manifest repos like AIAB
This patch set enables Pegleg to support repos like Airship in a
Bottle -- those that have site/ type/ global/ folders nested
under deployment_files/. Very particular logic is needed in order
to handle that. CLI unit tests included for validation/regression.

Change-Id: I9f13f59738599f07329ad3e3274eb4590e8638f9
2018-10-18 19:07:31 +01:00
Rick Bartra 6b2712fc7d Improve Pegleg repository name parsing
If a repository remote ends with `.git` Pegleg is successfully able
to return the repository name. The same is not true in Pegleg if the
repository name does not end in `.git`. This commit allows Pegleg to
support repository names that do and do not end in `.git`.

Change-Id: I45fd15790677e003af7be584221903551022b7d7
2018-10-16 19:52:03 +00:00
Zuul a95cca845c Merge "git: Increase test coverage for missing functions" 2018-10-05 21:26:52 +00:00
Felipe Monteiro ba1842c02e Tidy up collect output file names for cloned repos
This patch set tidies up collect output file names for cloned
repos. As an example, previously the output file could be named
something like tmp5ak7409aic-clcp-security-manifests.yaml -- after
this change it will be aic-clcp-security-manifests.yaml instead
which is much cleaner.

Pegleg "collect" looks at the last piece in a file path to
determine the filename to write to: [0]

This means that changing the clone path here from something like:

/tmp/tmp54d13yairship-pegleg (which will result in collection
output to tmp54d13yairship-pegleg.yaml)

To:

/tmp/tmp54d13y/airship-pegleg (which will result in collection
output to airship-pegleg.yaml)

[0] 2ea1a55a2d/pegleg/engine/site.py (L71)

Change-Id: I2198e299d392e24d376ccfa53bef57fcabf0d41b
2018-09-29 19:54:30 -04:00
Felipe Monteiro 799d302c2a git: Increase test coverage for missing functions
This patch set increases test coverage for some missing git
functions and adds some additional edge case/exception handling
logic to those functions.

Change-Id: I54348599ea959691254c678bc836025cf8df8722
2018-09-24 23:18:09 +00:00
Felipe Monteiro 893ea9f4bb Standardize Pegleg directory structure
This patch set standardizes the Pegleg directory
structure because of the following reasons:

1) src/bin/pegleg is not necessary and only makes
building (e.g. documentation building) and running
of tox targets unnecessarily difficult.
2) src/bin/pegleg is a Java-like standard that
bears no relevance to Python.

Change-Id: I37d39d3d6186b92f8fbfe234221c9e44da48cf10
2018-09-23 10:33:40 -04:00