Refactor models to reduce duplication #591
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.
To be able to have
models/lib.rs
with shared code, we needed to stop symlinking the entiresrc
directory and instead treat the variant-specific code as Rust modules, symlinking the correct one tovariant::current
so thatlib.rs
can re-exportSettings
. (We also have to symlink invariant/mod.rs
so Rust knows it's part of the module hierarchy.)Now, each variant defines a
Settings
structure using common sub-structures. Those sub-structures live in the mainlib.rs
, and the modeled types are now in a sharedmodeled_types
module. No changes were made to the code, just its organization.Documentation was updated to reflect these changes, including using cargo-readme to generate README.md now that there's a single source.
Reviewer's note: regarding the giant green/red code blocks - nothing in the implementation changed, it's just in a different place.
Testing done:
Confirmed that all
workspaces/
unit tests pass, whether for aws-dev or aws-k8s.Confirmed that local builds still create the symlink(s) correctly and get the right model.
Made an aws-k8s AMI, confirmed that the containerd config still has the CRI settings. It connected to my cluster and ran a pod OK.
Made an aws-dev AMI, confirmed that the containerd config was the smaller dev version. Ran a docker container OK.