Skip to content
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

alertmanager crd needs support for invalid enum names #92

Closed
clux opened this issue Nov 9, 2022 · 2 comments
Closed

alertmanager crd needs support for invalid enum names #92

clux opened this issue Nov 9, 2022 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@clux
Copy link
Member

clux commented Nov 9, 2022

In their schema:

                          matchType:
                            description: Match operation available with AlertManager
                              >= v0.22.0 and takes precedence over Regex (deprecated)
                              if non-empty.
                            enum:
                            - '!='
                            - =
                            - =~
                            - '!~'
                            type: string

This forces us to basically come up with our own names for the enum variants (because we can't simply drop invalid characters because they are all invalid in identifiers - even if wrapped in a rawstring).

So we have an immediate first step:

  • implement a Container::invalid_enum_identifiers(&self) -> bool that checks if any of the members have such a name in the enum
  • call that function in main, and if it's true; use generic Variant0, Variant1 names for them (but with #[serde(rename)] attrs to keep it compliant)

..and as a potential third step; args/config for letting users customize the values of these Variant names since it's pretty unergonomic to work with. First priority is to get it to compile though.

@clux clux added the help wanted Extra attention is needed label Nov 9, 2022
@clux
Copy link
Member Author

clux commented Nov 9, 2022

The function that detects validity could maybe use a regex or maybe https://docs.rs/syn/1.0.103/syn/fn.parse_str.html

@Dav1dde
Copy link
Member

Dav1dde commented Nov 12, 2022

Fixed with #103

@Dav1dde Dav1dde closed this as completed Nov 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants