这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@walteh
Copy link
Owner

@walteh walteh commented Aug 5, 2025

Summary

  • introduce Loader interface and YAMLLoader implementation
  • allow registering loaders by extension and default to YAML
  • use registered loader in reader and add unit test for YAMLLoader
  • document that ast Taskfile parsing still relies on YAML-specific logic

Testing

  • go test ./...

Prompt

Task 1: Refactor Configuration Loading (Abstract YAML Parsing)

Purpose: Prepare the codebase to handle multiple config file formats (YAML and HCL) by abstracting the parsing logic. Currently, the Taskfile loading is tightly coupled to YAML via built-in UnmarshalYAML methods. We need to introduce a format-agnostic layer so that adding HCL becomes straightforward.
• Implementation:
• Identify where Taskfiles are read and parsed (e.g. functions that search for Taskfile.yml and call YAML unmarshal). Refactor this logic to use a config loader interface or strategy pattern. For example, define an interface TaskfileLoader with a method like LoadTaskfile(path) (*Taskfile, error).
• Provide two implementations: YAMLLoader (uses existing YAML unmarshal logic) and HCLLoader (to be implemented in later tasks). Determine format by file extension or content.
• Decouple YAML-specific code: If Taskfile.UnmarshalYAML and other struct methods exist, consider moving YAML-specific unmarshalling into the YAML loader. The core Taskfile struct should not assume YAML input.
• Ensure that all references to YAML in the loading process (e.g. error messages like “invalid YAML”) are either generalized or moved into the YAML loader. This lays the groundwork for adding HCL seamlessly.
• Validation:
• All existing tests for loading and parsing YAML Taskfiles must continue to pass. For example, running task with a standard Taskfile.yml should behave exactly as before.
• Add a unit test for the loader interface: invoke the YAML loader on a known-good Taskfile YAML content and verify it returns a proper Taskfile struct (same as direct unmarshal). This confirms the refactor didn’t break YAML support.


https://chatgpt.com/codex/tasks/task_e_6891f2a02d888330bc1cd199e30270bb

@walteh walteh changed the base branch from main to codex/hcl August 5, 2025 12:44
@walteh walteh marked this pull request as ready for review August 5, 2025 12:44
@walteh walteh merged commit 82cbb36 into codex/hcl Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants