-
Notifications
You must be signed in to change notification settings - Fork 101
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
Adds an Unknown
variant to the list of possible mirrord targets for future compat.
#2553
Adds an Unknown
variant to the list of possible mirrord targets for future compat.
#2553
Conversation
Have you tried changing #[derive(Deserialize, ...)
#[serde(untagged)]
pub enum SafeTarget {
KnownTarget(Target),
UnknownTarget {
#[serde(rename = "type")]
type_: String,
},
} The necessary use of |
…rrord into issue/2515/unkown-target-v2
Changed it to an enum, please look into the operator PR to see if it's better now. Name suggestions are welcome, I was thinking |
Looks better imho ^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this change could touch only mirrord_operator
. Would be nice, because unknown targets are only relevant for maintaining forward compatibility with the operator. New wrapper type could be moved to mirrord_operator::crd
and the rest of OSS code could stay unaware of its existence. You wouldn't need to change mirrord_config
or mirrord_kube
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nits + could you add a unit tests asserting that this change is backwards compatible? In test submodule, you could declare a struct like TargetSpecLegacy
(with all the derives) that matches previous format and check how:
- Serialized legacy type with target
None
deserializes into new type - Serialized legacy type with some target deserializes into new type
- New type deserializes from some unknown target type
- Legacy type deserializes from the serialized new type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat!
Unknown
variant forTarget
#2515TargetSpec
from having anOption<Target>
field to anKubeTarget
enum, which can take either aKnown(Target)
or anUnknown(String)
:KubeTarget::Unknown
;