-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove Dir field and make Fs as the core path field
This branch removes dir field and makes users only specify the full path in `Fs` field. Helper functions are added to make this easy. Changes are also made in charts generation code to remove the passage of `Charts.yaml` for dependency charts i.e partials, etc as it confuses the generation. Only the top level charts will pass the `Chart.yaml` and for every other dep chart they only pass the templated files for rendering. Signed-off-by: Tarun Pothulapati <[email protected]>
- Loading branch information
1 parent
b1dbb1c
commit a004d1f
Showing
9 changed files
with
65 additions
and
69 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package static | ||
|
||
import ( | ||
"net/http" | ||
"path" | ||
"path/filepath" | ||
"runtime" | ||
) | ||
|
||
// WithPath creates a FileSystem with the given path from the repo root path | ||
func WithPath(subPath string) http.FileSystem { | ||
return http.Dir(path.Join(getRepoRoot(), subPath)) | ||
} | ||
|
||
// WithDefaultChart creates a FileSystem with the given path under the charts path | ||
func WithDefaultChart(subPath string) http.FileSystem { | ||
return http.Dir(path.Join(getRepoRoot(), "charts", subPath)) | ||
} | ||
|
||
// getRepoRoot returns the full path to the root of the repo. We assume this | ||
// function is only called from the `Templates` var above, and that this source | ||
// file lives at `pkg/charts/static`, relative to the root of the repo. | ||
func getRepoRoot() string { | ||
// /foo/bar/linkerd2/pkg/charts/static/templates.go | ||
_, filename, _, _ := runtime.Caller(0) | ||
|
||
// /foo/bar/linkerd2/pkg/charts/static | ||
dir := filepath.Dir(filename) | ||
|
||
// filepath.Dir returns the parent directory, so that combined with joining | ||
// ".." walks 3 levels up the tree: | ||
// /foo/bar/linkerd2 | ||
return filepath.Dir(path.Join(dir, "../..")) | ||
} |
This file contains 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
This file contains 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