Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable diff evaluator #2056

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Nov 30, 2023

  1. Add configurable diff evaluator

    Adds a smithy-diff evaluator which can be configured via metadata
    property `diffEvaluators` within the model. Unlike the similar
    EmitEach/EmitNoneSelectorValidators, this diff evaluator is not
    loaded using SPI, and the ability to create your own custom
    configurable diff evaluators has not been exposed. Instead,
    smithy-diff just looks at the new model's metadata and loads
    any diff evaluators directly. We can expose creating custom
    configurable diff evaluators later if there is a need, but this
    diff evaluator should be enough for almost every use case, and
    we can also extend it easily with more configuration options.
    
    This evaluator works as follows:
    1. Get a subset of shapes to match based on the `appliesTo`
    property. Currently either added shapes or removed shapes.
    2. Optionally filter this subset of shapes further with a
    selector configured in the `filter` property, which runs
    on either the new or old model depending on `appliesTo`.
    3. Run the configured `selector` on either the new model or
    old model depending on `appliesTo`.
    4. Match shapes returned by `selector` to the set of shapes
    from 2, and emit events based on `emitCondition`.
    
    This functionality can be extended later by adding more options
    for `emitCondition` and `appliesTo`. For example, there is
    currently no configuration option for looking at changed shapes,
    but you could imaging wanting to see which shapes don't match
    in the old model, but do in the new model, which would be a new
    `appliesTo`. Another `emitCondition` could be `IfAnyDontMatch`
    or something.
    
    Also adds a validator to smithy-diff for this metadata property so
    you'll know when the model is being build if evaluators have been
    configured incorrectly. This requires having a dependency on
    smithy-diff in the model package where you're configuring the diff
    evaluators, but the alternative is stick the validation in
    smithy-model, creating an implicit dependency on smithy-diff.
    milesziemer committed Nov 30, 2023
    Configuration menu
    Copy the full SHA
    5c8f6a9 View commit details
    Browse the repository at this point in the history