spkenv / spk

A Package Manager for high velocity software environments, built on spfs.
https://spkenv.dev
Apache License 2.0
40 stars 6 forks source link

Preserve install environment #1129

Closed jrray closed 2 months ago

jrray commented 2 months ago

Refactor various is_default() methods into IsDefault trait

Fixes #1081. The bug causing #1081 was in InstallSpec::is_default as the logic was not updated when the environment field was added to the struct way back at https://github.com/spkenv/spk/blob/f4899ce1e4ac0634ee95608e322a86a358096d4d/src/api/install_spec.rs#L31

As a guard against this kind of bug in the future, an IsDefault trait was created and a derive macro created to derive the is_default method semi-automatically. All existing is_default methods have been changed to use the trait instead.

And...

Refactor Package::runtime_environment

Both recipes and packages have the install.environment property, so refactor runtime_environment() out of the Package trait into its own trait, then require both Recipe and Package implement it.

This change was prompted in order to make the code in the new test possible.