-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move SyncToDisk function to interface
- Loading branch information
Showing
12 changed files
with
139 additions
and
140 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package charts | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
|
||
"helm.sh/helm/v3/pkg/chart" | ||
) | ||
|
||
type DependencyTemplateFile struct { | ||
Content []byte | ||
Path string | ||
} | ||
|
||
var DependencyCacheFolder = ".helm_ls_cache" | ||
|
||
func (c *Chart) NewDependencyTemplateFile(chartName string, file *chart.File) *DependencyTemplateFile { | ||
path := filepath.Join(c.RootURI.Filename(), "charts", DependencyCacheFolder, chartName, file.Name) | ||
|
||
return &DependencyTemplateFile{Content: file.Data, Path: path} | ||
} | ||
|
||
type PossibleDependencyFile interface { | ||
GetContent() string | ||
GetPath() string | ||
} | ||
|
||
// SyncToDisk writes the content of the document to disk if it is a dependency file. | ||
// If it is a dependency file, it was read from a archive, so we need to write it back, | ||
// to be able to open it in a editor when using go-to-definition or go-to-reference. | ||
func SyncToDisk(d PossibleDependencyFile) { | ||
if !IsDependencyFile(d) { | ||
return | ||
} | ||
err := os.MkdirAll(filepath.Dir(d.GetPath()), 0o755) | ||
if err == nil { | ||
err = os.WriteFile(d.GetPath(), []byte(d.GetContent()), 0o444) | ||
} | ||
if err != nil { | ||
logger.Error("Could not write dependency file", d.GetPath(), err) | ||
} | ||
} | ||
|
||
func IsDependencyFile(d PossibleDependencyFile) bool { | ||
return strings.Contains(d.GetPath(), DependencyCacheFolder) | ||
} |
This file was deleted.
Oops, something went wrong.
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
1 change: 0 additions & 1 deletion
1
testdata/dependenciesExample/charts/subchartexample/values.yaml
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
global: | ||
subchart: works | ||
|
||
subchartWithoutGlobal: works |
Oops, something went wrong.