add basepath along with filepath into yaml comment (#460)
* add basepath along with filepath into yaml comment Signed-off-by: Quan TRAN <itscaro@users.noreply.github.com>
This commit is contained in:
parent
4a5928e269
commit
2702161e74
|
|
@ -543,7 +543,7 @@ func (a *App) PrintState(c StateConfigProvider) error {
|
|||
return
|
||||
}
|
||||
|
||||
fmt.Printf("---\n# Source: %s\n\n%+v", run.state.FilePath, stateYaml)
|
||||
fmt.Printf("---\n# Source: %s\n\n%+v", run.state.FullFilePath(), stateYaml)
|
||||
|
||||
errs = []error{}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -3356,3 +3356,7 @@ func (st *HelmState) getOCIChart(release *ReleaseSpec, tempDir string, helm helm
|
|||
|
||||
return &chartPath, nil
|
||||
}
|
||||
|
||||
func (st *HelmState) FullFilePath() string {
|
||||
return filepath.Join(st.basePath, st.FilePath)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2692,3 +2692,38 @@ func TestGenerateOutputFilePath(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFullFilePath(t *testing.T) {
|
||||
tests := []struct {
|
||||
basePath string
|
||||
filePath string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
basePath: ".",
|
||||
filePath: "helmfile.yaml",
|
||||
expected: "helmfile.yaml",
|
||||
},
|
||||
{
|
||||
basePath: "./test-1/",
|
||||
filePath: "helmfile.yaml",
|
||||
expected: "test-1/helmfile.yaml",
|
||||
},
|
||||
{
|
||||
basePath: "/test-2/",
|
||||
filePath: "helmfile.yaml",
|
||||
expected: "/test-2/helmfile.yaml",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.expected, func(t *testing.T) {
|
||||
st := &HelmState{
|
||||
basePath: tt.basePath,
|
||||
FilePath: tt.filePath,
|
||||
}
|
||||
actual := st.FullFilePath()
|
||||
require.Equalf(t, actual, tt.expected, "FullFilePath() got = %v, want %v", actual, tt.expected)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue