Skip to content

Commit 6dc7a74

Browse files
committed
parsing output/input directory from module
1 parent dbfbb43 commit 6dc7a74

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

internal/config/moduleconfig/module_config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ type Parameter struct {
2828
type TemplateConfig struct {
2929
StrictMode bool
3030
Delimiters []string
31-
InputDir string
32-
OutputDir string
31+
InputDir string `yaml:"inputDir"`
32+
OutputDir string `yaml:"outputDir"`
3333
}
3434

3535
func LoadModuleConfig(filePath string) (ModuleConfig, error) {

internal/module/module_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestGetSourceDir(t *testing.T) {
2727
}
2828
}
2929

30-
func TestNewTemplateModule(t *testing.T) {
30+
func TestParseModuleConfig(t *testing.T) {
3131
testModuleSource := "../../tests/test_data/modules/ci"
3232
var mod moduleconfig.ModuleConfig
3333

@@ -46,6 +46,13 @@ func TestNewTemplateModule(t *testing.T) {
4646
assert.Equal(t, "CI Platform", param.Label)
4747
})
4848

49+
t.Run("TemplateConfig is unmarshaled", func(t *testing.T) {
50+
mod, _ = module.ParseModuleConfig(testModuleSource)
51+
assert.Equal(t, ".circleci", mod.TemplateConfig.OutputDir)
52+
assert.Equal(t, "templates", mod.TemplateConfig.InputDir)
53+
assert.Equal(t, []string{"<%", "%>"}, mod.TemplateConfig.Delimiters)
54+
})
55+
4956
}
5057

5158
func findParameter(params []moduleconfig.Parameter, field string) (moduleconfig.Parameter, error) {

tests/test_data/modules/ci/zero-module.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ template:
1010
delimiters:
1111
- "<%"
1212
- "%>"
13-
output: "github/test"
13+
inputDir: 'templates'
14+
outputDir: ".circleci"
1415

1516
# required context parameters: will throw a warning message at the end if any of the context parameters are not present
1617
# contextRequired:

0 commit comments

Comments
 (0)