hayone1/mongocd

[User-Story]: starlark

Opened this issue · 0 comments

As a...

As a user
I need a imperative validation feature
So that I can validate my documents before pushing them to the destination database.

Acceptance criteria (optional)

Given I have configured starlark validator in my weave.yml
When I run the build command
Then the validators should be run against my output documents.

Assumptions and Requirements (optional)

  • There should be a validators[].starlarkrun field similar to kpt (starlark run)[https://catalog.kpt.dev/starlark/v0.2/] in the weaveconfig.yml. eg:
render:
  env_name:
    validators:
    - starlarkrun:
        selectors:
          - name: domains
            kind: HelmRelease
        configPath: ""
        configMap:
          replicas: 3
          source: |
            def main():
              atmosphere = ctx['resource_list']["functionConfig"]["data"]["mainAtmosphere"]
              resource = ctx['resource_list']['items'][0]
              
              if not all([atm in resource["mainAtmosphere"] for atm in atmosphere]):
                  fail("atmosphere items [0]", atmosphere, \
                      " missing from resource ", resource)
  • The script will work similarly to how it does in kpt but the entry point must
    be a main() function.
  • The starlarkrun config should also be readable from a config file location relative to the overlays folder with it's location specified in configPath.
  • configPath and configMap shall not be specified in the same starlarkrun validator, if it is, an error should b thrown.

Impact (optional)

High

Version

0.0.1 (Latest)