Skip to content

Add Language and Dir fields to HookConfig #7438

Description

@wbreza

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:

  1. Import language package from pkg/tools/language.
  2. Add new fields to HookConfig struct:
    Language language.ScriptLanguage `yaml:"language,omitempty"`
    Dir      string                  `yaml:"dir,omitempty"`
  3. Add private field: resolvedLanguage language.ScriptLanguage (set during validate()).
  4. Add accessor: func (hc *HookConfig) ScriptLanguage() language.ScriptLanguage.
  5. 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

  • HookConfig marshals/unmarshals YAML correctly with new fields
  • Existing hook tests continue to pass (backward compatible)
  • Language field accepts python, js, ts, dotnet
  • Dir field is a string path
  • IsLanguageHook() returns false when resolvedLanguage is unset

References

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions