Skip to content

Conversation

@kflynn
Copy link
Member

@kflynn kflynn commented Oct 2, 2024

This has been... ugly.

We're starting from the point of view that the v4alpha1 CRDs should be camelCase internally, but that we'll need to still use snake_case when talking to Python (purely as a practical matter of paranoia). Managing that... wow. The Go ecosystem, you see, does not give you control over the tag used when serializing or deserializing JSON or YAML.

The Right Way to manage this may be a PR into encoding/json and sigs.k8s.io/yaml. The short-term way? I've copied those into Emissary's codebase and hacked them. 😛

The end result is:

  • encoding/json uses the json tag (for camelCase v4alpha1 nativeness)
  • github.com/emissary-ingress/emissary/v3/pkg/json uses the v3 tag but falls back to the json tag (for snake_case v3alpha1 madness)
  • sigs.k8s.io/yaml uses the yaml and json tags (for camelCase v4alpha1 nativeness)
  • github.com/emissary-ingress/emissary/v3/pkg/yaml uses the v3 tag but falls back to the yaml and json tags (for snake_case v3alpha1 madness)

and cmd/migrator has the beginnings of a conversion tool. I say "beginnings" because it currently only does snake_case YAML to camelCase YAML but it's a start... and I used it to convert the testdata manifests for the v4alpha1 CRDs.

Signed-off-by: Flynn [email protected]

…1. Allow make generate-fast to work with it.

Signed-off-by: Flynn <[email protected]>
@kflynn kflynn force-pushed the flynn/add-v4alpha1 branch from 4e4efe1 to dc6ddc6 Compare October 16, 2024 02:31
Turns out that the Go ecosystem doesn't currently offer control over the tag used when serializing or deserializing JSON or YAML. This is pretty appalling. We need control over the tag, and the most sane way I've found to support that is _copying all of encoding/json and sigs.k8s.io/yaml into our tree_ and modifying them. Ugh. Bad ecosystem!

Signed-off-by: Flynn <[email protected]>
…e json tag (and, also, it doesn't rely on internal imports)

Signed-off-by: Flynn <[email protected]>
…t to migrate all the v3alpha1 testdata for emissary-ingress.dev/v4alpha1 over to proper v4 CRDs.

Signed-off-by: Flynn <[email protected]>
@kflynn kflynn force-pushed the flynn/add-v4alpha1 branch from dc6ddc6 to 3e925af Compare October 16, 2024 02:33
Signed-off-by: Flynn <[email protected]>
…ions don't!

Really, standard library authors? Really??

Signed-off-by: Flynn <[email protected]>
…world.

This is the point where we _start_ to have some functionality working. The FakeCollision test passes after this change(!!).

Signed-off-by: Flynn <[email protected]>
Signed-off-by: Flynn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants