Skip to content

talm template -I silently strips operator comments above modeline #178

@lexfrei

Description

@lexfrei

Problem

talm template -I -f nodes/node.yaml rewrites the node file in place with the rendered chart output. Any operator-added prose comments above the modeline (project documentation, ticket links, "this node was reset on X for Y" notes) are silently lost — -I is full overwrite, not merge.

Documented behaviour by design (-I flag = rewrite), but the loss is silent: no warning, no count of stripped lines, no preserved-comment block. Operators trip on it regularly.

Reproduction

cd $PROJECT
cat > nodes/node-test.yaml << 'EOF'
# This node was reset 2026-05-12 after ticket OPS-1234 — see internal docs.
# DO NOT edit values directly; modify values.yaml and re-template.
# talm: nodes=["1.2.3.4"], endpoints=["1.2.3.4"], templates=["templates/controlplane.yaml"]
machine:
  certSANs:
    - 1.2.3.4
EOF
talm template -I -f nodes/node-test.yaml
head -3 nodes/node-test.yaml  # operator comments gone, only modeline remains

Verified on the dev17 project: prose comments at the head of nodes/node0.yaml (documenting the OCI / cozystack VIP arrangement) were stripped on the first -I run. Backup restored from git.

Expected — pick one

  1. Preserve a top-of-file comment block (# ... lines before the talm modeline), prepending them back after rewrite.
  2. Emit a stderr warning with a line count: Warning: removed N lines of operator comments above the modeline. Use --no-strip-comments (TODO) to preserve.
  3. Silently fine, document loudly in the talm template -I help and README so operators learn before they lose data.

Option 1 is the most operator-friendly and small in scope (parse the first comment block, re-emit on output before the modeline).

Why this matters

The rewrite path runs unattended in CI / scripted flows; comment loss is invisible until git diff catches it. Operators who don't git commit the change first lose the comments permanently.

Surfaced during the dev17 manual test plan exercise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/commandsIssues or PRs related to pkg/commands (CLI subcommands, flag parsing, root detection)area/templateIssues or PRs related to talm template (chart render, -I rewrite, --set/--values overlays)kind/featureCategorizes issue or PR as related to a new featurepriority/important-longtermImportant over the long term, but may not be staffed and/or may need multiple releases to completetriage/acceptedIndicates an issue is ready to be actively worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions