Skip to content

Commit

Permalink
Fix moduleconfig structure to match the schema from the google doc
Browse files Browse the repository at this point in the history
  • Loading branch information
bmonkman committed Jun 6, 2020
1 parent 37178ba commit 5fe94bc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
25 changes: 13 additions & 12 deletions internal/config/moduleconfig/module_config.go
Expand Up @@ -8,27 +8,28 @@ import (
)

type ModuleConfig struct {
Name string
Description string
Author string
Icon string
Thumbnail string
Template TemplateConfig
Credentials []string `yaml:"requiredCredentials"`
Prompts []Prompt `yaml:"parameters"`
Name string
Description string
Author string
TemplateConfig `yaml:"template"`
RequiredCredentials []string
Parameters []Parameter
}

type Prompt struct {
Field string `yaml:"field,omitempty"`
Label string
type Parameter struct {
Field string
Label string `yaml:"value,omitempty"`
Options []string `yaml:"options,omitempty"`
Execute string `yaml:"execute,omitempty"`
Value string `yaml:"value,omitempty"`
Default string `yaml:"default,omitempty"`
}

type TemplateConfig struct {
StrictMode bool
Delimiters []string
Output string
InputDir string
OutputDir string
}

func LoadModuleConfig(filePath string) (ModuleConfig, error) {
Expand Down
6 changes: 3 additions & 3 deletions internal/generate/generate_modules.go
Expand Up @@ -58,12 +58,12 @@ type TemplateParams struct {
}

func Generate(mod *module.TemplateModule, generatorCfg *config.GeneratorConfig) error {
moduleDir := module.GetSourceDir(mod.Source)
delimiters := mod.Config.Template.Delimiters
moduleDir := path.Join(module.GetSourceDir(mod.Source), mod.Config.TemplateConfig.InputDir)
delimiters := mod.Config.TemplateConfig.Delimiters
overwrite := mod.Overwrite
outputDir := mod.Output
if outputDir == "" {
outputDir = mod.Config.Template.Output
outputDir = mod.Config.TemplateConfig.OutputDir
}

templateData := TemplateParams{}
Expand Down
2 changes: 1 addition & 1 deletion internal/module/module.go
Expand Up @@ -64,7 +64,7 @@ func PromptParams(moduleConfig moduleconfig.ModuleConfig, parameters map[string]

// PromptParams renders series of prompt UI based on the config
func (m *TemplateModule) PromptParams(projectContext map[string]string) error {
for _, promptConfig := range m.Config.Prompts {
for _, promptConfig := range m.Config.Parameters {

label := promptConfig.Label
if promptConfig.Label == "" {
Expand Down

0 comments on commit 5fe94bc

Please sign in to comment.