-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
volume structures (mountPath, persistentVolumeClaim) must be lower-case to avoid unmarshal error #4175
Comments
There is an open PR in go-yaml to support json tags go-yaml/yaml#564 |
I ran into this issue too but looking around found this other issue Basically, from the documentation, they stated:
so you could lowercase your fields and it should work, for example:
I wrote down two tests to observe this behavior that at this time I don't know if it is a bug or intended. Failing Test: Passing test: I hope this gives you some guidance or help you in some way |
@dranes - Thank you for the workaround and root causing! I believe this will be considered a documentation bug rather than a code bug, but I've added the discuss label so that we can chat about it next week. |
Thanks @dranes. |
so |
It also means that object inlining, such as used in |
Is there any work around for dealing with configmaps? I think one use case for configmaps is supporting ECR (#731); with ECR we want to mount in a creds.json file. |
…ntainerTools#4175 * As explained in GoogleContainerTools#4175 structs imported from the K8s v1 core API library (e.g. volumes and volumeMounts) aren't parsed correctly because they use json tags whereas the skaffold data structures use the YAML tags. * This PR fixes that by implementing a custom marshler for the Volumes and VolumeMounts fields. The custom marshler removes the problematic fields and parses the rest of the struct using the built in YAML parser. For the problematic fields these are first marshled using json to take advantage of the json tags and then unmarshaled using json to ensure they are unmarshaled based on the json tags.
…ntainerTools#4175 * As explained in GoogleContainerTools#4175 structs imported from the K8s v1 core API library (e.g. volumes and volumeMounts) aren't parsed correctly because they use json tags whereas the skaffold data structures use the YAML tags. * This PR fixes that by implementing a custom marshler for the Volumes and VolumeMounts fields. The custom marshler removes the problematic fields and parses the rest of the struct using the built in YAML parser. For the problematic fields these are first marshled using json to take advantage of the json tags and then unmarshaled using json to ensure they are unmarshaled based on the json tags.
thanks @jlewi for opening a PR to fix this :) We'll try to get that in quickly |
…ntainerTools#4175 * As explained in GoogleContainerTools#4175 structs imported from the K8s v1 core API library (e.g. volumes and volumeMounts) aren't parsed correctly because they use json tags whereas the skaffold data structures use the YAML tags. * This PR fixes that by implementing a custom marshler for the Volumes and VolumeMounts fields. The custom marshler removes the problematic fields and parses the rest of the struct using the built in YAML parser. For the problematic fields these are first marshled using json to take advantage of the json tags and then unmarshaled using json to ensure they are unmarshaled based on the json tags.
…5039) * Create a custom marshler for Volumes and VolumeMounts to fix #4175 * As explained in #4175 structs imported from the K8s v1 core API library (e.g. volumes and volumeMounts) aren't parsed correctly because they use json tags whereas the skaffold data structures use the YAML tags. * This PR fixes that by implementing a custom marshler for the Volumes and VolumeMounts fields. The custom marshler removes the problematic fields and parses the rest of the struct using the built in YAML parser. For the problematic fields these are first marshled using json to take advantage of the json tags and then unmarshaled using json to ensure they are unmarshaled based on the json tags. * * Add custom marshal rountines so that Go -> YAML properly serializes Volumes and VolumeMounts * Run lint. * Fix GCI issues. * Fix GCI issues. * Apply suggestions from code review Co-authored-by: Nick Kubala <nkubala@users.noreply.github.com> Co-authored-by: Tejal Desai <tejal29@gmail.com> Co-authored-by: Nick Kubala <nkubala@users.noreply.github.com>
Follow-up to the issue reported in the comments of this question - #3883
Expected behavior
Skaffold parses the config and builds the image.
Actual behavior
Fails to parse the config
Information
Steps to reproduce the behavior
skaffold build
I'm not a big expert in golang and learned while debugging this issue so any help would be appreciated. So far it looks like this issue with go-yaml library.
Volume-ish structs come from the k8s api and doesn't have yaml tags.
for exampe,
whereas all skaffold structs have the yaml tag
go-yaml ignores external structs with the json tag only and doesn't add them to the schema.
I made a quick change to verify my finding and added yaml tags in all used sctructs in vendor/k8s.io/api/core/v1/types.go, then rebuilt skaffold and reran it against the attached config. The error was gone.
Example
Can anyone help me verify and confirm my finding please? Also any idea on how to fix it would be appreciated.
The text was updated successfully, but these errors were encountered: