-
Notifications
You must be signed in to change notification settings - Fork 826
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
GameServerAllocation example yaml file has incorrect format for selectors #2853
Comments
Oooh! Interesting, because https://github.com/googleforgames/agones/blob/main/examples/xonotic/gameserverallocation.yaml works just fine 🤔 I use that demo all the time, but that's going through k8s. I wonder if this is an issue with Do you have the same issue if you use the same library as Kubernetes: https://pkg.go.dev/k8s.io/apimachinery/pkg/util/yaml ? |
You're correct, it unmarshalls successfully with the Kubernetes library. I'm not sure what the right thing to do here is - the Kubernetes yaml library only offers deserialization, not serialization, so it seems like it's a common footgun for users here since if you're doing anything with yaml in go you're likely not to be using the Kubernetes yaml library due to this limitation. Maybe you could consider adding the json:",inline" but I'm not sure, if this works or how this affects compatibility with either library, or backwards compatibility for that matter. Sadly (?) I'm not a yaml expert, but both are seemingly valid yaml. It's just a shame to have such a footgun in the examples. Feel free to close this issue anyway. |
I feel like we could definitely add Out of curiosity, do you have a use case to go from Go -> YAML for what you are doing? |
Not for Agones, but we use (and serialize) yaml for other things so we were using the go-yaml library for that. |
Yeah - that makes sense! |
@markmandel - is there a downside in updating the example yaml files (as an alternative to adding the inline tag)? Do you think it's clearer to not specify the The code in our e2e tests where we use |
Other than it's a change in the API surface? 😄 (well not really, since the original still works).
Personally, I do - But also, Kubernetes as as whole doesn't expose the LabelSelector (we steal that data structure from them), although it calls it an individual "selector" in each of the cases below: |
In that case, adding |
The K8s YAML library will inline embeded structs, but some other ones will not. So adding the `json:",inline"` hint, so that they know that the `v1.LabelSelector` should be inlined if people are so inclined to reference it via Golang yaml libraries. Closes googleforgames#2853
The K8s YAML library will inline embeded structs, but some other ones will not. So adding the `json:",inline"` hint, so that they know that the `v1.LabelSelector` should be inlined if people are so inclined to reference it via Golang yaml libraries. Include regeneration of the crd docs and client libraries, which picked up on some small changes. Closes googleforgames#2853
The K8s YAML library will inline embeded structs, but some other ones will not. So adding the `json:",inline"` hint, so that they know that the `v1.LabelSelector` should be inlined if people are so inclined to reference it via Golang yaml libraries. Include regeneration of the crd docs and client libraries, which picked up on some small changes. Closes #2853
What happened:
The GameServerAllocation example yaml file has the incorrect format for it's selectors:
https://github.com/googleforgames/agones/blob/release-1.27.0/examples/gameserverallocation.yaml#L38-L45
You're missing the
labelSelector
, I believe this is because it is missing ajson:",inline"
for it's json tag:https://github.com/googleforgames/agones/blob/release-1.27.0/pkg/apis/allocation/v1/gameserverallocation.go#L103
Also the usage of the
matchExpressions
selector could be clearer for yaml, I've updated that below too.What you expected to happen:
The examples should deserialize correctly from yaml to into a `v1.GameSeverAllocation object.
The following format deserializes correctly for me into a
v1.GameSeverAllocation
and I think is clearer for the example:Alternatively I think you could likely fix the
json:",inline"
missing from theLabelSelector
to resolve the issue to match the examples, but I didn't test that.How to reproduce it (as minimally and precisely as possible):
Here's a short program I wrote to dump the spec
Anything else we need to know?:
Due to my internal policies I am unable to open a PR for this. My apologies.
Environment:
kubectl version
): n/aThe text was updated successfully, but these errors were encountered: