Skip to content

feat: generate example config with all options when creating new project #812

@hartym

Description

@hartym

Summary

Generate a comprehensive config.yml file when running harp-proxy create project. The config will be dynamically generated from source code introspection, showing all available settings as commented YAML with documentation links.

Context

Currently, harp-proxy create project generates an empty config.yml ({}). New users have no visibility into available configuration options without reading documentation. Generating a complete reference config improves discoverability and reduces friction.

The config should be generated at project creation time (not static template) to stay in sync with the actual settings defined in each app's Pydantic models.

Output

Generated config.yml structure:

# =============================================================================
# HARP Proxy Configuration
# =============================================================================
# This file contains all available configuration options with their defaults.
# Uncomment and modify values as needed.
# =============================================================================

# -----------------------------------------------------------------------------
# Dashboard
# See: https://docs.harp-proxy.net/en/latest/apps/dashboard/index.html
# -----------------------------------------------------------------------------
# dashboard:
#   port: 4080
#   auth: null
#   public_url: null

# -----------------------------------------------------------------------------
# Proxy
# See: https://docs.harp-proxy.net/en/latest/apps/proxy/index.html
# -----------------------------------------------------------------------------
# proxy:
#   endpoints: []

# -----------------------------------------------------------------------------
# Storage
# See: https://docs.harp-proxy.net/en/latest/apps/storage/index.html
# -----------------------------------------------------------------------------
# storage:
#   database_url: "sqlite+aiosqlite:///harp.db"
#   migrate: true
#   blobs: {}
#   redis: null

# ... (other apps)

Implementation

  1. Add config generation logic that introspects ApplicationSettingsMixin subclasses
  2. Use Pydantic's model_json_schema() or field iteration to extract:
    • Field names
    • Default values
    • Field descriptions
  3. Hook into cookiecutter post-generation to call the generator
  4. Format output as commented YAML with app section headers and doc URLs

Key files

  • harp/commandline/cookiecutters/project/hooks/post_gen_project.py - post-generation hook
  • harp/config/ - settings base classes with ApplicationSettingsMixin
  • harp_apps/*/settings*.py - app-specific settings to introspect

Testing Scenarios

  1. Happy path: Run harp-proxy create project, verify config.yml contains all app settings commented out
  2. Format validation: Generated YAML should be valid when uncommented
  3. Doc URLs: Each section should have correct documentation URL

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions