Skip to content

feat: merge variables from required input packages into composable manifests#1

Draft
teresaromero wants to merge 4 commits into3278-bundle-templates-required-input-packagesfrom
3279-merge-variables-when-required-input
Draft

feat: merge variables from required input packages into composable manifests#1
teresaromero wants to merge 4 commits into3278-bundle-templates-required-input-packagesfrom
3279-merge-variables-when-required-input

Conversation

@teresaromero
Copy link
Copy Markdown
Owner

@teresaromero teresaromero commented Mar 24, 2026

Merge input package variables into composable integration manifests

Closes elastic#3279

Composable packages stack — part 2 of 4.
This PR is stacked on elastic#3329 (bundle templates, closes elastic#3278). Merge order: elastic#3329 → this PR → #2#3.
Each PR will be rebased onto main once its predecessor merges.

Summary

Extends the required-inputs build step (introduced in elastic#3329) to merge variable definitions from required input packages into the composable integration's policy template and data stream manifests.

Variable merging follows these rules:

  • Input package variables are the base.
  • The integration package can promote input-level variables by declaring them under policy_templates[].inputs[].vars — they surface as top-level input vars and can override title/description/default.
  • Remaining variables land at data-stream level; the integration can override individual field-level properties without redeclaring the whole variable.
  • If the same variable appears at both levels in the integration manifest, the build fails with a clear error.

What changed

internal/requiredinputs/variables.go (new, ~500 lines)

  • MergeVariables: entry point called after template bundling.
  • Handles variable promotion to input level vs placement at data-stream level.
  • Merge priority: integration-declared override fields win; unset fields fall through to input package defaults.

internal/requiredinputs/variables_test.go (new, ~420 lines)

  • Covers: full merge, DS-only merge, input promotion, no-override passthrough, duplicate-variable error, two-policy-template scoping.

test/manual_packages/required_inputs/ (new fixtures)

  • var_merging_input_pkg — input package defining base variables.
  • with_merging_full — promotes paths+encoding; DS merges timeout; adds custom_tag.
  • with_merging_promotes_to_input, with_merging_ds_merges, with_merging_no_override — targeted scenarios.
  • with_merging_duplicate_error — expects build failure.
  • with_merging_two_policy_templates — validates per-policy-template scoping.

test/manual_packages/README.md — documents manual test fixture usage.

How to test

# Build the variable-merging input package
cd test/manual_packages/required_inputs/var_merging_input_pkg
elastic-package build

# Start the stack (serves the built package via built-in registry)
elastic-package stack up --version 9.4.0-SNAPSHOT

# Build and inspect a merge scenario
cd test/manual_packages/required_inputs/with_merging_full
elastic-package build
# Inspect build/ — merged variables should appear in policy_templates and data_stream manifests

Dependencies

teresaromero and others added 4 commits March 26, 2026 15:51
…ifests

Implements variable merging as part of the required_inputs build step
(issue elastic#3279). Input package vars are the base; composable package
overrides win when explicitly specified. Promoted input-level vars and
data-stream-level vars are correctly placed in the merged manifest.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Relocate required_inputs variable-merge packages from test/packages to
  test/manual_packages/required_inputs (manual-only CI glob).
- Point variables_test and loadInputPkgVarNodes fixtures at the new paths.
- Refresh test/manual_packages/README for unified required_inputs workflow
  and future CI move note.
- Add with_merging_two_policy_templates for scoped promotion across PTs.
- Add mergeVariables-oriented doc comments on variables_test.go.

Made-with: Cursor
BundleInputPackageTemplates was too narrow: the resolver path now also merges
variables from required input packages and may grow further. Rename the
requiredinputs.Resolver method and all call sites, tests, and mocks to Bundle.

Made-with: Cursor
@teresaromero teresaromero force-pushed the 3279-merge-variables-when-required-input branch from ea28eab to e03e531 Compare March 26, 2026 15:09
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