bottlerocket icon indicating copy to clipboard operation
bottlerocket copied to clipboard

Unable to make custom Kubernetes Settings types with `inner` types other than `String`

Open mchaker opened this issue 3 years ago • 0 comments

Image I'm using:

Any k8s variant

What I expected to happen:

Ability to use inner: i32 or any other type besides inner: String in the Kubernetes Settings model (https://github.com/bottlerocket-os/bottlerocket/blob/develop/sources/models/src/modeled_types/kubernetes.rs).

What actually happened:

When trying to use any inner type besides String, compile errors result from mismatched types between what string_impls_for!() expects, and having inner: i32.

string_impls_for!() is required due to the following error that appears when not using string_impls_for!() on a custom Kubernetes Settings type:

the trait bound `modeled_types::kubernetes::ImageGCHighThresholdPercent: _::_serde::Serialize` is not satisfied
required because of the requirements on the impl of `_::_serde::Serialize` for `std::option::Option<modeled_types::kubernetes::ImageGCHighThresholdPercent>`rustc_[E0277](https://doc.rust-lang.org/error-index.html#E0277)_ (https://doc.rust-lang.org/error-index.html#E0277)
mod.rs(1899, 12): required by a bound in `_::_serde::ser::SerializeStruct::serialize_field`
the trait bound `modeled_types::kubernetes::ImageGCHighThresholdPercent: _::_serde::Deserialize<'_>` is not satisfied
required because of the requirements on the impl of `_::_serde::Deserialize<'_>` for `std::option::Option<modeled_types::kubernetes::ImageGCHighThresholdPercent>`

How to reproduce the problem:

Construct a new Kubernetes Settings type with an inner type other than String and try to build Bottlerocket.

mchaker avatar Jun 30 '22 19:06 mchaker