Skip to content

feat(config): expose log.conditions via OWNCLOUD_LOG_CONDITIONS#487

Merged
phil-davis merged 2 commits into
masterfrom
feat-log-conditions-env
Jun 15, 2026
Merged

feat(config): expose log.conditions via OWNCLOUD_LOG_CONDITIONS#487
phil-davis merged 2 commits into
masterfrom
feat-log-conditions-env

Conversation

@DeepDiver1975

Copy link
Copy Markdown
Contributor

What

Exposes ownCloud core's log.conditions config value through a new OWNCLOUD_LOG_CONDITIONS environment variable, parsed in overlay/etc/templates/config.php for all three versions (v20.04, v22.04, v24.04).

Why

log.conditions (documented in core's config.apps.sample.php) is a list of condition maps mixing scalar and array values:

'log.conditions' => [
    [
        'shared_secret' => '...',   // string
        'users'         => ['u1'],  // string[]
        'apps'          => ['a1'],  // string[]
        'logfile'       => '/x.log',// string
        'loglevel'      => 0,       // int
    ],
],

The flat env-var idioms already used in config.php (explode() for flat lists, parse_str() for a single key=value map) cannot represent a list of maps with nested arrays, so this value previously had no env-var equivalent in the image.

How

A single JSON-encoded env var is the faithful representation:

if (getenv('OWNCLOUD_LOG_CONDITIONS') != '') {
  $logConditions = json_decode(getenv('OWNCLOUD_LOG_CONDITIONS'), true);
  if (is_array($logConditions)) {
    $config['log.conditions'] = $logConditions;
  }
}

Example:

OWNCLOUD_LOG_CONDITIONS='[{"apps":["files_external"],"loglevel":0,"logfile":"/var/log/oc-debug.log"}]'

The is_array() guard makes malformed JSON a no-op (key left unset, core falls back to default) rather than a fatal config-generation error.

Testing

  • php -l clean on all three files.
  • Functional test of getConfigFromEnv() covering: valid single condition (all five fields, types preserved), valid multi-condition list, malformed JSON (ignored), and unset (key absent).

🤖 Generated with Claude Code

ownCloud core's 'log.conditions' (documented in config.apps.sample.php)
is a list of condition maps mixing scalar and array values
(apps, users, logfile, loglevel, shared_secret). The flat env-var
idioms used elsewhere in config.php (explode/parse_str) cannot
represent this nested structure, so it had no env-var equivalent in
the image.

Expose it through a single JSON-encoded env var. A json_decode result
that is not an array (malformed JSON) is ignored so a bad value cannot
break config generation.

Applied to all three versions (v20.04, v22.04, v24.04).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
@mmattel

mmattel commented Jun 15, 2026

Copy link
Copy Markdown

Docs to ENVIRONMENT.md is missing

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
@DeepDiver1975 DeepDiver1975 requested a review from phil-davis June 15, 2026 11:18
@phil-davis phil-davis merged commit 6e57637 into master Jun 15, 2026
5 checks passed
@phil-davis phil-davis deleted the feat-log-conditions-env branch June 15, 2026 11:29
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.

3 participants