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

Credential struct should have json struct tags #193

Closed
mitar opened this issue Dec 1, 2023 · 2 comments · Fixed by #197
Closed

Credential struct should have json struct tags #193

mitar opened this issue Dec 1, 2023 · 2 comments · Fixed by #197
Labels
status/needs-triage Issues that need to be triaged. type/feature-request Feature Requests

Comments

@mitar
Copy link
Contributor

mitar commented Dec 1, 2023

Description

It seems one has to persist credentials. One easy way to do so would be to store them as JSON. But corresponding JSON is ugly because Credential does not have json struct tags.

Use Case

No response

Documentation

No response

@mitar mitar added status/needs-triage Issues that need to be triaged. type/feature-request Feature Requests labels Dec 1, 2023
@james-d-elliott
Copy link
Member

I can likely add this in v0.10.0. It's technically a breaking change but as we're v0 we can probably afford to and people can just copy the old struct as an intermediary if they have issues. Not sure golang's json library has any tooling specifically to handle this situation.

@mitar
Copy link
Contributor Author

mitar commented Dec 2, 2023

So golang json library in fact ignores JSON field case (which is what I primarily would want to achieve with struct tags). So adding json struct tags should just make new JSON have new case, but it would continue to parse old ones. So if somebody did already marshal credentials they will be able to continue use those.

To unmarshal JSON into a struct, Unmarshal matches incoming object keys to the keys used by Marshal (either the struct field name or its tag), preferring an exact match but also accepting a case-insensitive match.

Only if they marshal credentials and parse them with some other tool they might have a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/needs-triage Issues that need to be triaged. type/feature-request Feature Requests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants