Repository navigation
Conversation
When validating paths in the fsnode module, use the `filepath` module instead of the (more generic) `path`.
When we move `ImageConfig` into YAML we will need support for `fsnode.File` as it is used as part of the ImageConfig. This can be done in multiple ways, one is to add a custom unmarshaller. This is done in PR#1479 but because of the way the code was written the custom unmarshaling is rather ugly. This commit is an alternative version. As a starting point the struct fields are simply exported and the getters of the same name removed. Then we can add a custom unmarshal that just validates.
This commit adds custom unmarshalers for fsnode.{File,Directory}
that also do validation. For convenience when unmarshaling a
`fsnode.File` we support an extra `text: foo` field so that
in an ImageConfig YAML we can write:
```yaml
minimal_raw: &minimal_raw:
image_config:
files:
- path: "/root/anaconda-ks.cfg"
user: "root"
group: "root"
text: |
# Run initial-setup on first boot
# Created by osbuild
firstboot --reconfig
```
The user can also use `data:` to put a base64 encoded string
in for binary files.
Contributor
Author
|
I also close this one (for now) in favor of #1500 which is less code and (arguably) cleaner. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternative implementation for #1479 that changes the structure of the fsnode as suggested by @achilleas-k and @lzap
I have no super strong opinion. One nice property of the original code with the getters/setters is that after NewFile() it would always be valid. This approach with the exported fields does not protect against changes to invalid data after the creation (or by creation from hand). It also adds a bunch of (extra) churn.
fsnode: add custom unmarshalers for File/Dir
This commit adds custom unmarshalers for fsnode.{File,Directory}
that also do validation. For convenience when unmarshaling a
fsnode.Filewe support an extratext: foofield so thatin an ImageConfig YAML we can write:
The user can also use
data:to put a base64 encoded stringin for binary files.
fsnode: remove Getters, export field to make JSON friendly
When we move
ImageConfiginto YAML we will need support forfsnode.Fileas it is used as part of the ImageConfig.This can be done in multiple ways, one is to add a custom
unmarshaller. This is done in PR#1479 but because of the
way the code was written the custom unmarshaling is rather
ugly.
This commit is an alternative version. As a starting point
the struct fields are simply exported and the getters of
the same name removed. Then we can add a custom unmarshal
that just validates.