deckhand/deckhand
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
..
barbican Fix pep8 gate running on py3.8 2020-09-24 22:35:22 -05:00
client Remove unused code for policy validation as feature not implemented 2020-05-14 00:34:42 +00:00
common Allow source substring extraction 2022-01-18 13:04:25 -08:00
conf Add retries to Barbican secret create 2019-10-04 11:25:50 -05:00
control Remove unused code for policy validation as feature not implemented 2020-05-14 00:34:42 +00:00
db Revision diffing issue with revision rollback. 2018-11-21 11:32:16 -06:00
engine Allow source substring extraction 2022-01-18 13:04:25 -08:00
policies Redacts Raw Documents 2018-10-19 23:56:12 -05:00
tests Allow source substring extraction 2022-01-18 13:04:25 -08:00
__init__.py Accelerate YAML operations with LibYAML 2020-09-25 04:54:48 +00:00
cmd.py Integrate Deckhand with keystone auth 2017-10-16 19:54:46 +01:00
context.py Log client-id in UCP API endpoints 2019-04-05 09:55:09 +00:00
errors.py fix: Use schema instead of metadata.schema for replacement check 2018-10-31 15:02:28 -04:00
factories.py Adding api for revisions deep diffing 2018-09-17 17:01:34 +05:30
policy.py DECKHAND-66: Document substitution implementation 2017-10-13 15:16:27 -04:00
service.py Log client-id in UCP API endpoints 2019-04-05 09:55:09 +00:00
types.py Simplify schema validation 2018-07-03 02:07:33 +00:00