Add Language and Dir Fields to HookConfig
Part of #7435 — Multi-Language Hook Support
User Story
As a template author, I want to explicitly specify the language of my hook script and its working directory so that azd handles it correctly even when auto-detection isn't sufficient.
Solution Approach
Modify pkg/ext/models.go:
- Import
language package from pkg/tools/language.
- Add new fields to
HookConfig struct:
Language language.ScriptLanguage `yaml:"language,omitempty"`
Dir string `yaml:"dir,omitempty"`
- Add private field:
resolvedLanguage language.ScriptLanguage (set during validate()).
- Add accessor:
func (hc *HookConfig) ScriptLanguage() language.ScriptLanguage.
- Add helper:
func (hc *HookConfig) IsLanguageHook() bool — returns true if resolvedLanguage != ScriptLanguageUnknown.
Important: Do NOT change validate() in this issue — that happens in Issue 4. This issue only adds struct fields and accessor methods.
Modify pkg/ext/models_test.go:
- Test YAML deserialization with
language: python and dir: ./scripts.
- Verify existing tests still pass (new fields are
omitempty).
- Verify
Language field accepts: python, js, ts, dotnet.
Files: pkg/ext/models.go (MODIFY), pkg/ext/models_test.go (MODIFY)
Acceptance Criteria
References
Add Language and Dir Fields to HookConfig
Part of #7435 — Multi-Language Hook Support
User Story
As a template author, I want to explicitly specify the language of my hook script and its working directory so that azd handles it correctly even when auto-detection isn't sufficient.
Solution Approach
Modify
pkg/ext/models.go:languagepackage frompkg/tools/language.HookConfigstruct:resolvedLanguage language.ScriptLanguage(set duringvalidate()).func (hc *HookConfig) ScriptLanguage() language.ScriptLanguage.func (hc *HookConfig) IsLanguageHook() bool— returns true ifresolvedLanguage != ScriptLanguageUnknown.Important: Do NOT change
validate()in this issue — that happens in Issue 4. This issue only adds struct fields and accessor methods.Modify
pkg/ext/models_test.go:language: pythonanddir: ./scripts.omitempty).Languagefield accepts:python,js,ts,dotnet.Files:
pkg/ext/models.go(MODIFY),pkg/ext/models_test.go(MODIFY)Acceptance Criteria
HookConfigmarshals/unmarshals YAML correctly with new fieldsLanguagefield acceptspython,js,ts,dotnetDirfield is a string pathIsLanguageHook()returns false whenresolvedLanguageis unsetReferences