Skip to content

feat: add additional preset environment variables#328

Merged
patrick-stephens merged 14 commits into
mainfrom
224_add_env_presets
Jun 25, 2026
Merged

feat: add additional preset environment variables#328
patrick-stephens merged 14 commits into
mainfrom
224_add_env_presets

Conversation

@patrick-stephens

@patrick-stephens patrick-stephens commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Resolves #224 by adding preset environment variables based on the host or build metadata

  • OS_TYPE = linux, windows or macos
  • TELEMETRY_FORGE_AGENT_DISTRO = <the distro we're using, e.g. centos/7>
  • TELEMETRY_FORGE_AGENT_PACKAGE_TYPE = CONTAINER or PACKAGE
  • TELEMETRY_FORGE_AGENT_VERSION = <the agent version we're building>

In each case it will always check for an overridden variable in the environment first and then only set a default if not defined already.

Tests were added as well for the environment variables including the existing HOSTNAME one.
The macOS CI was not setting some variables either.


Summary by cubic

Adds preset env vars for OS and agent metadata, shows them in --help, and makes distro/package type mandatory for enterprise builds. CI and packaging pass the required flags; unit and integration tests verify defaults and overrides, addressing #224.

  • New Features

    • Auto-sets OS_TYPE to linux, windows, or macos.
    • Adds runtime presets AGENT_DISTRO, AGENT_PACKAGE_TYPE, AGENT_VERSION; derived from build metadata, respect overrides, fall back to "unknown".
    • Enforces TELEMETRY_FORGE_AGENT_DISTRO and TELEMETRY_FORGE_AGENT_PACKAGE_TYPE for enterprise builds; TELEMETRY_FORGE_AGENT_VERSION defaults to FLB_VERSION_STR.
    • Prints Distro, Package, and Version in --help.
  • CI and Tests

    • Moves build metadata to source/cmake/enterprise.cmake.
    • Passes -DTELEMETRY_FORGE_* from packaging Dockerfiles, Dockerfile.ubi, macOS and unit-test workflows.
    • Updates build-and-test-container.sh to build a test image and run container integration tests.
    • Adds/updates unit tests for defaults/overrides and an integration test that validates env values via a dummy input and exit plugin.

Written for commit b218e0f. Summary will update on new commits.

Review in cubic

Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Signed-off-by: Patrick Stephens <pat@telemetryforge.io>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds additional “preset” environment variables to the agent’s internal environment (flb_env) so configs can reliably reference OS and build/package metadata, while still honoring any values already provided by the process environment.

Changes:

  • Add preset env vars: OS_TYPE, TELEMETRY_FORGE_AGENT_DISTRO, TELEMETRY_FORGE_AGENT_PACKAGE_TYPE, TELEMETRY_FORGE_AGENT_VERSION (defaults only applied when not already set).
  • Add internal tests covering preset defaults and override behavior.
  • Move build-metadata CMake defines into source/cmake/enterprise.cmake and update macOS package workflow to pass distro/package type.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
source/src/flb_env.c Adds new preset env vars for OS + Telemetry Forge agent build metadata.
source/tests/internal/env.c Adds internal tests for preset defaults and override behavior.
source/CMakeLists.txt Removes build-metadata defines from the top-level CMake file (moved elsewhere).
source/cmake/enterprise.cmake Adds validation/definition of build metadata values for builds using enterprise cmake include.
.github/workflows/call-build-macos-packages.yaml Passes distro/package type into macOS package builds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/src/flb_env.c
Comment thread source/src/flb_env.c
Comment thread source/src/flb_env.c
Comment thread source/src/flb_env.c
Comment thread source/cmake/enterprise.cmake
Comment thread source/cmake/enterprise.cmake
Comment thread .github/workflows/call-build-macos-packages.yaml Outdated
@coveralls

coveralls commented Jun 11, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 28161193752

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.01%) to 57.875%

Details

  • Coverage increased (+0.01%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 293 coverage regressions across 5 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

293 previously-covered lines in 5 files lost coverage.

File Lines Losing Coverage Coverage
src/fluent-bit.c 190 24.2%
tests/internal/env.c 61 68.06%
src/flb_env.c 35 75.38%
plugins/in_telemetryforge/telemetryforge.c 6 0.0%
plugins/in_http/http_conn.c 1 64.48%

Coverage Stats

Coverage Status
Relevant Lines: 161483
Covered Lines: 94565
Line Coverage: 58.56%
Relevant Branches: 35615
Covered Branches: 19505
Branch Coverage: 54.77%
Branches in Coverage %: Yes
Coverage Strength: 5773.9 hits per line

💛 - Coveralls

Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
@patrick-stephens patrick-stephens marked this pull request as ready for review June 25, 2026 09:40
@patrick-stephens patrick-stephens requested a review from a team as a code owner June 25, 2026 09:40
@patrick-stephens patrick-stephens merged commit 97f9db5 into main Jun 25, 2026
32 checks passed
@patrick-stephens patrick-stephens deleted the 224_add_env_presets branch June 25, 2026 09:41
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.

Expose common OS information to configuration parameters

3 participants