Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const (
// TlsCertSecretYAML is the manifest file for the kubernetes secret enabling HTTPS
TlsCertSecretYAML string = "tls-letsencrypt-secret.yaml"

// DefaultConfigFile is the filename used, if none is set in config file(s)
DefaultConfigFile string = "os-config.yaml"
// DefaultTemplatingOutputFilename is the filename used, if none is set in config file(s)
DefaultTemplatingOutputFilename string = "os-deployment.yaml"

// TemplateSuffix is the recognized suffix for template files
TemplateSuffix string = ".tmpl"
Expand Down
5 changes: 3 additions & 2 deletions internal/instance/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,11 @@ func getFilename(cfg map[string]any, tplFile string) string {
if fn, ok := cfg["filename"].(string); ok && fn != "" {
return fn
}
if tplFilePretty, found := strings.CutSuffix(tplFile, constants.TemplateSuffix); found {
tplBase := filepath.Base(tplFile)
if tplFilePretty, found := strings.CutSuffix(tplBase, constants.TemplateSuffix); found {
return tplFilePretty
}
return constants.DefaultConfigFile
return constants.DefaultTemplatingOutputFilename
}

type TemplateFunctions struct {
Expand Down
8 changes: 4 additions & 4 deletions internal/instance/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ func TestGetFilename(t *testing.T) {
"other": "value",
}
result := getFilename(cfg, "myspecial.yaml")
if result != constants.DefaultConfigFile {
t.Errorf("Expected %s, got %s", constants.DefaultConfigFile, result)
if result != constants.DefaultTemplatingOutputFilename {
t.Errorf("Expected %s, got %s", constants.DefaultTemplatingOutputFilename, result)
}
})
t.Run("empty filename in config, with template file", func(t *testing.T) {
Expand Down Expand Up @@ -532,7 +532,7 @@ func TestCreateDirAndFiles(t *testing.T) {

t.Run("invalid template path", func(t *testing.T) {
cfg := map[string]any{
"filename": constants.DefaultConfigFile,
"filename": constants.DefaultTemplatingOutputFilename,
}
err := CreateDirAndFiles(tmpdir, false, "nonexistent-template", cfg)
if err == nil {
Expand Down Expand Up @@ -580,7 +580,7 @@ func TestCreateDirAndFiles(t *testing.T) {

outDir := filepath.Join(tmpdir, "output2")
cfg := map[string]any{
"filename": constants.DefaultConfigFile,
"filename": constants.DefaultTemplatingOutputFilename,
}

err := CreateDirAndFiles(outDir, true, tplDir, cfg)
Expand Down
Loading