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
Support toml markup for Platform struct #1073
Comments
I worry that this might perhaps encourage other formats to also request inclusion in our tags here, and I'm not sure it makes sense to maintain all that here 😅 I think this is an unfortunate limitation of Go's struct tagging conventions 😞 Is there a way to convince toml to read the json tags, perhaps? |
Both go-toml and encoding/json support encoding and decoding without tags if the markup name for a field is the same as the struct name, and a case-insensitive match is the fallback if a case-sensitive match is missing. That is, the existing lack of tags should be exactly equivalent to the following (json omitted for clarity): type Platform struct {
Architecture string `toml:"Architecture"`
OS string `toml:"OS"`
OSVersion string `toml:"OSVersion"`
OSFeatures []string `toml:"OSFeatures"`
Variant string `toml:"Variant"`
} and compatible with the following which differs from your desired use case only in lack of underscores: type Platform struct {
Architecture string `toml:"architecture"`
OS string `toml:"os"`
OSVersion string `toml:"osversion"`
OSFeatures []string `toml:"osfeatures"`
Variant string `toml:"variant"`
} |
I think toml is pretty standard and used all over containerd and k8s codebase so would it be ok to support that here as well? |
Not sure I understand this - "Both go-toml and encoding/json support encoding and decoding without tags if the markup name for a field is the same as the struct name" . |
Yes. It also works case-insensitive. |
It would be very helpful to have toml markup for Platform struct in https://github.com/opencontainers/image-spec/blob/main/specs-go/v1/descriptor.go#L53 .
For example, we are trying to add an option of Platform type in containerd's config.toml and toml markup for this struct would be handy:
Thoughts?
The text was updated successfully, but these errors were encountered: