deckhand/deckhand/engine
Phil Sphicas 5cd799cc5d Allow source substring extraction
When performing substitutions, there are occasions when the source value
does not exactly match the format required by the destination document
(e.g. the values.yaml structure of an Armada chart).

This change provides the ability extract a substring of the source
value, and substitute that into the destination document.

Two optional fields are added to `src` under `metadata.substitutions`:

  * `pattern`: a regular expression, with optional capture groups
  * `match_group`: the number of the desired capture group

The canonical use case is a chart that requires an image with the repo
name and tag in separate fields, while the substitution source has the
full image path as a single value.

For example, assuming that the source document "software-versions" has:

    data:
      images:
        hello: docker.io/library/hello-world:latest

Then the following set of substitutions would put the repo and tag in
the applicable values in the destination document:

    metadata:
      substitutions:
        - src:
            schema: pegleg/SoftwareVersions/v1
            name: software-versions
            path: .images.hello
            pattern: '^(.*):(.*)'
            match_group: 1
          dest:
            path: .values.images.hello.repo
        - src:
            schema: pegleg/SoftwareVersions/v1
            name: software-versions
            path: .images.hello
            pattern: '^(.*):(.*)'
            match_group: 2
          dest:
            path: .values.images.hello.tag
    data:
      values:
        images:
          hello:
            repo:  # docker.io/library/hello-world
            tag:   # latest

Change-Id: I2fcb0d2b8e2fe3d85479ac2bad0b7b90f434eb77
2022-01-18 13:04:25 -08:00
..
schemas Allow source substring extraction 2022-01-18 13:04:25 -08:00
__init__.py optimization: Skip post-validation for rendered document cache hit 2018-10-02 18:58:07 -05:00
_replacement.py fix: Use schema instead of metadata.schema for replacement check 2018-10-31 15:02:28 -04:00
cache.py optimization: Skip post-validation for rendered document cache hit 2018-10-02 18:58:07 -05:00
document_validation.py Fix v2 schema support 2019-08-13 11:50:28 -05:00
layering.py Fix encrypted doc rendering 2019-10-04 16:33:46 +00:00
render.py fix: Redact secondhand substitutions of sensitive data 2018-10-25 09:39:50 -04:00
revision_diff.py Fix pep8 gate running on py3.8 2020-09-24 22:35:22 -05:00
secrets_manager.py Allow source substring extraction 2022-01-18 13:04:25 -08:00
utils.py Adding api for revisions deep diffing 2018-09-17 17:01:34 +05:30