Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dag: Support Go template syntax #738

Open
yohamta opened this issue Dec 10, 2024 · 0 comments
Open

dag: Support Go template syntax #738

yohamta opened this issue Dec 10, 2024 · 0 comments
Assignees
Labels
enhancement New feature to be implemented

Comments

@yohamta
Copy link
Collaborator

yohamta commented Dec 10, 2024

Overview
Enhance Dagu's configuration files with Go template support, enabling dynamic content generation and variable substitution using Go's template/text package. Additionally, incorporate the rich set of utility functions from sprig to provide powerful template operations.

Features

  • Full Go template syntax support in most configuration fields
  • Access to all sprig template functions (string operations, math, lists, etc.)
  • Variable substitution across configuration
  • Environment variable support
  • Built-in helper functions

Example Usage

Basic variable substitution:

name: example
params:
  NAME: "World"
  GREETING: "Hello"
steps:
  - name: simple-greeting
    command: "{{.GREETING}}, {{.NAME}}!"

Using sprig functions:

name: templating-example
params:
  USER: "alice"
  ENV: "production"
steps:
  - name: conditional-step
    command: |
      {{- if eq .ENV "production" -}}
      deploy --production --user {{.USER | upper}}
      {{- else -}}
      deploy --staging --user {{.USER | lower}}
      {{- end -}}

  - name: date-based-task
    command: "backup-{{now | date \"2006-01-02\"}}.tar.gz"

Environment variables can be accessed using the env function:

steps:
  - name: env-aware
    command: "deploy --token {{env "API_TOKEN"}}"

This enhancement would make Dagu configurations more flexible and powerful, allowing for dynamic content generation based on variables, environment, and runtime conditions.

@yohamta yohamta added the enhancement New feature to be implemented label Dec 10, 2024
@yohamta yohamta self-assigned this Dec 29, 2024
@yohamta yohamta changed the title Support variable field & Go template syntax template: Support variable field & Go template syntax Dec 29, 2024
@yohamta yohamta changed the title template: Support variable field & Go template syntax template: Support Go template syntax Dec 30, 2024
@yohamta yohamta changed the title template: Support Go template syntax dag: Support Go template syntax Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature to be implemented
Projects
None yet
Development

No branches or pull requests

1 participant