mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-23 16:11:48 +00:00
Adds support for dot-prefixed paths in git
- in `flux bootstrap` and `flux create kustomization` etc. - E.g. for example `--path=.flux` should work now - Previous behaviour is to strip off any leading "." and leave you with "./flux" in the kustomizations / folder structure generated by `flux bootstrap` Signed-off-by: Simon Howe <footless@gmail.com>
This commit is contained in:
parent
7752206152
commit
f4418920fb
2 changed files with 8 additions and 1 deletions
|
|
@ -41,7 +41,10 @@ func (p *SafeRelativePath) Set(str string) error {
|
||||||
return fmt.Errorf("invalid relative path '%s': %w", cleanP, err)
|
return fmt.Errorf("invalid relative path '%s': %w", cleanP, err)
|
||||||
}
|
}
|
||||||
// NB: required, as a secure join of "./" will result in "."
|
// NB: required, as a secure join of "./" will result in "."
|
||||||
cleanP = fmt.Sprintf("./%s", strings.TrimPrefix(cleanP, "."))
|
if cleanP == "." {
|
||||||
|
cleanP = ""
|
||||||
|
}
|
||||||
|
cleanP = fmt.Sprintf("./%s", cleanP)
|
||||||
*p = SafeRelativePath(cleanP)
|
*p = SafeRelativePath(cleanP)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,10 @@ func TestRelativePath_Set(t *testing.T) {
|
||||||
{"traversing absolute path", "/foo/../bar", "./bar", false},
|
{"traversing absolute path", "/foo/../bar", "./bar", false},
|
||||||
{"traversing overflowing absolute path", "/foo/../../../bar", "./bar", false},
|
{"traversing overflowing absolute path", "/foo/../../../bar", "./bar", false},
|
||||||
{"empty", "", "./", false},
|
{"empty", "", "./", false},
|
||||||
|
{"relative empty path", "./", "./", false},
|
||||||
|
{"double relative empty path", "././", "./", false},
|
||||||
|
{"dot path", ".foo", "./.foo", false},
|
||||||
|
{"relative dot path", "./.foo", "./.foo", false},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue