Add filterSuppressions model transform #940
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit adds support for filtering suppressions by removing
unused suppressions, removing the reason from suppressions,
removing suppressions based on an event ID allow/deny list,
and removing suppressions based on a namespace allow/deny list.
This model transform is useful for projecting models with
internal information for external customers so that suppressions
can be retained in the model without exposing internal information.
To support this change, a Suppression abstraction had to be exposed
in smithy-model that was previously never exposed. However, for now,
the abstraction is as bare-bones as possible, and the concrete
suppression types are package-private. ModelValidator was also
significantly refactored to adapt to these Suppression changes, but
remains package-private until we have a compelling reason to expose
it outside of just using ModelAssembler for validation.
smithy-build required a significant refactor to support passing in
the encountered validation events of a projection to ModelTransformers
via the TransformContext object. This gave the FilterSuppressions
transform that ability to access ValidationEvents without needing to
do another expensive round of validation. Only the validation events
encountered for the model at the start of each projection, including
loaded imports, are passed to transforms (that is, intermediate
transforms of the model are not re-validated). However,
FilterSuppressions performs a diff of the validators defined in the
original model and validators defined in the projected model up to
that point to determine if suppressions for any removed validators
should also be removed.
The implementation of the apply transform in smithy-build was also
technically changed in a backward-incompatible way, though this
change will likely not impact any code other than that in the
smithy-build package itself. The transform still works in the same
way, it was just refactored to be implemented just like any other
transform.
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.