Accept OS Paths for File Marks #326
Unanswered
pivotaljohn
asked this question in
Ideas
Replies: 1 comment 2 replies
-
|
in this example:
what would happen if config/ has custom/values.yml as well (ie config/custom/values.yml)? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem Statement
yttprovides the user the ability to modify various metadata for files being processed through "File Marks".A file mark targets a set of files described by a
path. It then sets a piece of metadata (file type, whether to exclude entirely, whether to include in output) for all files matching thatpath.The
pathvalue refers not to a filesystem path, but a "relative path". The "relative path" of a file are the path segments from the location specified in the--files/-fvalue to the location of the file.Given this approach, it is easy to include two or more different files that end up having identical "relative path"es. When a File Mark is set for a
For example,
Given these inputs:
where:
config/template/config.yml-- is aytttemplateconfig/custom/values.yml-- contains a Data Values document (meant to customizeconfig/values.yml)config/values.yml-- contains a Data Values documentcustom/values.yml-- contains YAML data intended to bedata.load()'edIn this case, we want to mark
custom/values.ymlastype=data. To do so, we first determine its relative path. This can be done with the--files-inspectflag:And herein lies the problem: today, there's no way to differentiate between the Data Values files (
config/values.ymlandconfig/custom/values.yml) and the file targeted for loading (custom/values.yml).Setting a file mark would affect both
values.ymlfiles:What's needed is the ability to set file marks using a path notation that can disambiguate when two files happen to have the same relative path.
Consideration: Windows Paths
Whatever solution must also support DOS/Windows-style paths...
C:\>ytt -f c:\config\ -f w:\custom\ --file-mark "values.yml:type=data"Consideration: Other Uses of Paths
Paths are used within templates as well (e.g. loading a module from a template, loading data from a file).
Ideally, any solution will make for a unified syntax for expressing paths.
In particular, it has already been established that a path beginning with a path separator is a root library-relative path.
Consideration: Difficulty in Detecting File Marking
Provide an easy way to determine what type a file is.
Possible Solutions
Filesystem Path
The user supplies a
pathvalue from the OS filesystem namespace sufficiently to disambiguate. At a minimum, this would be the "mount path" (i.e. the value given to the corresponding-fargument).When that is insufficient to uniquely identify the desired target files, additional path-parts can be included.
Unix:
$ ytt -f config/ -f custom/ --file-mark "./custom/values.yml:type=data"Note:
os.SameFile()uses the inode and volume id (not the path expression) to determine whether two files are the same.Notice that a file mark path of
custom/values.ymlwould have continued to refer to two files:config/custom/values.ymlandcustom/values.yml. In this case, the standard "current directory" path-part is used to unambiguously refer tocustom/values.ymlWindows:
C:\>ytt -f config\ -f w:\custom\ --file-mark "w:\custom\values.yml:type=data"Note:
os.SameFile()uses a file id (not the path expression) to determine if two files are the same.Edits:
Beta Was this translation helpful? Give feedback.
All reactions