Skip to content

feat(config): add support for output format configuration#300

Draft
neBM wants to merge 1 commit intomcuadros:masterfrom
neBM:feature/log-formatting
Draft

feat(config): add support for output format configuration#300
neBM wants to merge 1 commit intomcuadros:masterfrom
neBM:feature/log-formatting

Conversation

@neBM
Copy link
Copy Markdown

@neBM neBM commented Sep 11, 2024

Logging events with a hardcoded logging format adds to complexity when submitted to logging agros such as an ELK stack.

Short of bringing in encoders to keep the implementation as lightweight as possible, this MR adds support for docker label injected logging format strings.

nekrich pushed a commit to nekrich/ofelia that referenced this pull request Feb 13, 2026
…labels (mcuadros#300)

## Summary

This PR exposes the existing job dependency infrastructure via
user-configurable INI file settings and Docker labels.

- Added `gcfg` and `mapstructure` struct tags to `BareJob` dependency
fields (`Dependencies`, `OnSuccess`, `OnFailure`)
- Created comprehensive tests for dependency configuration parsing
across all job types
- Updated `CONFIGURATION.md` with full documentation and examples

Closes mcuadros#299

## Changes

### Core (`core/bare_job.go`)
- Added `gcfg:"depends-on"` and `mapstructure:"depends-on,"` tags to
`Dependencies` field
- Added `gcfg:"on-success"` and `mapstructure:"on-success,"` tags to
`OnSuccess` field
- Added `gcfg:"on-failure"` and `mapstructure:"on-failure,"` tags to
`OnFailure` field

### Tests (`cli/config_dependencies_test.go`)
- `TestBuildFromString_WithDependencies` - Tests parsing of single and
multiple dependencies
- `TestBuildFromString_DependenciesAllJobTypes` - Verifies all job types
(exec, run, local, service, compose) support dependencies
- `TestBuildFromString_EmptyDependencies` - Verifies jobs without
dependencies work correctly

### Documentation (`docs/CONFIGURATION.md`)
- Added "Job Dependencies" section with complete usage examples
- Documented INI file syntax with multiple `depends-on` lines
- Documented Docker labels syntax for dependencies
- Added configuration options table

## Usage Example

### INI Configuration
```ini
[job-exec "init-database"]
schedule = @daily
container = postgres
command = /scripts/init-db.sh

[job-exec "backup-database"]
schedule = @daily
container = postgres
command = /scripts/backup.sh
depends-on = init-database
on-success = notify-complete
on-failure = alert-ops
```

### Docker Labels
```yaml
labels:
  ofelia.job-exec.process.depends-on: "setup"
  ofelia.job-exec.process.on-success: "cleanup"
  ofelia.job-exec.process.on-failure: "alert"
```

## Test plan
- [x] All existing tests pass
- [x] New dependency configuration tests pass
- [x] Linting passes
- [x] Verified struct tags match existing patterns in codebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant